
Har samma problem med Timer 1.
(Timer 0 och Timer 2 kan jag få att generera interrupt)
Jag släpper in en klocksignal på pin 13, och använder pin 22 och 23 för debug. (DIL-kapsel)
Hoppas att någon kan peka på vad jag gör för fel...
Kod: Markera allt
__config _CP_OFF & _DEBUG_OFF & _WRT_ENABLE_OFF & _CPD_OFF & _LVP_OFF & _BODEN_ON & _PWRTE_OFF & _WDT_OFF & _HS_OSC
include "p16f870.inc"
PUSH macro
movwf TEMP_W
swapf STATUS,W
movwf TEMP_S
endm
POP macro
swapf TEMP_S,W
movwf STATUS
swapf TEMP_W,1
swapf TEMP_W,W
endm
;
; Register file definitions
; First byte is at 0x20
TEMP_S equ 0x20
TEMP_W equ 0x21
; last byte is at 0x7F
org 0 ;
goto init ;
;
org 4 ;
interrupt ;
bcf INTCON, GIE ; Disable interrupts
PUSH
movlw 0x02 ; DEBUG, show if we get interrupts
xorwf PORTB, F
bcf PIR1, CCP1IF ; Clear capture interrupt flag
bcf PIR1, TMR1IF ; Clear Timer 1 interrupt flag
POP ;
bsf INTCON, GIE ;
retfie ;
; ******************************************************
; Init
; ******************************************************
init ;
movlw 0x21 ; Start at 21, using 20 as counter--
movwf FSR ;
movlw 0x60-1 ; 96 bytes, but "20" gets cleared by decfsz
movwf 0x20 ; Store number of bytes to clear in "20"
ram clrf INDF ; Clear the location pointed to by FSR
incf FSR, F ; Point to next location
decfsz 0x20, F ;
goto ram ;
bcf STATUS, RP0 ;
bcf STATUS, RP1 ;
clrf PORTA ;
bsf STATUS, RP0 ; Bank 1
movlw 0x08 ; No TMR0 prescaler
movwf OPTION_REG ;
movlw 0x3F ;
movwf TRISA ;
movlw 0x00 ;
movwf TRISB ; PORTB outputs
movlw 0x04 ;
movwf TRISC ;
clrf PIE1 ;
bsf PIE1, CCP1IE ;
bsf PIE1, TMR1IE ; DEBUG
bcf STATUS, RP1 ; Bank 0
clrf CCP1CON ; Capture mode, every rising flank
movlw 0x05 ;
movwf CCP1CON ;
movlw 0x01 ; Timer1 on, no prescaler
movwf T1CON ;
clrf INTCON ;
bsf INTCON, PEIE ;
bsf INTCON, GIE ;
main
movlw 0x04 ; DEBUG, show if processor is running
xorwf PORTB, F ; DEBUG
goto main
end