Dear NXP supporter:
Development enviroment of the project is:S32DS_Power_v2017.R1, PE multilink universal
Simple function introduction: Using eMIOS module to generate 2 PWM waveforms with different intial phase(0°,180°). So i wrote a function to change related registers as below:
void EMIOS_ResetUCCnt(void)
{
eMIOS_MCR_SET_FRZ(INST_EMIOS0_MC,1);
REG_WRITE32(&eMIOS[0]->UC[PWM1_eMIOS_CHN].CNT,0);
REG_WRITE32(&eMIOS[0]->UC[PWM2_eMIOS_CHN].CNT,500);
eMIOS_MCR_SET_FRZ(INST_EMIOS0_MC,0);
}
Description of the problems encounterred in my project:
(1) If the above function "EMIOS_ResetUCCnt()" is executed by single-step in debugging mode, the 2 PWM pulses output successfully with different phase. But run it at full-speed without breakpoint, the PWM fail to change their phases.
Figure1. Single-step running
Figure2. Single-step running result (different phases)
Figure3. full-speed running
Figure4. full-speed running result (same phases)
(2) If preprocessors related to second core(DEBUG_SECONDARY_CORES、TURN_ON_CPU1) is added to the project, and run it at full-speed mode, the PWM output is correct(figure 2).
(3) Base on step (2), the rountine ran successfully in debugging mode, but then stopped debugging mode and restarted the board, the PWM output is wrong(figure 4).
From my understanding, the root reason of the problems is :
whether function "EMIOS_ResetUCCnt()" is successfully executed or not. why preprocessors of second core affects the first core.
Could you please give me some hint? thank you in advance.
The project program is attached below.
Thank you again~
@ lukaszadrapa
Solved! Go to Solution.
Hi,
here is the reason:
The FRZ/FREN take effect only in debug mode:
If you single step over these commands, the device is in debug mode. But if you click on Run button, it's not considered as debug mode.
Regards
Lukas
I've made some further tests, found that:
the following 2 instructions must be ran by single-step, or it will fail to modify the corresponding registers.
REG_WRITE32(&eMIOS[0]->UC[PWM1_eMIOS_CHN].CNT,0);
REG_WRITE32(&eMIOS[0]->UC[PWM2_eMIOS_CHN].CNT,500);
Hi,
here is the reason:
The FRZ/FREN take effect only in debug mode:
If you single step over these commands, the device is in debug mode. But if you click on Run button, it's not considered as debug mode.
Regards
Lukas
I‘ve print the DBG_MODE bit of MC_ME->GS register which indicates whether the chip is in debug mode, found that chip was in normal mode while debugging.
lucas,
Thank you for your reply~
So, is it achievable to enter debug mode by software when running in normal mode? Could you give me some reference? Thank you~
No, that's not possible. And as the description suggests, it's not expected use case to modify the CNT in this way. It's possible to do that in debug mode for debug purposes but not in runtime.
Regards,
Lukas
Lucas,
Thank you very much~
Your comments are really helpful for me. I've verified that chip goes into debug mode with debugger. Maybe i should find another way to realize the expected function.
Regard,
Mahone