Content originally posted in LPCWare by PhysicsGuy on Fri Mar 01 13:38:34 MST 2013
Dear forum users,
this is my first post here.
I have a little problem with the handling of Timer0 handling on an lpcxpresso board with an lpc1769 on it.
My interrupt handler does the following. I set the timer such that it counts down from a certain value and raises an interrupt whem it reaches zero. In the handler, I reset the interrupt, load a new value into the timer and do some other stuff. In one application, this other stuff is just loading a word from memory and outputting that word on the pins of gpio0. This works nicely and if I run -O3 optimized code I can achieve a minimum time between events of 1 microsecond. Which is just about good enough. I can also somehow understand it, because it is twice the time ot seems the lpc to switch from main code to ithe isr. Does anyone know by now where this 500 ns latency comes from? I have followed several threads about this and no one seems to have resolved this issue.
In another application, instead of just clocking out one value, I program a 16 bit dac through gpio0. This takes, allowing for the time delays required by the part, about one microsecond, as measured by monitoring a gpio pin going upon entering the isr and going low at the end of the isr. This works when I set the timer value such that the time between the timer interrupt is about 4 microseconds or longer this works ok, but if I set the timer such that the period is less that ~2.6 microseconds, the period becomes unstable and fluctuates around 2.6 microseconds. I would have guessed that this should be 2 microsecond (the minimum period in my digital example+the time it takes to do the extra work to program the dac).So where is theextra 600 ns coming from?
To specify the system further, I have no other irq's enabled. The main loop polls the ethernet mac for incoming data, which is not there, because the part is in a separate lan without anything sending on it (no IP over this lan, only ethernetpackets under my control).
Thanks in advance for any hints.