Multiple compare and capture on same Timer
2006-02-20 by gvnn77
Hi everyone, I'm searching for solve a big problem in one of my projects. We use FreeRTOS in LPC ARM microcontroller and scheduler is called by a tick made with Timer0 Compare0. Unfortunately, Timer0 is configured, by FreeRTOS sources, as reset on match Compare0. Our board has a capture pin on P0.22 (CAP0.0) used to detect level duration and we have not to reset Timer0. So we configured Timer0 as continuously running and, on Timer0 Match0 interrupt, we reloaded new match value on register permitting us to have a periodic tick of 100 microseconds. To set the new match value I use following code: T0MR0 += L_COMPAREMATCH; where L_COMPAREMATCH is equal to 6000. Doing so, our next tick is after 71 seconds (that is about 0xFFFFFFFF clock at 60MHz) If I substitute previous code with: T0MR0 = T0TC + L_COMPAREMATCH; our next tick is about after 100 microseconds. But I cannot use this code, as I will lost tick between match on T0MR0-T0TC and recalculation-setting of next compare. How can I do? I cannot use Timer1 for O.S. tick as it is used for other purposes... Is it possible that between match on Compare0 and write of next Compare0, T0TC counts as many ticks as my match value? I tried to increment tick value of compare, but nothing, it doesn't work! My LPC works at 60MHz as Timer0, so I don't think that it executes about 20 instructions (corresponding to flag check and T0MR0 += L_COMPAREMATCH;) in 100 microseconds!!!! Thank you for your attention Enrico D.M. Vicenza - Italy