这是我的LCD.H文件
#ifndef _LCD1602_H_
#define _LCD1602_H_
#include "stm32f10x.h"
#include "sys.h"
#define DATAOUT(x) GPIO_Write(GPIOF,x);//Êä³ö
#define lcd_RS PBout(4)
#define lcd_RW PBout(5)
#define lcd_EN PBout(6)
void write_cmd(unsigned char cmd);
void write_data(unsigned char );
void lcd_char_write(unsigned char x,unsigned char y,unsigned char data);
void lcd_clear(void);
void lcd_init(void);
#endif
下面是c文件
#include "LCD1602.h"
#include "delay.h"
void write_cmd(unsigned char cmd)
{
delay_ms(5);
lcd_RS=0;
lcd_RW=0;
lcd_EN=1;
DATAOUT(cmd);
delay_us(100);
lcd_EN=0;
}
void write_data(unsigned char data )
{
lcd_RS=1;
lcd_RW=0;
lcd_EN=1;
DATAOUT(data);
delay_us(100);
lcd_EN=0;
}
void lcd_char_write(unsigned char x,unsigned char y,unsigned char data)
{
if (y == 0)
{
write_cmd(0x80 + x);
}
else
{
write_cmd(0xC0 + x);
}
write_data(data);
}
void lcd_clear(void)
{
write_cmd(0x01) ;
delay_ms(5);
}
void lcd_init(void)
{
write_cmd(0x38);
delay_ms(5);
write_cmd(0x38);
delay_ms(5);
write_cmd(0x38);
delay_ms(5);
write_cmd(0x38);
write_cmd(0x08);
write_cmd(0x01);
write_cmd(0x06);
delay_ms(5);
write_cmd(0x0C);
}
主函数main如下
#include "stm32f10x.h"
#include "sys.h"
#include "LCD1602.H"
#include "delay.h"
int main()
{
lcd_init();
lcd_clear();
while(1)
{
lcd_char_write(1,0,30);
}
}
代码没有错,编译通过了,可是在LCD1602上面没有显示,求大佬们解我之迷惑
|