t.man
New Member
hi guys!,
i'm just trying to find my way with basics around PIC and assembly language.
now i'm trying timer1 on compare match interrupt but it doesn't seem doing that.
may you come to my rescue?
i'm just trying to find my way with basics around PIC and assembly language.
now i'm trying timer1 on compare match interrupt but it doesn't seem doing that.
may you come to my rescue?
Code:
;timer1 in clear timer1 on interrupt
;developer: ????
;for PIC: 16f877a
;
processor 16f877a
include "p16f877a.inc"
errorlevel -302, -207;supress error message 302
__config _CP_OFF & _WDT_OFF & _PWRTE_ON & _RC_OSC
cblock 0x20
W_TEMP
STATUS_TEMP
PCLATH_TEMP
endc
org 0x00
goto main
org 0x04
goto ISR
init
banksel TRISB
clrf TRISB ;all outputs
banksel PORTB
clrf PORTB;all output pins low
movlw 0x0A
banksel CCP1CON
movwf CCP1CON;Compare mode, generate software interrupt on match
banksel PIE1
bsf PIE1, CCP1IE;enable CCP interrupt
banksel INTCON
bsf INTCON, GIE;enable interrupts
banksel CCPR1L
movlw .40
movwf CCPR1L
clrf CCPR1H;
movlw b'00101001'
banksel T1CON
movwf T1CON; set ups
banksel TMR1L
clrf TMR1L
banksel TMR1H
clrf TMR1H
retlw 0x00
main
call init
loop
goto loop
ISR
swapf STATUS,W
movwf STATUS_TEMP
movlw 0x01
xorwf PORTB,f;toggle
exit
swapf STATUS_TEMP,W
movwf STATUS
retfie
end