Libstock
It is currently 25 Oct 2014 08:44

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: 24 Apr 2009 14:45 
Offline

Joined: 24 Apr 2009 14:37
Posts: 3
:?
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


Top
 Profile  
 
 Post subject:
PostPosted: 28 Apr 2009 04:42 
Offline

Joined: 06 Aug 2006 15:32
Posts: 339
Location: Texas
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
http://www.pic_examples.byethost3.com/


Top
 Profile  
 
PostPosted: 06 Mar 2010 01:36 
Offline

Joined: 06 Mar 2010 01:22
Posts: 2
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!!!


Top
 Profile  
 
PostPosted: 06 Mar 2010 02:35 
Offline

Joined: 06 Aug 2006 15:32
Posts: 339
Location: Texas
Hi,
16F877 has neither ANSEL nor ANSELH, please check its datasheet.

_________________
Nick
http://www.pic_examples.byethost3.com/


Top
 Profile  
 
PostPosted: 06 Mar 2010 03:23 
Offline

Joined: 06 Mar 2010 01:22
Posts: 2
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.


Top
 Profile  
 
PostPosted: 08 Mar 2010 16:18 
Offline
mikroElektronika team
User avatar

Joined: 02 Dec 2009 14:16
Posts: 2138
Location: Serbia
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:

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]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Bing [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group