Command Adc_read in mikroc pro no found!!

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
tegnomicro
Posts: 3
Joined: 24 Apr 2009 14:37

Command Adc_read in mikroc pro no found!!

#1 Post by tegnomicro » 24 Apr 2009 14:45

:?
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

Nick101
Posts: 339
Joined: 06 Aug 2006 15:32
Location: Texas
Contact:

#2 Post by Nick101 » 28 Apr 2009 04:42

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.
Nick
[url]http://www.pic_examples.byethost3.com/[/url]

hazzz
Posts: 2
Joined: 06 Mar 2010 01:22

Re: Command Adc_read in mikroc pro no found!!

#3 Post by hazzz » 06 Mar 2010 01:36

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!!!

Nick101
Posts: 339
Joined: 06 Aug 2006 15:32
Location: Texas
Contact:

Re: Command Adc_read in mikroc pro no found!!

#4 Post by Nick101 » 06 Mar 2010 02:35

Hi,
16F877 has neither ANSEL nor ANSELH, please check its datasheet.
Nick
[url]http://www.pic_examples.byethost3.com/[/url]

hazzz
Posts: 2
Joined: 06 Mar 2010 01:22

Re: Command Adc_read in mikroc pro no found!!

#5 Post by hazzz » 06 Mar 2010 03:23

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.

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: Command Adc_read in mikroc pro no found!!

#6 Post by tihomir.losic » 08 Mar 2010 16:18

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
mikroElektronika [Support team]

Post Reply

Return to “mikroC PRO for PIC General”