写了一个1602的程序,和74hc595在一起的,液晶一直没有显示。不知道哪里有问题,求高手
void Write_595(unsigned char Data) { unsigned char j; GPIO_ResetBits(GPIOA , GPIO_Pin_5); GPIO_SetBits(GPIOA , GPIO_Pin_2); GPIO_ResetBits(GPIOB, GPIO_Pin_11); delay_nus(50); for (j=0;j<8;j++) { if(Data&0X80) GPIO_SetBits(GPIOA , GPIO_Pin_7); else GPIO_ResetBits(GPIOA , GPIO_Pin_7); Data=Data<<1; GPIO_SetBits(GPIOA , GPIO_Pin_5); delay_nus(50); GPIO_ResetBits(GPIOA , GPIO_Pin_5); delay_nus(50); } GPIO_ResetBits(GPIOA , GPIO_Pin_2); GPIO_ResetBits(GPIOA , GPIO_Pin_5); delay_nus(50); GPIO_SetBits(GPIOA , GPIO_Pin_2); GPIO_SetBits(GPIOA , GPIO_Pin_5); delay_nus(50); GPIO_ResetBits(GPIOA , GPIO_Pin_2); GPIO_ResetBits(GPIOA , GPIO_Pin_5); } void LCD_Write_Com(unsigned char LCD_Com)//LCD写命令 { Write_595(LCD_Com); GPIO_ResetBits(GPIOB, GPIO_Pin_11); GPIO_ResetBits(GPIOB , GPIO_Pin_12); GPIO_ResetBits(GPIOB, GPIO_Pin_10); delay_nms(5); GPIO_SetBits(GPIOB, GPIO_Pin_10); delay_nms(5); GPIO_ResetBits(GPIOB, GPIO_Pin_10); } void LCD_Write_Data(unsigned char LCD_Data)//LCD写数据 { Write_595(LCD_Data); GPIO_ResetBits(GPIOB, GPIO_Pin_11); GPIO_ResetBits(GPIOB , GPIO_Pin_10);
GPIO_SetBits(GPIOB , GPIO_Pin_12); delay_nms(5); GPIO_SetBits(GPIOB, GPIO_Pin_10); delay_nms(5); GPIO_ResetBits(GPIOB, GPIO_Pin_10); } void LCD_INIT()//LCD初始化 {
LCD_Write_Com(0x38); delay_nms(5); LCD_Write_Com(0x08); delay_nms(5); LCD_Write_Com(0x01); delay_nms(5); LCD_Write_Com(0x06); delay_nms(5); LCD_Write_Com(0x0c); delay_nms(5); }
void Set_xy_LCM(unsigned char x,unsigned char y) { unsigned char address; if(x==0) address=0x80+y; if(x==1) address=0xc0+y; LCD_Write_Com(address); } void Display_List_Char(unsigned char x,unsigned char y,unsigned char *s) { Set_xy_LCM(x,y); while(*s) { LCD_Write_Data(*s); delay_nms(5); s++; } } DS为PA7,NOE是PB11,STCP为PA1,SHCP为PA5,RS为PB12,E为PB10
|