/* Lcd test */

// Define CPU Type
#define __MSP430_449__

#include <io.h>

void wait(void);
void ClearLCD( void );

/*******************************************************************
 Main Code Routine
*******************************************************************/
#define LCD13_ 0x9D
sfrb(LCD13,LCD13_);
int main(void)
{

    WDTCTL = WDTPW + WDTHOLD;             // Stop watchdog timer
    FLL_CTL0 |= XCAP14PF;                 // Configure load caps
    LCDCTL = LCDON + LCD4MUX + LCDP0 + LCDP1 + LCDP2;     // STK LCD 4Mux, S0-S35
    BTCTL = BTFRFQ1;                      // STK LCD freq
    P5SEL = 0xFC;                         // Common and Rxx all selected

    P1DIR = 0xFF;           //port 1 = output
    P1OUT = 0x01;           //set bit 0 in port 1

    ClearLCD( );

    for ( ; ; )              //infinite loop
        {
        P1OUT=~P1OUT;        //invert port 1
        ClearLCD( );
        wait();              //call delay function
        P1OUT=~P1OUT;        //invert port 1
        LCD13 = 0x01;
        wait();              //call delay function
        P1OUT=~P1OUT;        //invert port 1
        LCD13 = 0x02;
        wait();              //call delay function
        P1OUT=~P1OUT;        //invert port 1
        LCD13 = 0x04;
        wait();              //call delay function
        P1OUT=~P1OUT;        //invert port 1
        LCD13 = 0x08;
        wait();              //call delay function
        P1OUT=~P1OUT;        //invert port 1
        LCD13 = 0x10;
        wait();              //call delay function
        P1OUT=~P1OUT;        //invert port 1
        LCD13 = 0x20;
        wait();              //call delay function
        P1OUT=~P1OUT;        //invert port 1
        LCD13 = 0x40;
        wait();              //call delay function
        P1OUT=~P1OUT;        //invert port 1
        LCD13 = 0x80;
        wait();              //call delay function
        }
}

void wait(void)          //delay function
{
  volatile int i;        //declare i as volatile int
  for(i=0;i<32000;i++);  //repeat 32000 times
}

/*******************************************************************
 Clear the LCD
*******************************************************************/
void ClearLCD( void )
{
unsigned int i;

    for ( i = 0; i <= 20; i++ )
        LCDMEM[i] = 0;
}
