MPC5748G project can only run in single-step mode while debugging but not in full-speed mode

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

MPC5748G project can only run in single-step mode while debugging but not in full-speed mode

跳至解决方案
1,539 次查看
mahoneinsh
Contributor I

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

mahoneinsh_0-1663406803675.png

Figure2. Single-step running result (different phases)

mahoneinsh_2-1663406881932.jpeg

Figure3. full-speed running

mahoneinsh_3-1663406984818.png

Figure4. full-speed running result (same phases)

mahoneinsh_4-1663407017970.jpeg

(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

0 项奖励
回复
1 解答
1,442 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

here is the reason:

lukaszadrapa_0-1663684140760.png

 The FRZ/FREN take effect only in debug mode:

lukaszadrapa_1-1663684462572.png

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

 

在原帖中查看解决方案

0 项奖励
回复
6 回复数
1,513 次查看
mahoneinsh
Contributor I

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);

0 项奖励
回复
1,443 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

here is the reason:

lukaszadrapa_0-1663684140760.png

 The FRZ/FREN take effect only in debug mode:

lukaszadrapa_1-1663684462572.png

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

 

0 项奖励
回复
1,427 次查看
mahoneinsh
Contributor I

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. 

mahoneinsh_0-1663726545796.png

mahoneinsh_1-1663726742825.png

 

 

0 项奖励
回复
1,435 次查看
mahoneinsh
Contributor I

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~

0 项奖励
回复
1,419 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

0 项奖励
回复
1,407 次查看
mahoneinsh
Contributor I

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

0 项奖励
回复