|
|
- void LCD_WriteOneByte(unsigned char date,unsigned char cmd) //寫一個(gè)字節(jié)(data,(1數(shù)據(jù)0指令))
- {
- //使用8位數(shù)據(jù)通信模式,8位數(shù)據(jù)用的是PB口,對應(yīng)12864的D0~D7(12864的數(shù)據(jù)I/O)
- RW=0; //RW=0;設(shè)置寫入模式(對應(yīng)12864的RW)
- if (cmd) RS=1;//高數(shù)據(jù) 低指令(對應(yīng)12864的RS)
- else RS=0;
- EN=1;//使能拉高(對應(yīng)12864的EN)
- PORTB = date;//給數(shù)據(jù)到I/O
- delay_us(10);//等電平穩(wěn)定
- EN=0;//使能拉低,數(shù)據(jù)送出完畢
- delay_us(100);//等12864接收完畢
- }
- void LCD_Init()
- {
- ///文字顯示模式初始化代碼
- LCD_WriteOneByte(0x30,0);delay_ms(40);
- LCD_WriteOneByte(0x30,0);delay_ms(40);//設(shè)置8位數(shù)據(jù)總線,執(zhí)行基本指令集
- LCD_WriteOneByte(0x0c,0);delay_ms(40);//開顯示,關(guān)光標(biāo),關(guān)光標(biāo)閃爍
- LCD_WriteOneByte(0x02,0);delay_ms(40);//游標(biāo)移動(dòng)到起始位置
- LCD_WriteOneByte(0x01,0);delay_ms(40);//清屏
- /**/ /*//繪圖模式
- LCD_WriteOneByte(0x30,0);_delay_ms(20);
- LCD_WriteOneByte(0x30,0);_delay_ms(20);//設(shè)置8位數(shù)據(jù)總線,執(zhí)行基本指令集
- LCD_WriteOneByte(0x01,0);_delay_ms(10);//清屏
- LCD_WriteOneByte(0x0c,0);_delay_ms(10);//開顯示,關(guān)光標(biāo),關(guān)光標(biāo)閃爍
- LCD_WriteOneByte(0x01,0);_delay_ms(10);//清屏
- LCD_WriteOneByte(0x36,0);_delay_ms(20);//開繪圖
- _delay_ms(10);
- */
- } /**/
- void main()
- {
- LCD_Init();
- delay_ms(5);
- P12=0;
- LCD_WriteOneByte(0x80,0);
- delay_ms(5);
- P11=0;
- LCD_WriteOneByte('A',1);
- delay_ms(3);
- P10=0;
- while(1);
- }
復(fù)制代碼 |
|