Kunal2
Junior Member level 3

Hi all
I wrote a program for adc conversion in mikroC as follows:
//ADC conversion and outputting digital value on leds
void ADCInit(){ //configuring A/D module
ADCON1 = 0b00000111; //channels AN8-An12 are digital and AN0-AN7 are analog
//Vref+ = Vdd and Vref- = Vss
ADCON2 = ox8A; //Right justified, Tad=2xacquisition time
//conversion clock = 32Tosc
}
//function to read ADC channel
unsigned int ADCRead( unsigned char ch){
ADCON0 = 0x00;//configuring analog channel
ADCON = (ch<<2); //selecting analog channel
ADON = 1; //switch on adc module
GODONE=1;//Start conversion
while(GODONE); //wait for the conversion to finish
ADON=0; //switch off adc
return ADRES;
}
void main() {
ADCInit(); //initialises adc in main program
TRISB = 0xff;//putting port b as output
while(1){
//always true condition. Endless loop
unsigned int val; //adc value
val=ADCRead(0); //read from channel 0
PORTB = val; // outputting result of AD conversion
}
}
on building the project i am getting errors like 1.Undeclared identifier 'ox8A' in expression adc.c
2.Undeclared identifier 'ADCON' in expression adc.c
I tried writing the program with ANSEL and ANSELH first but i was getting the same errors regarding identifiers.
Is it because i need to include a special library??
Kindly help folks
REgards
I wrote a program for adc conversion in mikroC as follows:
//ADC conversion and outputting digital value on leds
void ADCInit(){ //configuring A/D module
ADCON1 = 0b00000111; //channels AN8-An12 are digital and AN0-AN7 are analog
//Vref+ = Vdd and Vref- = Vss
ADCON2 = ox8A; //Right justified, Tad=2xacquisition time
//conversion clock = 32Tosc
}
//function to read ADC channel
unsigned int ADCRead( unsigned char ch){
ADCON0 = 0x00;//configuring analog channel
ADCON = (ch<<2); //selecting analog channel
ADON = 1; //switch on adc module
GODONE=1;//Start conversion
while(GODONE); //wait for the conversion to finish
ADON=0; //switch off adc
return ADRES;
}
void main() {
ADCInit(); //initialises adc in main program
TRISB = 0xff;//putting port b as output
while(1){
//always true condition. Endless loop
unsigned int val; //adc value
val=ADCRead(0); //read from channel 0
PORTB = val; // outputting result of AD conversion
}
}
on building the project i am getting errors like 1.Undeclared identifier 'ox8A' in expression adc.c
2.Undeclared identifier 'ADCON' in expression adc.c
I tried writing the program with ANSEL and ANSELH first but i was getting the same errors regarding identifiers.
Is it because i need to include a special library??
Kindly help folks
REgards