Compiler error on CMCON = 7


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2007
    Posts
    26

    Default Compiler error on CMCON = 7

    I see examples of using this to turn off analogue comparator but it gives an undefined symbol error for me.

    CMCON = 7

    I also included the following lines I found elsewhere and got error 'opcode expected instead of '___config'

    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _LVP_OFF & _BODEN_ON
    ' Internal Oscillator
    ' Enable watch dog timer
    ' Enable power up timer
    ' Disable MCLR pin
    ' Disable low voltage programming
    ' Enable brown out detect

    Thanks all

    Rich

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

    Default Details !!!!!

    Which processor, please ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Sorry, it's a 16f886.

    Thanks for your reply!

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Try this:
    @ __CONFIG _CONFIG1, _INTOSCIO & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _LVP_OFF & _BOR_ON
    CM1CON0 = 0
    CM2CON0 = 0

    You will get overwriting previous address error unless you comment out the config statement in your 16F886.inc file in the root of your PBP directory, because there is already a config statement there and PBP blends or includes this file into the compile automaticly.
    JS
    Last edited by Archangel; - 16th September 2007 at 06:00.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Thanks Joe but it still didn't work with your lines of code. The error I get is:

    Error blink.asm 66:[235] opcode expected instead of '_config'

    The CMCON line gives a compiler error as well. Is this command not supported on the PIC16F886 perhaps?

    The total code is:

    Code:
    @ __CONFIG _CONFIG1, _INTOSCIO & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _LVP_OFF & _BOR_ON
    CM1CON0 = 0
    CM2CON0 = 0
    
    TRISB = %00000000
    ANSEL=0
    ANSELH=0
    define osc 4
    'CMCON = 7
    led var PORTB.0
    led1 var PORTB.1
    led2 var PORTB.2
    led3 var PORTB.3
    led4 var PORTB.4
    led5 var PORTB.5
    led6 var PORTB.6
    led7 var PORTB.7
    loop:   High led         ' Turn on LED connected to PORTB.0
            High led1         ' Turn on LED connected to PORTB.0
            High led2         ' Turn on LED connected to PORTB.0
            High led3         ' Turn on LED connected to PORTB.0
            High led4         ' Turn on LED connected to PORTB.0
            High led5         ' Turn on LED connected to PORTB.0
            High led6         ' Turn on LED connected to PORTB.0
            High led7         ' Turn on LED connected to PORTB.0
            Pause 500       ' Delay for .5 seconds
    
            Low led           ' Turn off LED connected to PORTB.0
            low led1
            low led2
            low led3
            low led4
            low led5
            low led6
            low led7
            Pause 500       ' Delay for .5 seconds
    
            Goto loop       ' Go back to loop and blink LED forever
            End

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    I can answer that too ! You are using PM as the assembler and those configs are written for use of MPASM. Download from microchips website, then go into microcode studios Tabs across the top, click view, go down to compile and program options, open the tab that says, assembler, and check the little white box that says use MPASM. Then you will be using the assembler almost all of the Top Guns in here use, so their code snippets and programs will work for you.<p>
    Read this thread too: http://www.picbasic.co.uk/forum/show...t=config+fuses<p>
    Try this using PM assembler : @ DEVICE pic16F886, INTOSCIO,WDT_ON,MCLR_OFF,LVP_OFF
    Last edited by Archangel; - 16th September 2007 at 06:34.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Hi rjones2102,

    first:
    comparator register is CM1CON0. if you look at the datasheet pg. 80 it will tell you how to arrange the bits so that you can turn it off. in this case CM1CON0.7=0 will turn off Comparator 1 because bit 7 in CM1CON0 Register is enable/disable register. same with comparator 2: CM2CON0.7 = 0.

    second:
    I used to get erros in PBP when i adjusted the fuses (config register) in PBP. the way i got around this is like joe said, instead of declaring: @ __CONFIG _CONFIG1, _INTOSCIO & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _LVP_OFF & _BOR_ON

    go to the .inc file and edit your fuses there. i believe it would be in c:\PBP folder

    last:
    i don't know if it matters but the way i usually set up my registers, is i first begin with osc, then with other stuff.

  8. #8
    Join Date
    Sep 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Thanks guys,

    I will take all of that on board. Your help has undoubtedly saved me hours but certainly hasn't detracted from my learning!

    Thanks
    Rich

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Thermo 7 segments - little problem
    By fratello in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 27th July 2013, 07:31
  3. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  4. Working with indivividual bytes of an array
    By J_norrie in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd January 2007, 19:16
  5. code conversion
    By saturnX in forum mel PIC BASIC
    Replies: 19
    Last Post: - 3rd October 2005, 17:17

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts