|
|
View previous topic :: View next topic |
Author |
Message |
eliberg Guest
|
problem with timer0 int and program size |
Posted: Mon Mar 13, 2006 11:15 am |
|
|
Hi,
I have a really big problem with the timer0 interrupt.
I'm using a 18F4431 PIC, and wuold like to have an int0 every 30ms.
If my program is short (under 30% ROM usage), no problem, the int works fine.
( setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
enable_interrupts(INT_RTCC);
set_timer0(64950);
Inside the int routine of course I set the timer again
)
But my program is very long. With a 61% of rom usage, the int0 fires every 167ms, even if the set_timer is always 64950, and if I compile the whole program (65% of rom usage) int0 fires every 250ms.
It seems that the interrupt timing depends on the program size.
Is it possible?
What can I do?
Thanks
eli |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Mar 13, 2006 11:33 am |
|
|
Quote: | I'm using a 18F4431 PIC, and wuold like to have an int0 every 30ms. |
Can you clarify which interrupt source you are using ?
"int0" is the first external interrupt, and is on pin RC3.
Did you actually mean to say the "TMR0" interrupt ? |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Mon Mar 13, 2006 11:35 am |
|
|
Here are a couple of things to look at:
Make sure you do not call a function from both within the interrupt handler and in the main code body. If you do do this then it is likley the PIC is adding disable interrupts around the call in the main body of code with the result that you miss interrupts.
Some functions, such as writing to the internal EEPROM, automatically disable interrupts during the process however this does not explain the large delays you are seeing.
Another common mistake is to code functions inside the interrupt handler - such as printf or delay_ms(xxx) in which case you are staying too long in the handler and missing interrupts. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Ttelmah Guest
|
|
Posted: Mon Mar 13, 2006 11:42 am |
|
|
Try something radical. Make the code 'grow' to the larger size, by writing a macro, to do something simple, like loop a few dozen times, and repeat this into the main code a lot of times.
I suspect you will find that the interrupt remains at the same frequency.
What is probably happening, is that some individual command in the main, is resulting in interrupts being disabled, and you are spending longer in this state as your code grows...
Best Wishes |
|
|
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|