I have a PIC18F87J11 device and I'm supposed to create:
1) a high-priority ISR that's supposed to be triggered every 100ms
2) a low-priority ISR that's supposed to be triggered every 10ms
I have a basic knowledge about configuring a pre-scaler, in example for Timer0, it's
movlw b'00000010'
movwf T0CON
as manual page reads, this should configure Timer0 to 16bit counter, pre-scaler 1:8 (device's manual page 179). The problem is, I don't know how to determine the correct pre-scaler settings when I want 100ms intervals. Any help appreciated.
EDIT:
Okay, now I realize that I probably have way less idea about what I'm doing then I thought. I can't find relevant information in manual (and I'm sure it is there). I need to set up Timer0 to 100ms and Timer1 to 10ms.
Here are you have ISR high-priority initiation rutine for TMR0.
At very begining of your MCPU initiation code you must define...
;Init TMR0 as 8 bit timer, overflow every 1024 CPU cycles if TMRxPrescaler4 is set
;{
TMRxPrescaler2 equ 0
TMRxPrescaler4 equ 1
TMRxPrescaler8 equ 2
TMRxPrescaler16 equ 3
TMRxPrescaler32 equ 4
TMRxPrescaler64 equ 5
TMRxPrescaler128 equ 6
TMRxPrescaler256 equ 7
movlw (1<<TMR0ON) + (1<<T08BIT) + TMRxPrescaler4
movwf T0CON
bsf INTCON, TMR0IE ;enable TMR0 overflow interrupt
;};
After MCPU initiation don't forget to switch on interrupts...
bsf INTCON, GIE
ISR rutine:
ISR
bcf INTCON, TMR0IF ;demask TMR0 overflow interrupt
;your ISR code
retfie 1
In ISR rutune count numbers of TMR0 overflows, for 10MHz CPU clock: 10000000 / 4 / 1024 = 2441.4 overflows for one second.
I recommend that you are using only one ISR rutine where you handle both events.