|
- #include "msp430f6638.h"
- #define d 0x01
- #define c 0x20
- #define b 0x40
- #define a 0x80
- #define dp 0x10
- #define g 0x04
- #define f 0x08
- #define e 0x02
- const char char_gen[]={
- a+b+c+d+e+f,//0
- b+c, //1
- a+b+d+e+g, //2
- a+b+c+d+g, //3
- b+c+f+g, //4
- a+f+g+c+d, //5
- a+c+d+f+e+g, //6
- a+b+c, //7
- a+b+c+d+e+f+g,//8
- a+b+c+d+f+g}; //9
- void delay_ms(unsigned int ms)
- {
- unsigned char m;
- while(ms--)
- for(m=0;m<100;m++);
- }
- void Init_lcd(void)
- {
- LCDBCTL0 =LCDDIV0+LCDPRE0+LCDMX1+LCDSSEL+LCDMX1+LCD4MUX;
- LCDBPCTL0=LCDS0+LCDS1+LCDS2+LCDS3+LCDS4+LCDS5+LCDS6+LCDS7
- +LCDS8+LCDS9+LCDS10+LCDS11;
- P5SEL =0xfc;
- }
- void LcdGo(unsigned char Dot)
- {
- if(Dot==1)
- {
- //打開(kāi)液晶顯示
- LCDBCTL0 |=LCDON;
- }
- else if(Dot==0)
- {
- LCDBCTL0 &=~LCDON;
- }
- }
- /*顯示消隱*/
- void Lcdblink(unsigned char doit)
- {
- if(doit==0)
- {
- LCDBCTL0 &=~LCDSON;
- }
- else if(doit==1)
- {
- LCDBCTL0 |=LCDSON;
- }
- }
- void LCD_clear(void)
- {
- unsigned char index;
- for(index=0;index<12;index++)
- {
- LCDMEM[index]=0;
- }
- }
- void Backlight_enable(void)
- {
- P5DIR |=BIT7;
- P5OUT &=~BIT7;
- }
- int main( void )
- {
- unsigned num,n;
- // Stop watchdog timer to prevent time out reset
- WDTCTL = WDTPW + WDTHOLD;
- Init_lcd();
- LcdGo(1);
- //Lcdblink(1);
- LCD_clear();
- Backlight_enable();
- while(1)
- {
- for(num=0;num<3;num++)
- {
- for(n=0;n<4;n++)
- {
- LCDMEM[num*4+n]=char_gen[num*4+n];
- delay_ms(1000);
- }
- LCD_clear();
- }
- }
- }
復(fù)制代碼
|
|