This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi there,
I got a question regarding the PWM syncing and interrupt.
We are syncing PWM with an external signal with no phase (TBPHS = 0). We also set PWM interrupt will be triggered when counter = 0 or TBPRD (ETSEL[INTSEL] = ET_CTR_PRDZERO). The program seems to work fine, the motor did run.
But thinking a bit further we come up with a scenario that should have caused problem: Let say TBCTR just reach 0 and a PWM ISR is triggered. But shortly after, when TBCTR is at let say 4, external signal comes in, with the syncing mechanism TBCTR will be reset to 0. In this case will this cause interrupt signal to be fired again? If so is that mean an extra ISR will be running right after current ISR?
I tried to illustrate the scenario in the following figure:
Thanks for reading, any reply is appreciated
Yes every time the TBCTR becomes 0, an interrupt will fire. You can set TBPHS=1 so it wont change TBCTR to 0.
Nima
Thanks for the reply Nima, your anwser clear our doubt.
Just one more question though, is there any good way to monitor ISR? We have tried toggling IO when enter and leave ISR, it works but is clumsy. It's difficult to hold oscilloscope probe steady and the number of ISRs we can monitored are limited by the number of spare IO on the board.
Maybe a good way is having a variable that increments every interrupt. Then transfer that variable up to a PC for debugging through SCI and COM ports.