Dear Sir,
I use MC56F82748 of eFlexPWM.
The parameters of the VAL 4,5 for the eFlexPWM model are somewhat different from my knowledge.
I will ask you about it.
Below is my setting,
And SM1INIT and SM2INIT value same as 0.
The following waveforms SM1, VAL2=20, VAL3=803, VAL4=863, VAL5=1635
PWMA works normally. but PWMB VAL4 is high with VAL2 at the same time, and when count to 863 then PWM did not change to low.
SM2's VAL1 is filled with 0x681, VAL4 is filled with 0x600, and VAL5 is filled with 0x610.
SM2 PWMB issue is same as SM1.
Thanks,
BR
Kris
Hi, Kris,
I think there is issue for the following code:
for(;;)
{
//FMSTR1_Poll();
if(switch_flag==0){
setReg16(PWMA_SM2VAL5, 0x600);
switch_flag=1;
}
/* load new values to PWM registers */
setReg16Bits(PWMA_MCTRL, PWM_MCTRL_LDOK(1)); /* LDOK,load enable */
}
you can NOT write any peripheral register in a for loop, as you know that the core writes a peripheral register with about 50MHz speed if you write code in this way.
You can enable reload interrupt, in the reload ISR, you can update the eFlexPWM register so that the PWM cycle changes for every cycle.
Hope it can help you
BR
Xiangjun Rong
Hi Xiangjun
Sorry, Maybe I deleted too many things and caused your misunderstanding.
In my project, I follow the DRM172 to doing PWM update.
https://www.nxp.com/docs/en/reference-manual/DRM172.pdf
As below picture, reload PWM value when SM0 counter over.
I move the "setReg16Bits(PWMA_MCTRL, PWM_MCTRL_LDOK(1)); /* LDOK,load enable */ " into the PWM ISR.
It's still have same issue.
As you said, I follow you enable reload interrupt, in the reload ISR, still have issue.
Hello kris ke, can you please check if you attached the same project which you are discussing in question, as i checked i found different values and setting of PWM in your attached file.
Kamil
Hi Kamil
The PWM values different than the my question it is not affect the issue of PWM. I removed the extra content from my project and narrowed it down to reproduce the issue.
If you stop in Step 1, And set switch_flag to a value other than 1. The PWM_SM2VAL0 = 0, PWM_SM2VAL1=0x683, PWM_SM2VAL4=0x38c, PWMA_SM2VAL5=19.
And the PWM SM2VAL45 will work normal.
If you let it normal run, then the The PWM_SM2VAL0 = 0, PWM_SM2VAL1=0x683, PWM_SM2VAL4=0x38c, PWMA_SM2VAL5=0x600.
It will reproduce my issue.
Kris
Hello Kris Ke, did you get a chance to test xiangjun rong code?
Hi, Kris,
It appears that the PWM waveform of SM1_VAL45 does not match with the register configuration, pls post your project so that we can have a review and test.
BR
Xiangjun Rong
Hello kris ke, are you getting same issue with SM0, and SM2 module, can meanwhile can you please share your code which you are testing, as well as schematic around MCU.
With Regards
Kamil