/***********************************************************************
工 程:ST7920驱动的12864液晶的3线串行驱动模式
引脚定义: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) //==================================================================== //函数声明 void Delay(uint ms); //延时子程序 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[]={"海内存知己"}; 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]!='