Hi Darrel,
Pretty cool stuff. Have you tested this on other 18F parts? I don't have a 4520 to test
with, but I couldn't get this to work without clearing CCP1CON before moving 9 to it on
a 452 or 4431.
Had to do this;
Code:
ASM
MyInt
clrf CCP1CON ; 18F452 & 18F4431 require this before it changes CCP1 output
movlw 9
movwf CCP1CON
bcf PIR1,TMR1IF ; clear TMR1 int flag
retfie FAST ; use RETFIE FAST to restore WREG, STATUS & BSR
ENDASM
On an 18F452 or 18F4431, the above works fine, but only if I clear CCP1CON first.
This works on a 452 & 4431 with CCP1 & TMR1 ints enabled on any output pin;
Code:
ASM
MyInt
btfss PIR1,TMR1IF ; TMR1 interrupt?
bra CCP ; no - service CCP interrupt
bcf PIR1,TMR1IF ; yes - clear TMR1 int flag
bsf LATB,0 ; set RB0 on TMR1 interrupt
retfie FAST ; return
CCP
bcf PIR1,CCP1IF ; clear CCP1 int flag
bcf LATB,0 ; clear RB0 on compare interrupt
retfie FAST ; use RETFIE FAST to restore WREG, STATUS & BSR
ENDASM
I was just wondering if this might be a fluke with the 4520 part - since none of the other
18F parts I've tested will toggle CCP1 with just the movlw 9, movwf CCP1CON?
Bookmarks