Milead
Newbie level 5
Im trying to connect a HD44780 lcd to a pic16f874a.
I read many posts in different forums, but could not solve my problem.
I have the pic connected to the lcd just as it is in the example of Mikroc.
My code is also very similar.
I dont know if the problem is the hardware or the software.
I appreciate if you help me.
i can see only black squares on the first row.
i took care of the contrast,
LVP and in circuit debugger are off in config bits.
Here is my code:
char *text = "Hello World"; //Constant holding text to be displayed
// Lcd pinout settings
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;
// Pin direction
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
void main() * * * * //Main program
*{
* TRISB = 0; * * * * * * * *// PORTB is output
* * * Delay_ms(1000);
* Lcd_Init(); * * * * // Initialize LCD connected to PORTB
* * * * * * *Delay_ms(1000);
* Lcd_Cmd(_Lcd_CLEAR); * * * // Clear data on lcd
* Lcd_Cmd(_Lcd_CURSOR_OFF); *// Turn cursor off
* while(1) *//while loop, not necessarily needed
* * {
* * *Lcd_Out(1, 1, text); * // Print text to LCD, 2nd row, 1st column
* * }
}
I read many posts in different forums, but could not solve my problem.
I have the pic connected to the lcd just as it is in the example of Mikroc.
My code is also very similar.
I dont know if the problem is the hardware or the software.
I appreciate if you help me.
i can see only black squares on the first row.
i took care of the contrast,
LVP and in circuit debugger are off in config bits.
Here is my code:
char *text = "Hello World"; //Constant holding text to be displayed
// Lcd pinout settings
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;
// Pin direction
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
void main() * * * * //Main program
*{
* TRISB = 0; * * * * * * * *// PORTB is output
* * * Delay_ms(1000);
* Lcd_Init(); * * * * // Initialize LCD connected to PORTB
* * * * * * *Delay_ms(1000);
* Lcd_Cmd(_Lcd_CLEAR); * * * // Clear data on lcd
* Lcd_Cmd(_Lcd_CURSOR_OFF); *// Turn cursor off
* while(1) *//while loop, not necessarily needed
* * {
* * *Lcd_Out(1, 1, text); * // Print text to LCD, 2nd row, 1st column
* * }
}