Hi, I'm having some problems on interfacing ADC with LCD display. The main purpose of using ADC is because I need to read the voltage of the batteries and transfer it, and display to LCD. I'm using MCC18 compiler. Please guide or help me!
Code:include <p18f4520.h> #include <delays.h> #include <stdlib.h> void Init_LCD(void); //Initialise the LCD void W_ctr_8bit(char); //8-bit Control word for LCD void W_data_8bit(char); //8-bit Text Data for LCD ADCON0=0b00000001; ADCON0bits.GO = 1; // Start ADC Delay10TCYx(5); //give channel time to initiliase while(ADCON0bits.DONE); // Wait for conversion to finish. counts=ADRESH*255 +ADRESL; //for 3.62 volts, expect a count of 741 millivolts = (counts * 1.367)/100; //gives a result of 3630.9 Init_LCD(); W_ctr_8bit(0x80); for(i=0;i<8;i++) W_data_8bit(MESS3[i]); W_ctr_8bit(0x8C); W_data_8bit('V'); itoa(millivolts,Distance1); //(int value, char * str, int base); W_ctr_8bit(0x89); while(Distance1[i]) { W_data_8bit(Distance1[i]); i++; }