Need Help doing C Language Programming for PIC18F4520 MPLAB lCD 3

Status
Not open for further replies.

InNeedOfHelp

Full Member level 3
Joined
Dec 5, 2012
Messages
169
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
2,205
Hi guys, my final year project require me to program a tiny thermal sensor on the board . But i have totally no idea how to begin with. i am not planning to ask for the whole code, i only need a small tutorial on how to display word on the LCD and if there is any ways to light up the LEDs.

 

what compiler are you using?

you can find more threads on this forum about how to displaying words in lcd.
 

you can find this link as useful.
**broken link removed**

Can you post the schematic?
 

thanks for the link

- - - Updated - - -



this is the PIC18F4520 im using.



This is the thermal sensor for my project.



and this is the lcd im using..
 

Im using PIC18F4520 to display other strings like "ding dong" . But i dunno how to start so. Thanks for the link anyway
 

i don't have the c18 compiler, so i didn't compile the program. try to compile and let me know if there are any errors. And double-check the hardware connections with the pins used in the software.
HTML:
//turns watch dog timer off, turn low voltage programming off
#pragma config WDT=OFF, LVP=OFF, DEBUG=ON, MCLRE = OFF
#pragma config OSC=HS
#include <p18f4520.h>
#include <delays.h>

#define _XTAL_FREQ 10000000     // 10 MHz  ---- check ur hardware and change according to it
//===============//
connect uC pin A2 to LCD RS, pin A1 to E, LCD R/W to ground --- change according to your hardware
#define  RS  LATAbits.LATA2     //Define LCD pinout RS
#define  E	 LATAbits.LATA1    //Define LCD pinout E
#define lcdport LATB            // LCD data pins connected to uC port B ---- 

void lcd_init();
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);

void main()
{
lcd_init();
while(1)
{
lcd_cmd(0x80);
lcd_data("ding dong");
}
}

void lcd_init()
{
lcd_cmd(0x30);      // Configure the LCD in 8-bit mode, 1 line and 5x7 font
lcd_cmd(0x0c);      // display on and cursor off
lcd_cmd(0x01);      // clear display screen
lcd_cmd(0x06);      // increment cursor
lcd_cmd(0x80);      // set cursor to 1st line
}

void lcd_cmd(unsigned char c)
{
lcdport = c;
RS = 0;
EN = 1;
delay_ms(15);
EN = 0;
}

void lcd_data(unsigned char z)
{
lcdport = z;
RS = 1;
EN = 1;
delay_ms(15);
EN = 0;
}

i can help you as much if you are using ccs c compiler.

Best wishes
 
Last edited:

CCS C Compiler ? what is that ? got one error after building it,


here is the errors
 

It is another compiler.

and do the changes as mentioned above by jayanth.

change this
HTML:
#define  E	 LATAbits.LATA1
to
HTML:
#define EN LATAbits.LATA1
compile now.
 

Im using MPLAB IDE to compile my program. i tried changing the above mentioned by jayanth. but it is still the same..
 

Hi i found this code from you link




i build successfully but the LCD didnt appear anything..
 

compare the code with your hardware.
1. what crystal have you connected in your hardware. frequency mentioned in software is 20Mhz. change the value according to your hardware. for eg. in your hardware if you have connected 12Mhz crystal, change in software as 12000000
2. In software, enable pins connected to pin 6 of port D. Change according to the hardware. for eg,in your hardware, if you have connected enable pin of LCD to uC pin 1 of port A ,
#define E LATAbits.LATA1
3. similar to point 2, change according to RS pin.
4. to which port you have connected your data pins to uC. if you have connected to portB change as , #define LCDdata LATB
5. check the connection in R/W pin of lcd. It should be connected to ground. If it is connected to uC pin. change the #define like mentioned in point 2.

Now compile it will work
 

32.768kHz , do i write 32768 or just write 32000.
i have change all the LCDs Ports and Pins
 

are you using external crstal?

just write as #define _XTAL_FREQ 32768
 

Yup i wrote that. but still can't work , nothing appear on LCD
 

can u post the code please. what are the changes have you did so that i can correct..
 

here is the code

Thank you
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…