| 
 
中级会员  
 
	积分244金钱244 注册时间2016-11-19在线时间31 小时 | 
 
3金钱 
| lcd头文件 
 #ifndef __LCD_H
 #define __LCD_H
 #include "sys.h"
 #define E  PCout(12)
 #define RS PCout(11)
 void lcd_Init(void);
 void write_com(u8 com);
 void write_date(u8 date);
 #endif
 
 
 lcd.c文件
 #include "lcd.h"
 #include "stm32f10x.h"
 #include "delay.h"
 void lcd_Init(void)
 {
 GPIO_InitTypeDef GPIO_InitStruct;
 
 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOC,ENABLE);
 
 GPIO_InitStruct.GPIO_Mode =GPIO_Mode_Out_PP;
 GPIO_InitStruct.GPIO_Pin =GPIO_Pin_All;                                  //数据传出接口(GPIOD口共有16个,只使用前8个口)
 GPIO_InitStruct.GPIO_Speed =GPIO_Speed_50MHz;
 GPIO_Init(GPIOD,&GPIO_InitStruct);
 
 GPIO_InitStruct.GPIO_Mode =GPIO_Mode_Out_PP;
 GPIO_InitStruct.GPIO_Pin =GPIO_Pin_11|GPIO_Pin_12;
 GPIO_Init(GPIOC,&GPIO_InitStruct);                                         //命令端和使能端
 
 }
 void write_com(u8 com)                                                       //写命令函数
 {
 RS=0;
 GPIO_Write(GPIOD,com);
 delay_ms(5);
 E=1;
 delay_us(1);
 E=0;
 }
 void write_date(u8 date)                            //写数据函数
 {
 RS=1;
 GPIO_Write(GPIOD,date);
 delay_ms(5);
 E=1;
 delay_us(5);
 }
 
 主函数:
 #include "stm32f10x.h"
 #include "lcd.h"
 int main(void)
 {
 u8 z='a';
 lcd_Init();
 
 write_com(0x38);
 write_com(0x0c);
 write_com(0x06);
 write_com(0x01);
 
 write_com(0x08);                              //在第一行显示
 write_date(z);                                  //显示字母A
 
 }
 接口连接好但是显示不出来,全白的。请问我这个程序有问题吗?新手   急急急
 
 
 | 
 |