Well I i had to work so that means I had to start sleeping more LOL . You are using newer Hi-tech then me so I upgraded mine.
I 'll post you some thing tonight as when
Your configure was wrong I think you new that but you use isis it uses it's own configure. They changed a lot with hi-hech v9-65. The code I posted just needs the function fixed that returns the adc value.
how is the code going??if my code change become as shown below....but my calculation was wrong...i cant get the reading display as the thermocouple temperature....
for example...
thermocouple show 100 C but the display cant show exact 100 C.....
how i going to calculate it??
#include <htc.h>
#include <math.h>
#include "lcd.h"
__CONFIG(1, FCMDIS & IESODIS & XT);
__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*4750)/1023)/10);
LCDWriteIntXY(0,1,t,3);//Prit IT!
Wait(1000);
}
}