Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

pic18f2580 comparator error in adc

Status
Not open for further replies.

einton

New Member
Hi guys , i m working on adc using pic18f2580, i have gone through adc using pic18f452 earlier using mikroc pro, but this time there issome problems , guys u know 18f2580 contain comparators but when i m turning it off it is giving identifier error for CMCON.
u guys please check this program and verify what wrong with it and why it is giving error also tell if any thing missing in program




#include <built_in.h>
unsigned int adc_rd;

void main() {

CMCON = 0x07; // turn off comparators//IT IS GIVING IDENTIFIER ERROR
ADCON1 |= 0x00; // Set AN2 channel pin as analog
TRISA = 0xFF; // input

TRISC = 0x00; // Set PORTC as output
TRISB = 0x00; // Set PORTD as output

while (1) {
adc_rd = ADC_Read(0); // get ADC value from channel 0
PORTC = adc_rd; // display adc_rd[7..0]
PORTB = Hi(adc_rd); // display adc_rd[9..8]
}
}
PLEASE TELL WHAT I DO, ALSO VERIFY PROGRAM , TELL ME ANY THING MISSING SO , HOW CAN I TURN OFF COMPARATORS , WHAT WILL BE THE RIGHT WAY.
 
Last edited:

be80be

Well-Known Member
I no why it's not working but It should. The datasheet tells you to turn it off like your doing but there is no CMCON in the 18f2580.inc.
Maybe someone has used this chip and tell how to fix it.
There is a CIOCON but no CMCON
if you read the datasheet on page 263 at table 20-1 and i quote CMCON(3)
3 These registers are unimplemented on PIC18F2X80 devices.
 
Last edited:

einton

New Member
thanx so un implemented means not available so u think code is perfect and if i just remove CMCON will that way code should work.
 

be80be

Well-Known Member
thanx so un implemented means not available so u think code is perfect and if i just remove CMCON will that way code should work.
Just remove CMCON
I would say that would hook you up It should fix it
 
Last edited:

einton

New Member
thanx be80be it works dear
dear i involved in another problem mt portb<5:7> are not working please tell me what should i do, is their any simulator available feom which i can check my mikroc pro programs.
 

gaspode42

Member
Einton

You can simulate your MikoC apps in MikroC directly - you can watch variables etc - just run in debug mode
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top