Pic16f88 config problem

Thread Starter

Dodgydave

Joined Jun 22, 2012
11,303
I am trying to set the config register up by putting the following line in>>

__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO


but when i build it i get error message "illegal character ," presumably the comma in the line after config1.

so i take the comma out and get another message "missing operator"

yet if i put this line in >> __CONFIG b'10111110010100'
it builds ok but with a nag warning.

so what am i doing wrong????:confused::confused:
 

JohnInTX

Joined Jun 26, 2012
4,787
Tried your line with a sample build and it works. The comma is OK but all of the ANDed values must be on one source line. I copy/pasted your code into MPLAB and it was on one line so maybe that's not what's going on but breaking the values into two lines got me to your reported problem. Also, if the __CONFIG is in column 1 you'll get scolded. I used MPLAB 8.63 (MPASM 5.39) to test it.

Consider using the CONFIG directive instead of __CONFIG. You can specify each item on a separate line of code. Settings and values are in the processor header file (P18F88.inc). I find it better than __CONFIG which is an old construct.

config setting=value [, setting=value]

Grasping at straws dept:
If you continue to have problems check the P18F88.inc file to be sure everything in the source is actually defined, on rare occasions, things get left out or are incorrect.

The directive should appear before any code is generated (according to MPASM but not sure why this would be an issue).

Also, be sure the the PIC is identified by MPLAB processor selection or by a 'list' directive.

Make sure that no non-printing characters have crept into the source (been there).

As a last resort, comment those lines out and re-type them from scratch (done that).

Good luck!
 
Last edited:

Thread Starter

Dodgydave

Joined Jun 22, 2012
11,303
Tried the '&' symbol now i get this
Error[126] C:\TEMP\16F88.ASM 6 : Argument out of range (not a valid config register address)


this is my programme, all iwant to do is get started and make an led on porta flash a t 1hz

so if you can spot my mistakes and correct me i would be grateful>>>

LIST p=16F88 ;tell assembler what chip we are using
#include "P16F88.inc" ;include the defaults for the chip
;set up config register
__CONFIG _CONFIG1 & _CP_OFF & _CCP1_RB3 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO

org 0x0000 ;org sets the origin, 0x0000 for the 16F88,
;this is where the program starts running
cblock 0x20
d1
d2
d3
endc

bsf STATUS, RP0 ;select bank 1
movlw b'11000110' ;set up prescaler to 128 on Tmr0
movwf OPTION_REG

movlw b'00000000' ;set PortA all outputs
movwf TRISA
movlw b'11111111'
movwf TRISB ;set PortB all inputs
bcf STATUS, RP0 ;select bank 0

Loop
bsf PORTA,0
;set bit 0 on
call Delay
;
bcf PORTA,0
call Delay ;set bit0 off
goto Loop ;go back and do it again
Delay

;delay of 500msec at 8mhz clock
;999997 cycles
movlw 0x08
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;3 cycles
goto $+1
nop

return
end
 

t06afre

Joined May 11, 2009
5,934
You should do like this
Rich (BB code):
     __CONFIG    _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
     __CONFIG    _CONFIG2, _IESO_OFF & _FCMEN_OFF
