haowhaow
Joined: 07 Feb 2011 Posts: 1 Location: MY
|
LCD display value no response?? |
Posted: Mon Feb 07, 2011 10:09 pm |
|
|
I'm newbie in programming. I'm using pic18f4520 and 16 x 2 lcd.
After simulation is ok, but in real device, my lcd is blank.
I don't know how to configure my code. Can anyone here help me to solve it ?
Here is my code:
Code: |
#include <18F4520.H>
#fuses HS,NOPROTECT,NOLVP,NOWDT
#device ADC=10 //10-bit conversion
#use delay(clock = 20000000)
#include "lcd.c"
void main()
{
float temp, lsb;
int8 msd, lsd;
lsb = 5000.0/1024.0; //lsb in mv
lcd_init(); //initialize lcd
while(1) //do forever
{
setup_adc(ADC_CLOCK_INTERNAL); //ADC clock source
setup_adc_ports(ALL_ANALOG); //ADC inputs
set_adc_channel(0); //select RA0
delay_ms(100);
temp = read_adc(); //get temperature
/*convert reading to temperature*/
temp = temp*lsb; //temp in mv
temp = temp/10.0; //temp in degree C
msd = temp; //msd digit
lsd = 10.0*(temp-msd); //lsd digit
printf(lcd_putc,"\fTemp.: %U.%U C", msd,lsd);
delay_ms(500);
}
} |
|
|