#169429 - Synthetic - Fri Jul 10, 2009 9:17 am
So I've been having problems with timers since the last libnds update, and I'm having a weird problem now that I'm not quite sure what to make of.
I'm setting up a ~millisecond timer using the following code:
The timer is enabled first thing in main, and happily chugs along working until time0 reaches ~65100 and then the program freezes. I've looked around, and it seems to freeze in a slightly different place in my code every time, which implies its not an overflow in any of my time calculations causing a freeze, and the fact that its freezing so close to 65535 ticks is very suspicious. I've tried calling the timer init code again after ~65000 ticks but that doesn't do anything.
Is there a way that the hardware timer could be overflowing into other memory, or maybe I'm overlooking something in the setup? I'm afraid I don't know very much about the timer internals, so I have no idea what the problem could be.
Thanks in advance for any help.
I'm setting up a ~millisecond timer using the following code:
Code: |
volatile long time0=0;//global millisecond timer void timer0_function(void){time0++;} //blah blah blah, code inbetween TIMER0_DATA = TIMER_FREQ_64(1000); TIMER0_CR = TIMER_ENABLE | TIMER_IRQ_REQ | TIMER_DIV_64; irqSet(IRQ_TIMER0, timer0_function); irqEnable(IRQ_TIMER0); |
The timer is enabled first thing in main, and happily chugs along working until time0 reaches ~65100 and then the program freezes. I've looked around, and it seems to freeze in a slightly different place in my code every time, which implies its not an overflow in any of my time calculations causing a freeze, and the fact that its freezing so close to 65535 ticks is very suspicious. I've tried calling the timer init code again after ~65000 ticks but that doesn't do anything.
Is there a way that the hardware timer could be overflowing into other memory, or maybe I'm overlooking something in the setup? I'm afraid I don't know very much about the timer internals, so I have no idea what the problem could be.
Thanks in advance for any help.