In order to program a PIC16F54, I have to set the GCB to …
#chip 16c54
…in order for my programmer (DIY K149-BC v141204) to program the "F" part number.
Also to note, a PIC16x54 does not have two instructions that most of the other chips have. These are ADDLW and SUBLW.
An example GCB code:
[word] Accumulator = 0 Accumulator += 1
Will cause an error in the compiler … "Unknown opcode 'addlw' and generates the following assembly code…
clrf Accumulator clrf Accumulator_H movlw 1 addwf Accumulator,F movf Accumulator_H,W btfsc STATUS,C addlw 1 movwf Accumulator_H
The workaround that I have used for WORD values is this and requires direct inline assembly …
[word] Accumulator = 0 movlw 1 addwf Accumulator,F btfsc STATUS,C incf Accumulator_H,F
Alternatively you could setup the counter like this …
'Same as .... ' Accumulator = Accumulator + 1 movlw 1 addwf Accumulator,F btfsc STATUS,C addwf Accumulator_H,F btfsc STATUS,C goto OVERFLOW_routine
Even for a 32-Bit Counter, something like this …
movlw 1 addwf Accumulator_A,F btfsc STATUS,C addwf Accumulator_B,F btfsc STATUS,C addwf Accumulator_C,F btfsc STATUS,C addwf Accumulator_D,F btfsc STATUS,C goto OVERFLOW_routine
Where A/B/C/D are each BYTEs making up the 32-Bit LONG
Log in to post a comment.
In order to program a PIC16F54, I have to set the GCB to …
#chip 16c54
…in order for my programmer (DIY K149-BC v141204) to program the "F" part number.
Also to note, a PIC16x54 does not have two instructions that most of the other chips have. These are ADDLW and SUBLW.
An example GCB code:
Will cause an error in the compiler … "Unknown opcode 'addlw' and generates the following assembly code…
The workaround that I have used for WORD values is this and requires direct inline assembly …
Alternatively you could setup the counter like this …
Even for a 32-Bit Counter, something like this …
Where A/B/C/D are each BYTEs making up the 32-Bit LONG