Hi,
Here is a TMR1 test program for 18F4620, which needs INTERRUPT time setting [ TMR1L = TMR1H ]
Here is a calculation, to assist the settings: (Thanks E)
(The OSC is from an 8MHz XTL with PLL enabled.)
[[ Prescaler for TMR1 look at T1CON = 0x30' = 8:1, so thats 1MHz/8= 125KHz or 8uSec
Then TMR1 if loaded with 0xFFFF =65536 division =1.97Hz or ~0.52Sec period.
So load TMR1 with 0x0BDC [ decimal 65536-62500=3036] , that will give 8uSec*62500 = 0.5Sec.
So it will have to count UP from 3036 decimal to 65536 then roll over to 0000 count and generate an Interrupt every 0.5sec
You MUST reload TMR1 every time its in the Interrupt subroutine with 0x0BDC ]]
EDIT: I've coloured the 8's RED. Are these two different, in other words OSC/8/8 ?
C.
Here is a TMR1 test program for 18F4620, which needs INTERRUPT time setting [ TMR1L = TMR1H ]
Here is a calculation, to assist the settings: (Thanks E)
(The OSC is from an 8MHz XTL with PLL enabled.)
[[ Prescaler for TMR1 look at T1CON = 0x30' = 8:1, so thats 1MHz/8= 125KHz or 8uSec
Then TMR1 if loaded with 0xFFFF =65536 division =1.97Hz or ~0.52Sec period.
So load TMR1 with 0x0BDC [ decimal 65536-62500=3036] , that will give 8uSec*62500 = 0.5Sec.
So it will have to count UP from 3036 decimal to 65536 then roll over to 0000 count and generate an Interrupt every 0.5sec
You MUST reload TMR1 every time its in the Interrupt subroutine with 0x0BDC ]]
EDIT: I've coloured the 8's RED. Are these two different, in other words OSC/8/8 ?
C.
Attachments
-
1.3 KB Views: 8
Last edited: