Code của em không cho khi chạy thì không xuất chữ ra màn hình ?? ai có thể giúp em ko?
#include"LCD4.h"
#include"Delay.h"
#include"main.h"
#include"Port.h"
/*----------------------------------------------
_LCD_CLEAR: 0x01
_LCD_RETURN_HOME: 0x02
_LCD_ENTRY_MODE: 0x06
_LCD_4BIT_2LINE_FONT_5x8: 0x28
_LCD_TURN_ON: 0x0C
-*--------------------------------------------*/
void delay_us(unsigned char n){
while(n--);
}
void lcdWriteHighNibble(unsigned char dat){
LCD_D7 = dat & 0x80;
LCD_D6 = dat & 0x40;
LCD_D5 = dat & 0x20;
LCD_D4 = dat & 0x10;
}
void lcdWriteLowNibble(unsigned char dat){
LCD_D7 = dat & 0x08;
LCD_D6 = dat & 0x04;
LCD_D5 = dat & 0x02;
LCD_D4 = dat & 0x01;
}
void lcdCmd(unsigned char cmd){
LCD_RS = 0;
lcdWriteHighNibble(cmd);
LCD_RS = 1;
LCD_RS = 0;
lcdWriteLowNibble(cmd);
LCD_RS = 1;
LCD_RS = 0;
if(cmd <= 0x02)
delay_ms(2);
else
delay_us(37);
}
void initLCD(){
LCD_RS = 0;
delay_ms(20);
lcdWriteLowNibble(0x03);
LCD_EN = 1;
LCD_EN = 0;
delay_ms(5);
lcdWriteLowNibble(0x03);
LCD_EN = 1;
LCD_EN = 0;
delay_us(100);
lcdWriteLowNibble(0x03);
LCD_EN = 1;
LCD_EN = 0;
delay_ms(1);
lcdWriteLowNibble(0x02);// khoi tao dung 4 bit
LCD_EN = 1;
LCD_EN = 0;
delay_ms(1);
//edit lcd
lcdCmd(_LCD_4BIT_2LINE_FONT_5x7);
lcdCmd(_LCD_TURN_ON);
lcdCmd(_LCD_CLEAR);
lcdCmd(_LCD_ENTRY_MODE);
}
void showChrCP(unsigned char dat){
LCD_RS = 1;
lcdWriteHighNibble(dat);
LCD_EN = 1;
LCD_EN = 0;
lcdWriteLowNibble(dat);
LCD_EN = 1;
LCD_EN = 0;
delay_us(37 + 4);
}
hàm main
void main(void){
initLCD();
showChrCP('a');
}