BYTE seconds; // A running seconds counter
BYTE int_count; // Number of interrupts left before a second has elapsed
#int_rtcc // This function is called every time
void clock_isr() { // the RTCC (timer0) overflows (255->0).
// For this program this is apx 76 times
if(--int_count==0) { // per second.
++seconds;
int_count=INTS_PER_SECOND;
}
What does it mean this expression: (20000000/(4*256*256)) ?
As i can understand 20000000 is clock frequency.
256 is prescaler division. What are 4 and the second 256??
Thanks
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
Posted: Sat Apr 29, 2006 7:22 am
Quote:
As i can understand 20000000 is clock frequency.
256 is prescaler division.
True.
Quote:
What are 4 and the second 256??
The 4 comes from the timers being driven at Fosc / 4. This is related to the PIC using 4 clock cycles to execute a single instruction.
The 256 is the maximum value your timer can count up to before overflowing, at overflow an interrupt is generated and the timer starts counting at 0 again. For 8-bit timers use 256 and for 16 bit timers 65536.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum