im newbie in programming.....
im using hi tech compiler, pic18f4520 and 16 x 2 lcd.....
after simulation is ok....but in real device, my lcd is blank .....
i dunno how to configure my code.....can anyone here helps me to solve it??
here is my code
#include <htc.h>
#include <math.h>
#include "lcd.h"
__CONFIG(1, FCMDIS & IESODIS & HS);
__CONFIG(2, BORDIS & BORV45 & PWRTEN & WDTDIS & WDTPS1);
__CONFIG(3, CCP2RB3 & LPT1DIS & MCLRDIS & 0xFDFF);
__CONFIG(4, DEBUGDIS & XINSTDIS & LVPDIS & STVRDIS);
//Simple Delay Routine
void Wait(unsigned int delay)
{
for(;delay;delay--)
__delay_us(100);
}
void ADCInit(void){
ADCON0=0b00000001; // select Fosc/2
ADCON1=0b00001110; // select left justify result. A/D port configuration 0
ADCON2=0b00001010;
}
unsigned char read_adc(unsigned char ){
ADON = 1; // initiate conversion on the selected channel
GODONE=1 ;//Start conversion
while(GODONE= 1)continue;
return(ADRESH); // return 8 MSB of the result
}
void main()
{
//Let the LCD Module start up
Wait(100);
//Initialize the LCD Module
LCDInit(LS_BLINK);
//Initialize the ADC Module
ADCInit();
//Clear the Module
LCDClear();
//Write a string at current cursor pos
LCDWriteString("Temperature:");
LCDWriteStringXY(5,1,"Degree C");
while(1)
{
unsigned int val;
unsigned int t; //Temperature
val=read_adc(); //Read Channel 0
t=round(((val*5000)/1024)/10);
LCDWriteIntXY(0,1,t,3);//Prit IT!
Wait(1000);
}
}
im using hi tech compiler, pic18f4520 and 16 x 2 lcd.....
after simulation is ok....but in real device, my lcd is blank .....
i dunno how to configure my code.....can anyone here helps me to solve it??
here is my code
#include <htc.h>
#include <math.h>
#include "lcd.h"
__CONFIG(1, FCMDIS & IESODIS & HS);
__CONFIG(2, BORDIS & BORV45 & PWRTEN & WDTDIS & WDTPS1);
__CONFIG(3, CCP2RB3 & LPT1DIS & MCLRDIS & 0xFDFF);
__CONFIG(4, DEBUGDIS & XINSTDIS & LVPDIS & STVRDIS);
//Simple Delay Routine
void Wait(unsigned int delay)
{
for(;delay;delay--)
__delay_us(100);
}
void ADCInit(void){
ADCON0=0b00000001; // select Fosc/2
ADCON1=0b00001110; // select left justify result. A/D port configuration 0
ADCON2=0b00001010;
}
unsigned char read_adc(unsigned char ){
ADON = 1; // initiate conversion on the selected channel
GODONE=1 ;//Start conversion
while(GODONE= 1)continue;
return(ADRESH); // return 8 MSB of the result
}
void main()
{
//Let the LCD Module start up
Wait(100);
//Initialize the LCD Module
LCDInit(LS_BLINK);
//Initialize the ADC Module
ADCInit();
//Clear the Module
LCDClear();
//Write a string at current cursor pos
LCDWriteString("Temperature:");
LCDWriteStringXY(5,1,"Degree C");
while(1)
{
unsigned int val;
unsigned int t; //Temperature
val=read_adc(); //Read Channel 0
t=round(((val*5000)/1024)/10);
LCDWriteIntXY(0,1,t,3);//Prit IT!
Wait(1000);
}
}