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.

[PIC] LCD interafcing with pic 18f4520

Status
Not open for further replies.

RAJPUT VIDISHA

Member level 1
Joined
Jul 14, 2015
Messages
37
Helped
0
Reputation
0
Reaction score
1
Trophy points
6
Activity points
344
hello, i'm new to pic microcontrollers and i want to dispaly something on my LCD but this code is not working . plzz anybody can help

Code:
                      // LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections


void main()
{

     ADCON1 = 0x00;
     CMCON = 0X07;                    // Disable comparators

     TRISB = 0X00;               // PORTB as output
     PORTB = 0XFF;

 

Lcd_Init();                        // Initialize LCD
Lcd_Cmd(_LCD_CLEAR);               // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
       


Lcd_out(1,1,"APEX");                 // Write text in first row
  Delay_ms(1000);
Lcd_out(1,1,"techs");


   

}
 
Last edited by a moderator:

Hi,

What happens instead?
What did you do yet to find the error?

Klaus
 

Your lcd registers are already set as output their is no need of setting ADC and comparators since you are not using them just comment them and compile again ...

// ADCON1 = 0x00;
// CMCON = 0X07; // Disable comparators

TRISB = 0X00; // PORTB as output
// PORTB = 0XFF;
 

Thanks for replying....
kabeer02 i did as u said but still nothing is getting display on lcd..y so
 

hello

with PIC18 use LAT instead of PORT bit

Code:
  // LCD module connections
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;
 

Your lcd registers are already set as output their is no need of setting ADC and comparators since you are not using them just comment them and compile again ...

// ADCON1 = 0x00;
// CMCON = 0X07; // Disable comparators

TRISB = 0X00; // PORTB as output
// PORTB = 0XFF;
This advice is both right and wrong at the same time.
It is right in that you don't need to set the port bit ot digital mode if you are only using it as a digital output in that the digital output drive circuit (as mentioned above, driven by the LAT registers and NOT the PORT registers) will normally force the line to be the correct state.
On the other hand, if the pin is used for a digital input then it will always read as '0' while in analog mode.
The "best practice" is to set the analog/digital mode to the way it should be. (Also this stops the analog input circuits always begin driven by the digital signal. This should not be harmful but is just not necessary.)
For this device, you actually have a alternative way to do this by setting the PBADEN configuration bit, but we are not shown the configuration settings by the OP so we don't know if this is being done.
Susan
 

lcd interfacing with pic18f4520

HELLO... plz anyone can tell me how to scroll only second row of LCD...
 

Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top