I am getting syntax errors while trying to set the configuration bits on a PIC16F886.
The problem is that there are two configuration words and two configurations have multiple bits.
So it does not work the way it works with PIC10F206.
I am using the pic-as v2.20 toolchain.
PROCESSOR 16F886
RADIX DEC
#include <xc.inc>
;this did not work:
;config DEBUG = ON, LVP = OFF, FCMEN = OFF, IESO = OFF, BOREN = OFF
;config CPD = OFF, CP = OFF, MCLRE = OFF, PWRTE = OFF, WDTE = OFF, FOSC = OFF
;this did not work:
;config 0000000000000000000000000000
;this did not work:
;config 0x00
;this did not work:
;config config1 0x0000
;config config2 0x0000
PSECT StartCode,class=CODE,delta=2
global Start
Start:
movlw 11000000B ;set option register
;option is not in the p16f886 instruction summary
movwf 81h ;option_reg is at 81h (bank 1)
movlw 11111110B ;everything to input except for RA0
tris 05h ;05h is TRISA
bcf 05h, 0 ;clear bit zero in TRISA register
;the led on RA0 should light up now
sleep
END Start
Thanks for your answers.
This code here works so far.
It is still not perfect like I probably should use the BANKSEL
directive and use the variables instead of hex codes.
Also I did not set bank 1 before setting the options so that might not have an effect.
PROCESSOR 16F886
PAGEWIDTH 132
RADIX DEC
#include <xc.inc>
config DEBUG = OFF, LVP = OFF, FCMEN = OFF, IESO = OFF, BOREN = OFF
config CPD = OFF, CP = OFF, MCLRE = OFF, PWRTE = OFF, WDTE = OFF
config FOSC = INTRC_NOCLKOUT, LVP = OFF, BOR4V = BOR40V, WRT = OFF
PSECT StartCode,class=CODE,delta=2
global Start
Start:
movlw 11000000B ;set option register
;option is not in the p16f886 instruction summary
movwf 81h ;option_reg is at 81h (bank 1)
movlw 00100000B ;set the status register (select bank 1)
movwf 03h ;status register is at 03h
movlw 11111110B ;everything to input except for RA0
;there is no tris instruction on this processor
movwf 85h ;85h is TRISA register
movlw 00000000B ;set the status register (select bank 0)
movwf 03h ;status register is at 03h
;05h is PORTA
bcf 05h, 0 ;clear bit zero in PORTA register
;the led on RA0 should light up now
sleep
END Start