3BABY
Member level 5
- Joined
- Jan 14, 2011
- Messages
- 91
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- New Zealand
- Activity points
- 2,252
Hi Guys,
im having major difficulty trying to create a delay of 765 Timer1 counts..
i just cannot get the interrupt flag to work..
ive tryed loading the High Byte with 253 as you can see in my code so the Low Byte will count up to 255 3 times.. but in MPLab SIM i cant see the High Byte incrementing and i donot get an interrupt..
i have read the datasheet and checked and re checked..
the only time i can get it to work is if i load timer1 High Byte with 255 and let the Low Byte count up to 255 and then it will set the interrupt bit.. but if I clear the interrupt bit and try to count up to 255 on the Low byte again.. it wont Skip to Next Instruction..
any help would be much appricated
im having major difficulty trying to create a delay of 765 Timer1 counts..
i just cannot get the interrupt flag to work..
ive tryed loading the High Byte with 253 as you can see in my code so the Low Byte will count up to 255 3 times.. but in MPLab SIM i cant see the High Byte incrementing and i donot get an interrupt..
i have read the datasheet and checked and re checked..
the only time i can get it to work is if i load timer1 High Byte with 255 and let the Low Byte count up to 255 and then it will set the interrupt bit.. but if I clear the interrupt bit and try to count up to 255 on the Low byte again.. it wont Skip to Next Instruction..
any help would be much appricated
Code:
BSF T1CON, RD16 ;= 1 RD16: 16-Bit Read/Write Mode Enable bit
BCF T1CON, T1RUN ;= 0 T1RUN: Timer1 System Clock Status bit
BCF T1CON, T1CKPS1 ;= 0 T1CKPS1:T1CKPS0: Timer1 Input Clock Prescale Select bits
BSF T1CON, T1CKPS0 ;= 1
BCF T1CON, T1OSCEN ;= 0 T1OSCEN: Timer1 Oscillator Enable bit
BCF T1CON, T1SYNC ;= 0 T1SYNC: Timer1 External Clock Input Synchronization Select bit
BCF T1CON, TMR1CS ;= 0 TMR1CS: Timer1 Clock Source Select bit
; 1 = External clock from RC0/T1OSO/T13CKI pin (on the rising edge)
; 0 = Internal clock (FOSC/4)
BCF T1CON, TMR1ON ;= 0 TMR1ON: Timer1 On bit
BSF PIE1, TMR1IE ; Timer1 interrupt enabled
BCF PIR1, TMR1IF ; clears timer1 interrupt flag bit
MOVLW 0x00 ;loading the Timer Low Byte
MOVWF TMR1L
MOVLW d'253' ; loading the Timer HIgh Byte
MOVWF TMR1H
BSF T1CON, TMR1ON ; STARTS TIMER1
AGAIN1 BTFSS PIR1, TMR1IF
GOTO AGAIN1
BCF T1CON, TMR1ON ; STOPS TIMER1
BCF PIR1, TMR1IF ; clears timer1 interrupt flag bit
;moves onto next part of program