本帖最后由 nwx8899 于 2012-7-21 14:30 编辑
1 液晶介绍
2 电路连接
3 取字模
3 project
4 效果预览
5 源代码
-
复制代码- /***********************************************
- **** LAUNCH PAD 学习之LCD 12864***
- **** MCU: MSP430 ***
- **** 作者: nwx***
- **** ***
- **** ***
- **** 实验现象:LCD显示 LOG ***
- **** *** 2012.6.27
- ****P1.0~P1.7 数据口 P2.0 P2.1 P2.2 en rs Psb***
- ***********************************************/
- #include <msp430g2452.h>
- #define uchar unsigned char
- #define uint unsigned int
- #define BUTTON BIT3 //P1.3为板上按键S2
- const uchar table[]="欢迎参加TI在线培训!";
- const uchar table1[]="LaunchPad ";
- const uchar table2[]=" 点火开始!";
- uchar num;
- void delay_1ms(void)
- {
- uint i;
- for (i=0;i<1140;i++);
- }
- /*-- 调入了一幅图像:C:UsersAdministratorDesktoplaunchpad.bmp --*/
- /*-- 宽度x高度=128x64 --*/
- const uchar image[]=
- {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x03,0xFF,0xFE,0x7F,0xFF,
- 0x01,0xF8,0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x3F,0xFF,0xE3,0xFF,0xFE,0x7F,0xFF,
- 0x07,0xFF,0x00,0x07,0xC7,0xF8,0x0F,0xFF,0x00,0x38,0x70,0xE0,0x00,0x1C,0x70,0x00,
- 0x1F,0xFF,0x80,0x1F,0xC7,0xF8,0x1F,0xFF,0x80,0x30,0x60,0x60,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xF0,0x3E,0x1C,0x0F,
- 0x7F,0xFF,0xC0,0x3F,0xC7,0xF8,0x0F,0xFF,0x03,0x87,0xFF,0xC7,0xE0,0x3C,0x18,0x0F,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x01,0xFF,0xC0,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- }; //第一幅图像数据
- const uchar image1[]=
- {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xE0,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFC,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x87,0xFE,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xF0,0x00,0x0E,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x80,0x1F,0xFF,0xF0,0x00,0x06,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE1,0xF0,0xFF,0xFF,0xF0,0x00,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x3F,0xFF,0xFF,0xF8,0x00,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xF0,0x00,0x1F,0xEF,0xFF,0xF8,0x00,0x06,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x7F,0x07,0xFF,0xFC,0x00,0x0E,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x01,0xF8,0x03,0xFF,0xFC,0x00,0x0E,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF8,0x03,0xE0,0x03,0xFF,0xFE,0x00,0x3C,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x1C,0x0F,0x80,0x01,0xFF,0xFE,0x00,0x78,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x3E,0x00,0x01,0xFF,0xFE,0x00,0xF0,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x7C,0x00,0x00,0xFF,0xFE,0x03,0xE0,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xF0,0x00,0x00,0xFF,0xFE,0x07,0xC0,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x03,0xC0,0xFF,0xFE,0x1F,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xC0,0x03,0x80,0x0F,0xE0,0x7F,0xFF,0x7E,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xC0,0x03,0x00,0xFF,0xE0,0x7F,0xFF,0xF8,0x00,
- 0x00,0x00,0x00,0x00,0x03,0xFE,0x00,0x00,0x01,0x03,0xFF,0xC0,0x7F,0xFF,0xE0,0x00,
- 0x00,0x00,0x00,0x00,0x1F,0xC0,0x00,0x00,0x41,0x9F,0xFC,0x00,0x7F,0xFF,0x80,0x00,
- 0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x1F,0xC1,0xFF,0xE0,0x00,0x7F,0xFF,0x00,0x00,
- 0x00,0x00,0x00,0x03,0xE0,0x00,0x03,0xFE,0x07,0xFE,0x00,0x00,0x7F,0xF8,0x00,0x00,
- 0x00,0x00,0x00,0x0F,0x00,0x00,0xFF,0xC0,0x3F,0xF0,0x00,0x00,0x7F,0xE0,0x00,0x00,
- 0x00,0x00,0x00,0x3C,0x00,0x07,0xF8,0x00,0xFF,0xC0,0x00,0x00,0xFF,0x80,0x00,0x00,
- 0x00,0x00,0x00,0xF0,0x00,0x7E,0x00,0x01,0xF0,0xC0,0x00,0x1F,0xFC,0x00,0x00,0x00,
- 0x00,0x00,0x03,0x80,0x03,0xF0,0x00,0x01,0x80,0x40,0x03,0xFF,0xE0,0x00,0x00,0x00,
- 0x00,0x00,0x0E,0x00,0x1F,0x80,0x00,0x00,0x00,0x7F,0xFF,0xFE,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x18,0x00,0x7C,0x00,0x00,0x00,0x00,0x7F,0xFF,0xF0,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x70,0x01,0xE0,0x00,0x00,0x0C,0x00,0x3F,0xF8,0x60,0x00,0x00,0x00,0x00,
- 0x00,0x01,0xE0,0x07,0x80,0x00,0x00,0x38,0x00,0x30,0x00,0xC0,0x00,0x00,0x00,0x00,
- 0x00,0x03,0x80,0x3C,0x00,0x00,0x00,0xF0,0x38,0x30,0x01,0xC0,0x00,0x00,0x00,0x00,
- 0x00,0x0E,0x00,0x70,0x00,0x00,0x01,0xC0,0x70,0x30,0x03,0x80,0x00,0x00,0x00,0x00,
- 0x00,0x1C,0x01,0xC0,0x00,0x00,0x07,0x00,0xE0,0x30,0x07,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x70,0x07,0x00,0x00,0x00,0x1C,0x01,0x80,0x60,0x1E,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xE0,0x0C,0x00,0x00,0x00,0xF8,0x03,0x00,0xE0,0x78,0x00,0x00,0x00,0x00,0x00,
- 0x03,0x80,0x38,0x00,0x00,0x01,0xC0,0x0E,0x01,0xC1,0xE0,0x00,0x00,0x00,0x00,0x00,
- 0x07,0x00,0xF0,0x00,0x00,0x0F,0x00,0x1C,0x07,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,
- 0x0E,0x01,0xC0,0x00,0x00,0xFC,0x00,0x70,0x1F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x18,0x01,0x00,0x00,0x0F,0xE0,0x01,0xE0,0x3F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x70,0x00,0x00,0x01,0xFE,0x00,0x03,0x80,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xE0,0x00,0x00,0x03,0xE0,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xC0,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x18,0x00,0x00,0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x1F,0xF8,0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xFF,0xFF,0xF0,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xE0,0x00,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xC0,0x00,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x01,0x80,0x1F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x01,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x03,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- }; //第二幅图像数据
- /*****************************************
- *
- * N ms延时函数
- *
- ****************************************/
- void delay_nms(uint n)
- {
- uint i=0;
- for (i=0;i<n;i++)
- delay_1ms();
- }
- void write_com(uint com)
- {
- //lcdrs = 0;
- P2OUT&= 0xfd; //P2.1 RS =0
- P1OUT = com;
- delay_nms(5);
- //lcden = 1;
- P2OUT|= 0x01;
- delay_nms(5);
- P2OUT&= 0xfe;
- }
- void write_dat(uint dat)
- {
- //lcdrs = 1;
- P2OUT |= 0x02;
- P1OUT = dat;
- delay_nms(5);
- //lcden=1;
- P2OUT|= 0x01;
- delay_nms(5);
- // lcden=0;
- P2OUT&= 0xfe;
- }
- void disp_str(uchar addr,const uchar *pt,uchar num)
- {
- uchar i;
- write_com(addr);
- for(i=0;i<(num*2);i++)
- write_dat(*(pt++));
- }
- void init()
- {
- //PSB=1;//并口模式
- P2OUT |= BIT2;
- delay_nms(15);
- //EN=0;
- P2OUT&= 0xfe;
- delay_nms(5);
- write_com(0x30);
- delay_nms(1);
- write_com(0x08);//清屏
- delay_nms(1);
- write_com(0x0c);//开显示,关光标
- delay_nms(1);
- write_com(0x01);
- delay_nms(1);
- write_com(0x06);//第一行显示位置
- delay_nms(1);
- }
- void lcd12864_image(const uchar *p)
- {
- int x,y;
- write_com(0x34); //扩展指令集动作,绘图显示OFF
- for (y=0;y<32;y++) //送上半屏显示数据
- {
- write_com(0x80|y); //送显示Y坐标0x80-0x9f
- write_com(0x80); //送显示X坐标0x80
- for (x=0;x<16;x++)
- {
- write_dat(*p);
- p++;
- }
- }
- for (y=0;y<32;y++) //送下半屏显示数据
- {
- write_com(0x80|y); //送显示Y坐标0x80-0x9f
- write_com(0x88); //送显示X坐标0x88
- for (x=0;x<16;x++)
- {
- write_dat(*p);
- p++;
- }
- }
- write_com(0x36); //扩展指令集动作,绘图显示ON
- }
- void displayfirst()//显示第一个界面
- {
- write_com(0x01); //清除显示(清零DDRAM)
- disp_str(0x98,table,18);
- lcd12864_image(image);//送图像显示数据
- delay_nms(5000);
- }
- void displaysecond()//显示第二个界面
- {
- write_com(0x01); //清除显示(清零DDRAM)
- disp_str(0x80,table1,18);
- disp_str(0x98,table2,18);
- lcd12864_image(image1);//送图像显示数据
- delay_nms(5000);
- }
- void main(void)
- {
- WDTCTL = WDTPW + WDTHOLD; // Stop WDT
- P1DIR |= 0xff; // P1.2 output
- P2DIR |= 0xff;
- init();
- while(1)
- {
- if(BUTTON==0x00)
- {displayfirst();}
- else
- {displaysecond();}
- }
- }
复制代码
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
?
什么型号
一周热门 更多>