Hello,
I am using MPC5744P, and the configuration of PWM-CTU-ADC for sampling the ADC on PWM trigger. I am freezing the CTU when entering debug mode in order to disable interrupts that are triggered by the PWM, because PWM triggers continue to work even when the debug mode is entered. PWM.CTRL2.B.DBGEN only disables the output of the PWM submodule, not the triggers that go to the CTU. If I don't disable the CTU, debugging is difficult, because an interrupt is triggered while I am in debug (e.g. breakpoint is encountered), and on exit from debug mode (continue is pressed) the interrupt is executed, and the same breakpoint is triggered again on return from interrupt.
I have disabled the CTU_0 in debug mode by setting MC_ME.PCTL251.B.DBG_F bit.
This configuration works unreliably because sometimes the CTU doesn't unfreeze on the debug mode exit! This is potentially very dangerous in motor control applications, because on debug exit, the CTU remains freezed, while the PWM is working, and the code is executed.
Now I have fixed this by freezing the PWM instead of the CTU, although the CTU freeze should have worked properly.
Can anybody help, or share some experiences on this matter?
Hi,
You can also disable:
1. FlexPWM counters via RUN bit. This will stop generating triggers to CTU
2. You can clear FlexPWM_SUBn_TCTRL - in this case FlexPWM counters will run, but wont generate triggers for CTU.
I don't think disabling CTU is correct here. I would rather disable source of CTU triggers.
Peter
Hello Peter,
thank you for the quick response.
The problem is in disabling the output trigger when a breakpoint is encountered. I would like to disable the triggers automatically when the debug is entered. Is there a known mechanism for handling those issues, like a hook that could be called?
I understand what you want to achieve.
There are to ways:
1. to write debug script for your debugger and stop counters of FlexPWM.
2. to use SW debug and handle in debug exception stopping of FlexPWM counters.
I recommend you to use 1. case as with Lauterbach debugger I will be very simple. However you can use any debugger which supports scripting.
Peter