I’m trying to use DSP timers to get the speed of 4 wheels. I use the register B0, B1, D0, D1.
I set the register of the timers as I saw in the processor expert “capture” bean. (both edge, interrupt enables, prescaler set to 5). The frequency I try to get is between 40Hz and 2.5 KHz.
The problem I have is that:
when the speeds of the wheels are about the same I get a delay in the timer values.
This means that I read 4 different values of speed. The smallest one is the correct.
When an interrupt is detected the sequence of code is this:
- Reset the counter
- Verify if an overflow occurred, and in this case I manage the overflow
- If no overflow then enalbele highest level interrupt (level 3), read the capture register and reset the interrupt flag.
In my opinion the problem is that: when the B0 interrupt occurs and the program is inside the handling routine of B0, happen that B1, or other timers, interrupt occurs… and It is delay handled, so the reset of its timer is done with a delay and this introduce the problem.
One solution could be to force the DSP on the interrupt events to automatically reset the timer after saving the timer value in the capture register. But I don’t know how to do it, and if is it possible.
How can I overcome this?