I have been trying to use Timer0 in an 18F8720 device as a 16-bit timer. I can get my code to work when it is configured as an 8-bit counter, but when I set it to 16-bits, no interrupts occur. Here is a code snippet of a modified version of EX_STWT.C example from CCS:
------------------------------------------------------
#int_timer0 // 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;
}
}
InitializeSystem();
do {
printf("Press any key to begin.\n\r");
getc();
start=seconds;
printf("Press any key to stop.\n\r");
getc();
printf("%u seconds.\n\r",seconds-start);
} while (TRUE);
}
------------------------------------------------------
When the initialization line is as follows timer 0 interrupts are generated.
When the RTCC_8_BIT option is eliminated, which should cause timer 0 to become 16-bit, timer0 interrupts do not occur.
setup_timer_0 (RTCC_INTERNAL | RTCC_DIV_256);
Anyone experienced this? Is there a work-around? Thanks.
Pogostik
Joined: 06 Jul 2004 Posts: 3
Typo in headline... Pls excuse
Posted: Tue Jul 06, 2004 9:20 am
In my header I meant to type 18F8720. I don't think the 18F8920 is available yet....
Guest
Posted: Tue Jul 06, 2004 10:13 am
Did you wait enough time? Setting up timer0 to 16 bit in your case could means 256 seconds (cca. 4 minutes) instead of the original 1 second.
Pogostik
Joined: 06 Jul 2004 Posts: 3
Posted: Tue Jul 06, 2004 10:27 am
Are you saying... setting timer0 to 16 bits and initializing it to 0 would result in 65535 ticks before interrupt; whereas setting it to 8 bits would require only 256 ticks before interrupt? I think that may be it. Let me try it with those adjustments.
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