Reputation: 1
I want to build a binary clock using the timer1 module as RTC with the code example from the datasheet, but although I wrote the necessary code around it, the interrupt does not trigger. Did I miss a register setting or memory address? I'm new to PIC programming but got some experience in assembly.
UDATA_ACS
secs RES 1
mins RES 1
hours RES 1
ORG 0x0000 ; processor reset vector
GOTO MAIN ; go to beginning of program
ORG 0x0800
BTFSC intcon,int0if
CALL int0_isr
RETFIE
MAIN_PROG CODE ; let linker place main program
ORG 0x0100
MAIN
MOVLW 080h ; Preload TMR1 register pair
MOVWF TMR1H ; for 1 second overflow
CLRF TMR1L
MOVLW b'00001101' ; Configure for external clock,
MOVWF T1CON ; Asynchronous operation, external oscillator
CLRF secs ; Initialize timekeeping registers
CLRF mins ;
MOVLW .12
MOVWF hours
BCF intcon,int0if
BSF INTCON,INT0IE
BCF INTCON2,INTEDG0
; BSF rcon,ipen
; BSF intcon,peie
BSF PIE1, TMR1IE ; Enable Timer1 interrupt
BSF intcon,gie
clrf lata
movlw 0x0f
movwf adcon1
movwf 0x07
movwf cmcon
movlw 0x00
movwf trisa
clrf portb
movlw 0x00
movwf trisb
clrf latd
movlw 0x00
movwf trisd
movlw secs
movwf lata
movlw mins
movwf latb
movlw hours
movwf latd
here
goto here
RETURN
int0_isr
;from datasheet p.133
RETFIE
~~~~~~~~~
Upvotes: 0
Views: 132
Reputation: 4288
You are using the wrong interrupt vector with 0800
.
Interrupt Vector high: 0008h
Interrupt Vector low: 0018h
ORG 0x0008
BTFSC intcon,int0if
CALL int0_isr
RETFIE
Upvotes: 1