Hi all
I am using PIC18F4620 and C18 complier. I want my timer 0 to increment at every instruction clock cycle BUT only when I want it to and stop when I want it to.
Currently, I have T0CON = 0x88
I have defined an interrupt , at the end of the interrupt I read Timer0( number of rising edge during interrupt). The reading Im getting has ~200 MORE points. I feed 0s into TMR0H and TMR0L at the beginning and end of the interrupt (after reading timer0) . Where am I getting these additional 200 clicks from?
Slightly lost right now...
I want to use Timer 0 as a COUNTER to increment on INTERNAL INSTRUCTION CLOCK! How do I do that?
Currently I am using Timer0 as a timer to increment on internal instruction clock. This is because there is no option to make it counter for internal clock.
Heres from PIC18F4620 data sheet :
T0CS: Timer0 Clock Source Select bit
1 = Transition on T0CKI pin
0 = Internal instruction cycle clock (CLKO)
Timer0 can operate as either a timer or a counter; the
mode is selected with the T0CS bit (T0CON<5>). In
Timer mode (T0CS = 0), the module increments on
every clock by default unless a different prescaler value
is selected (see Section11.3 Prescaler). If the
TMR0 register is written to, the increment is inhibited
for the following two instruction cycles. The user can
work around this by writing an adjusted value to the
TMR0 register.
The Counter mode is selected by setting the T0CS bit
(= 1). In this mode, Timer0 increments either on every
rising or falling edge of pin RA4/T0CKI. The incrementing
edge is determined by the Timer0 Source Edge
Select bit, T0SE (T0CON<4>); clearing this bit selects
the rising edge. Restrictions on the external clock input
are discussed below.
I am using PIC18F4620 and C18 complier. I want my timer 0 to increment at every instruction clock cycle BUT only when I want it to and stop when I want it to.
Currently, I have T0CON = 0x88
I have defined an interrupt , at the end of the interrupt I read Timer0( number of rising edge during interrupt). The reading Im getting has ~200 MORE points. I feed 0s into TMR0H and TMR0L at the beginning and end of the interrupt (after reading timer0) . Where am I getting these additional 200 clicks from?
Slightly lost right now...
I want to use Timer 0 as a COUNTER to increment on INTERNAL INSTRUCTION CLOCK! How do I do that?
Currently I am using Timer0 as a timer to increment on internal instruction clock. This is because there is no option to make it counter for internal clock.
Heres from PIC18F4620 data sheet :
T0CS: Timer0 Clock Source Select bit
1 = Transition on T0CKI pin
0 = Internal instruction cycle clock (CLKO)
Timer0 can operate as either a timer or a counter; the
mode is selected with the T0CS bit (T0CON<5>). In
Timer mode (T0CS = 0), the module increments on
every clock by default unless a different prescaler value
is selected (see Section11.3 Prescaler). If the
TMR0 register is written to, the increment is inhibited
for the following two instruction cycles. The user can
work around this by writing an adjusted value to the
TMR0 register.
The Counter mode is selected by setting the T0CS bit
(= 1). In this mode, Timer0 increments either on every
rising or falling edge of pin RA4/T0CKI. The incrementing
edge is determined by the Timer0 Source Edge
Select bit, T0SE (T0CON<4>); clearing this bit selects
the rising edge. Restrictions on the external clock input
are discussed below.