View previous topic :: View next topic |
Author |
Message |
evsource
Joined: 21 Nov 2006 Posts: 129
|
INT_RTCC RTCC timer0 going too slow on 18F2520 |
Posted: Mon Apr 23, 2007 10:27 am |
|
|
Hi,
On a 18F2520, with the latest version compiler (4.030), I can't seem to get the timer0 interrupt (INT_RTCC) to give the expected results. I have it set up like this:
Code: | setup_timer_0( RTCC_INTERNAL );
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL); |
I've tried variations of the setup_timer0 function using various combinations like:
Code: | setup_timer_0( RTCC_INTERNAL | RTCC_DIV_2); |
and
Code: | setup_timer_0( RTCC_INTERNAL | RTCC_DIV_128 ); |
I'm using a 8mHz clock.
The higher divisors do slow the interrupt down, but the fastest setting (the first chunk of code with only RTCC_INTERNAL, no scalers), interrupts at about 14Hz. I would expect *much* faster.
Any ideas of what I could be doing wrong? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 23, 2007 11:22 am |
|
|
The timer is being configured in 16-bit mode. You're probably expecting
it to be in 8-bit mode. In CCS, you have to explicitly put it in that mode.
Example:
Code: | setup_timer_0( RTCC_INTERNAL | RTCC_8_BIT ); |
|
|
|
evsource
Joined: 21 Nov 2006 Posts: 129
|
|
Posted: Mon Apr 23, 2007 3:50 pm |
|
|
PCM programmer wrote: | The timer is being configured in 16-bit mode. You're probably expecting
it to be in 8-bit mode. In CCS, you have to explicitly put it in that mode.
Example:
Code: | setup_timer_0( RTCC_INTERNAL | RTCC_8_BIT ); |
|
That was it. Thanks! |
|
|
|