/***********************************************************************
工 程:ST7920驅(qū)動(dòng)的12864液晶的3線串行驅(qū)動(dòng)模式
引腳定義:RS(CS)=====> PD3 //PB0
RW(SID)====> PD4 //PB1
EN(SCLK)===> PD6// PB2
PSB為硬件控制,接高電平為8位或4位的并行模式,接低電平為串行模式
************************************************************************/
#include #include #define uchar unsigned char #define uint unsigned int #define nop() NOP() #define xtal 8 #define Set_CS() DDRD |= (1<<3);PORTD |= (1<<3) #define Set_SID() DDRD |= (1<<4);PORTD |= (1<<4) #define Set_SCLK() DDRD |= (1<<6);PORTD |= (1<<6) #define Clr_CS() DDRD |= (1<<3);PORTD &=~(1<<3) #define Clr_SID() DDRD |= (1<<4);PORTD &=~(1<<4) #define Clr_SCLK() DDRD |= (1<<6);PORTD &=~(1<<6) //==================================================================== //函數(shù)聲明 void Delay(uint ms); //延時(shí)子程序 void W_1byte(uchar RW, uchar RS, uchar W_data); void Write_8bits(uint W_bits); void LCD_Init(void); /******************************************************************** ********************************************************************/ //=================================================================== const uchar mynew1[]={"歡迎你來到我的家"}; const uchar mynew2[]={"Create by:LQG "}; const uchar mynew3[]={"海內(nèi)存知己"}; const uchar mynew4[]={"天涯若比鄰"}; /******************************************************************** ********************************************************************/ void main() { uchar i = 0; DDRD &= ~BIT(7); PORTD &= ~BIT(7); DDRC |=BIT(6); PORTC &= ~BIT(6); DDRC &= ~BIT(7); PORTC &= ~BIT(7); Clr_CS(); Clr_SID(); Clr_SCLK(); LCD_Init(); while(1) { nop(); nop(); W_1byte(0,0,0x80); //顯示的地址0x80 nop(); for(i=0;mynew1[ i]!='