PDA

View Full Version : Compiler error on CMCON = 7



rjones2102
- 15th September 2007, 15:57
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

Acetronics2
- 15th September 2007, 16:11
Which processor, please ???

Alain

rjones2102
- 16th September 2007, 00:24
Sorry, it's a 16f886.

Thanks for your reply!

Archangel
- 16th September 2007, 05:36
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

rjones2102
- 16th September 2007, 06:01
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:



@ __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

Archangel
- 16th September 2007, 06:19
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/showthread.php?t=543&highlight=config+fuses<p>
Try this using PM assembler : @ DEVICE pic16F886, INTOSCIO,WDT_ON,MCLR_OFF,LVP_OFF

jmbanales21485
- 16th September 2007, 06:26
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.

rjones2102
- 16th September 2007, 11:14
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