Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Driving a raw LCD from MSP430
// 2010 Kenneth Finnegan
// http://kennethfinnegan.blogspot.com/
// Ultra-low power LCD counter experiment
#include "msp430G2231.h"
// Which digit is being displayed
volatile unsigned char mode;
// refresh periods spent in current mode
volatile unsigned char modecnt;
// bitmaps for the 7 segment digits 0-9
const unsigned char digits[] = { 0x7B, 0x18, 0x6D, 0x3D, 0x1E, 0x37, 0x77, 0x19, 0x7F, 0x1F};
// FUNCTIONS
void pause (int c);
void main(void) {
WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog Timer
BCSCTL2 = 0xF8; // MCLK:LFXT1CLK/8 SMCLK:LFXT1CLK
P1DIR = 0xFF;
P1OUT = 0x00;
CCTL0 = CCIE;
CCR0 = 0;
TACCR0 = 0x3FF; // Period of 1023 + 1 cnts, which is 32Hz
TACTL = 0x0211; // Timer_A: SMCLK, UP MODE, TAIE
// Sleep forever...
_BIS_SR(LPM1_bits + GIE);
}
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void) {
// Increment refresh count
modecnt = (modecnt+1) % 32;
// Change displayed digit every second
if (modecnt == 0) {
mode = (mode + 1) % 10;
P1OUT = digits[mode];
}
// Reverse all pins to alternately bias the LCD
P1OUT ^= 0xFF;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment