I have LCD qc1602a v2. I am using library for communication with Lcds (with HD44780 compliant controllers) through the 4-bit interface. I can not write in second line. I tried to move cursor in second row but useless. I have tried to wire a LCD to PIC B ports but i get the same error. I am using a example. I am stuck.
// LCD module connections
sbit LCD_RS at RC4_bit;
sbit LCD_EN at RC5_bit;
sbit LCD_D4 at RC0_bit;
sbit LCD_D5 at RC1_bit;
sbit LCD_D6 at RC2_bit;
sbit LCD_D7 at RC3_bit;
sbit LCD_RS_Direction at TRISC4_bit;
sbit LCD_EN_Direction at TRISC5_bit;
sbit LCD_D4_Direction at TRISC0_bit;
sbit LCD_D5_Direction at TRISC1_bit;
sbit LCD_D6_Direction at TRISC2_bit;
sbit LCD_D7_Direction at TRISC3_bit;// End LCD module connectionsvoid main(){
ANSELC =0;// Configure AN pins as digital I/O
C1ON_bit =0;// Disable comparators
C2ON_bit =0;
delay_ms(500);
Lcd_Init();// Initialize LCD
Lcd_Cmd(_LCD_CLEAR);// Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);// Cursor off
Lcd_Out(1,1,"First row");// Write text in first row
Delay_ms(2000);
Lcd_Out(2,1,"Second row");// Write text in second row
Delay_ms(2000);while(1){}}
On a PIC18 always use the LATx bites (not the PORTx bites) to avoid R-M-W problems:
Code C - [expand]
1
2
3
4
5
6
7
8
9
10
// LCD module connections
sbit LCD_RS at LATC4_bit;
sbit LCD_EN at LATC5_bit;
sbit LCD_D4 at LATC0_bit;
sbit LCD_D5 at LATC1_bit;
sbit LCD_D6 at LATC2_bit;
sbit LCD_D7 at LATC3_bit;
sbit LCD_RS_Direction at TRISC4_bit;
....
If this is not enough, study the datasheet of your LCD, maybe it uses different line-addressing.
hi alesk, is your lcd working now? im using a 4-bit lcd too, but with pic18f46k22. im still having some troubles on lcd. can you please post your lcd_init(), lcd_cmd() and lcd_out() functions? it would be a great help.
hi blackpearl87,
i think he is using microC and lcd_init(), lcd_cmd() and lcd_out() etc. are its library functions.
Have a look at this link it may help you
**broken link removed**
Looking at your code, why do you think that the second line of text should be put out on the second line? A line is 40 characters long with only the first 16 (in this case) being visible. To show text on the second line you have to
(A) set the LCD controller to be a two line display, (you may have to adjust the contrast after doing this)