Closed eagl1 closed 2 years ago
Hi @eagl1 ,
Your code is for 8-bit mode and you are setting the display to 4-bit mode.
void lcd_init(void){
__delay_ms(25);
ADCON1 = 0b00001111;
lcd_cmd(0x33); <-- normally the configuration must be done with sending three times the same value.
lcd_cmd(0x32);
lcd_cmd(0x28); <--- this line must be lcd_cmd(0x38) to work (or 0x33, 0x32)
lcd_cmd(0x0f);
lcd_cmd(0x01);
lcd_cmd(0x80);
}
``
Yes, also I found the source code here: https://github.com/lcgamboa/picsimlab_examples/tree/master/docs/board_McLab2/PIC16F877A/test_b3/src/test_b3.X
And copied it, and it's working :)
Thanks.
Hi,
I'm working to get the LCD1602 embedded in PICGenios board using PIC16F877A.
I've tried this code but it's not working.
` void pic_init(void){ TRISA = 0b00000000; TRISB = 0b00000000; TRISD = 0b00000000; TRISC = 0b00000000; TRISE = 0b00000000; }
void lcd_init(void){
__delay_ms(25); ADCON1 = 0b00001111; lcd_cmd(0x33);lcd_cmd(0x32);lcd_cmd(0x28); lcd_cmd(0x0f);lcd_cmd(0x01);lcd_cmd(0x80);
}
void lcd_cmd(char cmd){ PORTD = cmd; PORTE &= ~(1 << LCD_RS);
PORTE |= (1 << LCD_EN); delay_us(10); PORTE &= ~(1 << LCD_EN); delay_ms(5); }
void lcd_data(char dat){ PORTD = dat; PORTE |= (1 << LCD_RS); PORTE |= (1 << LCD_EN); delay_us(10); PORTE &= ~(1 << LCD_EN); delay_ms(5); }
void move_cursor (unsigned char row, unsigned char col){ if(row == 1){ lcd_cmd(FIRST_ROW + col); }
}
void lcd_string_arr(char str[]){
char i; for(i=0; str[i] != 0; i++){ lcd_data(str[i]); } }
void lcd_string_ptr(const char *msg){ unsigned char cnt=1;
}
void lcd_string_xy(unsigned char row, unsigned char col, char str[]){ if(row == 1){ lcd_cmd(FIRST_ROW + col); } if(row == 2){ lcd_cmd(SECOND_ROW + col); } lcd_string_arr(str); }`
In this main I'm using this test code:
`void main(void) {
}`