Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Problems with LCD and PIC18F25K22 second row(line) on display

Status
Not open for further replies.

AlesK

Newbie level 5
Joined
Jul 17, 2014
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
71
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.

8640203900_1405584867.jpg


MY CODE:

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// 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 connections
 
 
void 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)
  {
  }
 }

 
Last edited by a moderator:

Can you also post Lcb_init(), Lcd_Cmd() and Lcd_Out() functions?
 

I have LCD qc1602a v2.... I can not write in second line

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.
 
  • Like
Reactions: AlesK

    AlesK

    Points: 2
    Helpful Answer Positive Rating
LATx bites works fine! tnx
 

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**
 

thanks anjalimidhuna :) i will take a look :D

hi zuisti, im using mplad ide v8.92. no idea about mikroc.
 
Last edited by a moderator:

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)

(B) Set the address to 40
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top