+ Reply to Thread
Results 1 to 7 of 7

Thread: pic18f2580 comparator error in adc

  1. #1
    einton Newbie
    Join Date
    Jan 2009
    Location
    pakistan
    Posts
    45

    Default pic18f2580 comparator error in adc

    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 by einton; 10th August 2009 at 01:38 PM.


  2. #2
    be80be Excellent be80be Excellent be80be Excellent be80be Excellent be80be Excellent be80be Excellent
    Join Date
    Aug 2008
    Location
    morristown,tn
    Posts
    2,000

    Default

    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 by be80be; 10th August 2009 at 04:04 PM.
    Burt

  3. #3
    einton Newbie
    Join Date
    Jan 2009
    Location
    pakistan
    Posts
    45

    Default

    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.

  4. #4
    be80be Excellent be80be Excellent be80be Excellent be80be Excellent be80be Excellent be80be Excellent
    Join Date
    Aug 2008
    Location
    morristown,tn
    Posts
    2,000

    Default

    Quote Originally Posted by einton View Post
    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 by be80be; 10th August 2009 at 04:22 PM.
    Burt

  5. #5
    einton Newbie
    Join Date
    Jan 2009
    Location
    pakistan
    Posts
    45

    Default

    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.

  6. #6
    gaspode42 Good gaspode42 Good gaspode42 Good gaspode42 Good
    Join Date
    Feb 2009
    Location
    UK
    Posts
    201

    Default

    Einton

    You can simulate your MikoC apps in MikroC directly - you can watch variables etc - just run in debug mode
    "A lie gets halfway around the world before the truth has a chance to get its pants on" - Sir Winston Churchill (1874 - 1965)

  7. #7
    be80be Excellent be80be Excellent be80be Excellent be80be Excellent be80be Excellent be80be Excellent
    Join Date
    Aug 2008
    Location
    morristown,tn
    Posts
    2,000

    Default

    Read page 134 http://ww1.microchip.com/downloads/e...Doc/39637c.pdf
    You have to set ADCON1 to use all portb but that should not have made 5 or 7 not work
    Note: On a Power-on Reset, RB4, RB1 and RB0
    are configured as analog inputs by default
    and read as ‘0’; RB7:RB5 and RB3:RB2
    are configured as digital inputs.
    Burt

+ Reply to Thread

Similar Threads

  1. pic18f2580 portb<5:7>
    By einton in forum Micro Controllers
    Replies: 9
    Latest: 16th August 2009, 01:12 PM
  2. CAN protocol using mikroc pro by pic18f2580
    By einton in forum Micro Controllers
    Replies: 3
    Latest: 29th July 2009, 01:46 PM
  3. Comparator help
    By samarsingla in forum General Electronics Chat
    Replies: 7
    Latest: 12th July 2006, 09:28 PM
  4. the right comparator
    By xmat in forum Electronic Projects Design/Ideas/Reviews
    Replies: 6
    Latest: 25th April 2005, 05:03 PM
  5. Need Assistance , Another Verify Error At OOOOh! Error
    By MindShaper in forum Micro Controllers
    Replies: 0
    Latest: 4th September 2003, 02:05 PM

Tags for this Thread