Page 1 of 1

Command Adc_read in mikroc pro no found!!

Posted: 24 Apr 2009 14:45
by tegnomicro
:?
Example in help for mikroc pro no compiled:
unsigned int temp_res;

void main() {
ANSEL = 0x04; // Configure AN2 pin as analog
TRISA = 0xFF; // PORTA is input
ANSELH = 0; // Configure other AN pins as digital I/O
TRISC = 0x3F; // Pins RC7, RC6 are outputs
TRISB = 0; // PORTB is output

do {
temp_res = ADC_Read(2); // Get 10-bit results of AD conversion
PORTB = temp_res; // Send lower 8 bits to PORTB
PORTC = temp_res >> 2; // Send 2 most significant bits to RC7, RC6
} while(1);
}

errors:
undeclared identifier 'ANSEL' in expression
undeclared identifier 'ANSELH' in expression
undeclared identifier 'ADC_Read' in expression

please is happening in this code?

however it works well in mikroc 8.2
is a failure mikro c pro ¿or is happening?
thanks

Posted: 28 Apr 2009 04:42
by Nick101
Hi,
Be sure you select the right device (MCU) on the Project Settings window and be sure you check ADC on the Library Manager window.

Re: Command Adc_read in mikroc pro no found!!

Posted: 06 Mar 2010 01:36
by hazzz
unsigned int temp_res;

void main() {
ANSEL = 0x04;
TRISA = 0xFF;
ANSELH = 0;
TRISC = 0x3F;
TRISB = 0;

do {
temp_res = ADC_Read(2);
PORTB = temp_res;
PORTC = temp_res >> 2;
}while(1);
}
--this is an example in mikroC Pro manual...when compiling, i got this error message
"undeclared identifier "ANSEL" in expression"
"undeclared identifier "ANSELH" in expression"

i am using mikroC Pro for PIC ver 3.2 and PIC 16F877 for my MCU.
please help!!!

Re: Command Adc_read in mikroc pro no found!!

Posted: 06 Mar 2010 02:35
by Nick101
Hi,
16F877 has neither ANSEL nor ANSELH, please check its datasheet.

Re: Command Adc_read in mikroc pro no found!!

Posted: 06 Mar 2010 03:23
by hazzz
Hi Sir Nick,
how will i edit my code to make it work on 16F877?i wanted to learn to make a project in PIC16F877 but i cannot compile this sample code on the manual...i will really appreciate your help.thank you so much.

Re: Command Adc_read in mikroc pro no found!!

Posted: 08 Mar 2010 16:18
by tihomir.losic
hazzz wrote:how will i edit my code to make it work on 16F877?i wanted to learn to make a project in PIC16F877 but i cannot compile this sample code on the manual...i will really appreciate your help.thank you so much.
Hello,

please, try this code:

Code: Select all

unsigned int temp_res;

void main() {
  TRISA = 0xFF;
  TRISB = 0;
  TRISC = 0x3F;

  do{
    temp_res = ADC_Read(2);
    PORTB = temp_res;
    PORTC = temp_res >> 2;
  }while(1);
}
Best regards,

Losic Tihomir