This is the config options
Rich (BB code):
;----- CONFIG1 Options --------------------------------------------------
_FOSC_LP EQU H'3FEC' ; LP oscillator
_LP_OSC EQU H'3FEC' ; LP oscillator
_FOSC_XT EQU H'3FED' ; XT oscillator
_XT_OSC EQU H'3FED' ; XT oscillator
_FOSC_HS EQU H'3FEE' ; HS oscillator
_HS_OSC EQU H'3FEE' ; HS oscillator
_FOSC_EC EQU H'3FEF' ; ECIO; port I/O function on RA6/OSC2/CLKO
_EXTCLK EQU H'3FEF' ; ECIO; port I/O function on RA6/OSC2/CLKO
_FOSC_INTOSCIO EQU H'3FFC' ; INTRC oscillator; port I/O function on both RA6/OSC2/CLKO pin and RA7/OSC1/CLKI pin
_INTRC_IO EQU H'3FFC' ; INTRC oscillator; port I/O function on both RA6/OSC2/CLKO pin and RA7/OSC1/CLKI pin
_FOSC_INTOSCCLK EQU H'3FFD' ; INTRC oscillator; CLKO function on RA6/OSC2/CLKO pin and port I/O function on RA7/OSC1/CLKI pin
_INTRC_CLKOUT EQU H'3FFD' ; INTRC oscillator; CLKO function on RA6/OSC2/CLKO pin and port I/O function on RA7/OSC1/CLKI pin
_FOSC_EXTRCIO EQU H'3FFE' ; EXTRC oscillator; port I/O function on RA6/OSC2/CLKO
_EXTRC_IO EQU H'3FFE' ; EXTRC oscillator; port I/O function on RA6/OSC2/CLKO
_FOSC_EXTRCCLK EQU H'3FFF' ; EXTRC oscillator; CLKO function on RA6/OSC2/CLKO
_EXTRC_CLKOUT EQU H'3FFF' ; EXTRC oscillator; CLKO function on RA6/OSC2/CLKO
_WDTE_OFF EQU H'3FFB' ; WDT disabled
_WDT_OFF EQU H'3FFB' ; WDT disabled
_WDTE_ON EQU H'3FFF' ; WDT enabled
_WDT_ON EQU H'3FFF' ; WDT enabled
_PWRTE_ON EQU H'3FF7' ; PWRT enabled
_PWRTE_OFF EQU H'3FFF' ; PWRT disabled
_MCLRE_OFF EQU H'3FDF' ; RA5/MCLR/VPP pin function is digital I/O, MCLR internally tied to VDD
_MCLR_OFF EQU H'3FDF' ; RA5/MCLR/VPP pin function is digital I/O, MCLR internally tied to VDD
_MCLRE_ON EQU H'3FFF' ; RA5/MCLR/VPP pin function is MCLR
_MCLR_ON EQU H'3FFF' ; RA5/MCLR/VPP pin function is MCLR
_BOREN_OFF EQU H'3FBF' ; BOR disabled
_BODEN_OFF EQU H'3FBF' ; BOR disabled
_BOREN_ON EQU H'3FFF' ; BOR enabled
_BODEN_ON EQU H'3FFF' ; BOR enabled
_LVP_OFF EQU H'3F7F' ; RB3 is digital I/O, HV on MCLR must be used for programming
_LVP_ON EQU H'3FFF' ; RB3/PGM pin has PGM function, Low-Voltage Programming enabled
_CPD_ON EQU H'3EFF' ; Data EE memory code-protected
_CPD_OFF EQU H'3FFF' ; Code protection off
_WRT_ALL EQU H'39FF' ; 0000h to 0FFFh write-protected
_WRT_PROTECT_ALL EQU H'39FF' ; 0000h to 0FFFh write-protected
_WRT_2048 EQU H'3BFF' ; 0000h to 07FFh write-protected, 0800h to 0FFFh may be modified by EECON control
_WRT_PROTECT_2048 EQU H'3BFF' ; 0000h to 07FFh write-protected, 0800h to 0FFFh may be modified by EECON control
_WRT_256 EQU H'3DFF' ; 0000h to 00FFh write-protected, 0100h to 0FFFh may be modified by EECON control
_WRT_PROTECT_256 EQU H'3DFF' ; 0000h to 00FFh write-protected, 0100h to 0FFFh may be modified by EECON control
_WRT_OFF EQU H'3FFF' ; Write protection off
_WRT_PROTECT_OFF EQU H'3FFF' ; Write protection off
_DEBUG_ON EQU H'37FF' ; In-Circuit Debugger enabled, RB6 and RB7 are dedicated to the debugger
_DEBUG_OFF EQU H'3FFF' ; In-Circuit Debugger disabled, RB6 and RB7 are general purpose I/O pins
_CCPMX_RB3 EQU H'2FFF' ; CCP1 function on RB3
_CCP1_RB3 EQU H'2FFF' ; CCP1 function on RB3
_CCPMX_RB0 EQU H'3FFF' ; CCP1 function on RB0
_CCP1_RB0 EQU H'3FFF' ; CCP1 function on RB0
_CP_ON EQU H'1FFF' ; 0000h to 0FFFh code-protected (all protected)
_CP_ALL EQU H'1FFF' ; 0000h to 0FFFh code-protected (all protected)
_CP_OFF EQU H'3FFF' ; Code protection off
;----- CONFIG2 Options --------------------------------------------------
_FCMEN_OFF EQU H'3FFE' ; Fail-Safe Clock Monitor disabled
_FCMEN_ON EQU H'3FFF' ; Fail-Safe Clock Monitor enabled
_IESO_OFF EQU H'3FFD' ; Internal External Switchover mode disabled
_IESO_ON EQU H'3FFF' ; Internal External Switchover mode enabled
I have used information in your PIC include file "C:\Program Files\Microchip\MPASM Suite\p16f88.inc" and the template file "C:\Program Files\Microchip\MPASM Suite\Template\Code\16F88TEMP.ASM"
 
Last edited:

Thread Starter

Dodgydave

Joined Jun 22, 2012
11,303
thanks have copied your line in and now it builds, looks like i left the config2 line off.

Cheers your a STAR!!


P.S. is that the only way to write to the config or can you do a "MOVWF CONFIG"
 

Markd77

Joined Sep 7, 2009
2,806
Sorry, I got confused, I've only used PICs with one configuration line. Glad it works now.
As far as I know that is the only way to set the configuration. It can't be changed without reprogramming, at least in the midrange PICs I use, so movwf wouldn't work.
 

ErnieM

Joined Apr 24, 2011
8,377
Its a good idea to always take a look into the template file and the include file. Then programming new PICs ;)
QFT. It makes lots of sense (and is my standard way of starting a new project) to use the Microchip template file as a starting point. In this case the file is "16F88TEMP.ASM" and lives at ...\Program Files\Microchip\MPASM Suite\Template\Code.

As it turns out, the configuration you were attempting to use exactly matches the template. Had you started there you would have saved yourself a few days of grief, and had a good example of some of the tricky syntax you need to use.
 
Top