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 everyone,
I'm encountering a problem with HRPWM similar to the one mentioned in this topic. I have seen it occur both on TMS320F28035 (ePWM Type 1) and TMS320F28075 (ePwm Type 4).
The problem manifests itself as an unwanted glitch on the PWM output. In the actual application I use many peripherals such as the ADC, ECAP, ECAN, SPI, CPU timers and interrupts, CLA, etc. but I took some time to find the smallest possible code which allows me to reproduce the problem, which seems to only involve the ePWM peripherals.
The oscilloscope screenshot below shows the glitch. It is achieved with a small program running on the TMS320F28035 controlCARD.
The yellow signal is EPWM1A on GPIO0. The blue signal is a reference signal generated using EPWM2A with edges configured for events CTR=PRD and CTR=ZRO.
First a few notes on things I have tried:
The code used to reproduce the problem is the following:
EALLOW; SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1; SysCtrlRegs.PCLKCR0.bit.HRPWMENCLK = 1; EPwm1Regs.TBCTL.bit.CTRMODE = 2; EPwm1Regs.AQCTLA.bit.CAU = 1; EPwm1Regs.AQCTLA.bit.CAD = 2; EPwm1Regs.TBPRD = 200; EPwm1Regs.CMPA.half.CMPA = 50; EPwm1Regs.CMPCTL.bit.LOADAMODE = 1; // load on CTR = PRD EPwm1Regs.HRPWR.bit.MEPOFF = 0; EPwm1Regs.HRCNFG.bit.EDGMODE = 2; EPwm1Regs.HRCNFG.bit.HRLOAD = 1; // load on CTR = PRD GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; EDIS; for (;;) { DELAY_US(10); EPwm1Regs.CMPA.half.CMPAHR = 0; DELAY_US(10); EPwm1Regs.CMPA.half.CMPAHR = (200U << 8); }
All this program does is switch CMPAHR between zero and a non-zero value.
The problem only seems to appear when the ePWM is running in up-down count (TBCTL[CTRMODE] = 2) AND the micro-edge position logic controls the falling edge (HRCNFG[EDGMODE] = 2) AND the CMPAHR load event is programmed outside of the pulse (when the PWM signal is at 0).
This last condition is because I have seen the problem in two configurations:
Furthermore the width of the glitch seems to be related to the value of CMPAHR, as shown by the two pictures below. The first one is with CMPAHR set to 130 steps and the second one with CMPAHR set to 230 steps.
That is all the information I have for now, but if you need to know anything else please let me know.
Cheers,
Pierre
Pierre, I would like to look into this. Can you send the CCS project so I have everything matching your setup?
Nima
Hi Nima,
I tried with the following configuration:
EPwm1Regs.TBCTL.bit.CTRMODE = 2; EPwm1Regs.AQCTLA.bit.CAU = 1; EPwm1Regs.AQCTLA.bit.CAD = 2; EPwm1Regs.TBPRD = 200; EPwm1Regs.CMPA.half.CMPA = 50; EPwm1Regs.CMPCTL.bit.LOADAMODE = 0; // load on CTR = ZRO EPwm1Regs.HRPWR.bit.MEPOFF = 0; EPwm1Regs.HRCNFG.bit.EDGMODE = 2; EPwm1Regs.HRCNFG.bit.HRLOAD = 0; // load on CTR = ZRO
The result is that there is no glitch.
On the other hand the next configuration results in the glitch appearing:
EPwm1Regs.TBCTL.bit.CTRMODE = 2; EPwm1Regs.AQCTLA.bit.CAU = 1; EPwm1Regs.AQCTLA.bit.CAD = 2; EPwm1Regs.TBPRD = 200; EPwm1Regs.CMPA.half.CMPA = 50; EPwm1Regs.CMPCTL.bit.LOADAMODE = 0; // load on CTR = ZRO EPwm1Regs.HRPWR.bit.MEPOFF = 0; EPwm1Regs.HRCNFG.bit.EDGMODE = 2; EPwm1Regs.HRCNFG.bit.HRLOAD = 1; // load on CTR = PRD
Nima,
Please see the following table summarizing the different behaviours I can observe on my F28035 controlCARD.
AQCTLA[CAU]/AQCTLA[CAD] | CMPCTL[LOADAMODE] | HRCNFG[HRLOAD] | Observed behaviour |
Clear (1) / Set (2) | Load on CTR = PRD (1) | Load on CTR = PRD (1) | ANOMALY |
Clear (1) / Set (2) | Load on CTR = PRD (1) | Load on CTR = ZRO (0) | ok |
Clear (1) / Set (2) | Load on CTR = ZRO (0) | Load on CTR = PRD (1) | ANOMALY |
Clear (1) / Set (2) | Load on CTR = ZRO (0) | Load on CTR = ZRO (0) | ok |
Set (2) / Clear (1) | Load on CTR = PRD (1) | Load on CTR = PRD (1) | ok |
Set (2) / Clear (1) | Load on CTR = PRD (1) | Load on CTR = ZRO (0) | ANOMALY |
Set (2) / Clear (1) | Load on CTR = ZRO (0) | Load on CTR = PRD (1) | ok |
Set (2) / Clear (1) | Load on CTR = ZRO (0) | Load on CTR = ZRO (0) | ANOMALY |
Were you able to reproduce this?
Cheers,
Pierre
Yes I have tried some of the conditions and I do the see the unwanted pulse. For now could you continue your work with one of the working conditions while I investigate the issue? I suspect this is a know condition which could be documented.
Nima,
Yes I have been using one of the working conditions as a workaround for some time now.
These unwanted pulses can cause a lot of damage when they induce cross-conduction.
Regards,
Pierre
Can you try something and let me know what results you get?
Can you set the rest of the actions? For example when they are not needed, set them to no action or to the actual state they need to be.
// Action qualifier register bit definitions */ AQCTL ZRO // 1:0 Action Counter = Zero PRD // 3:2 Action Counter = Period CAU // 5:4 Action Counter = Compare A up CAD // 7:6 Action Counter = Compare A down CBU // 9:8 Action Counter = Compare B up CBD // 11:10 Action Counter = Compare B down
Mainly i'm concerned with ZRO AND PRD. Try setting those to no action or PULL high or low when needed.
Nima,
I've been using the HRPWM for six years, I know that datasheet very well. Please pay attention to my first message:
I am going to run the code I sent you with the autoconv and SFO and send you oscilloscope pictures so you can see for yourself.
Pierre
Nima,
Cheers,
Pierre
Pierre,
I'm confused. I tried the code you sent me with AUTOCONV enabled and the anomoly was not present. I'm gonna try again and share the results.
Nima
Yes here is the code with AUTOCONV and the screenshot of the scope without the anomaly.
void main(void) { initClock(); initFlash(); __eallow(); SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1; SysCtrlRegs.PCLKCR0.bit.HRPWMENCLK = 1; EPwm1Regs.TBCTL.bit.CTRMODE = 2; EPwm1Regs.AQCTLA.bit.CAU = 1; EPwm1Regs.AQCTLA.bit.CAD = 2; EPwm1Regs.TBPRD = 200; EPwm1Regs.CMPA.half.CMPA = 50; EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0; // Shadow mode EPwm1Regs.CMPCTL.bit.LOADAMODE = 2; // load on CTR = PRD EPwm1Regs.HRPWR.bit.MEPOFF = 0; EPwm1Regs.HRCNFG.bit.EDGMODE = 2; EPwm1Regs.HRCNFG.bit.AUTOCONV = 1; EPwm1Regs.HRCNFG.bit.HRLOAD = 1; // load on CTR = PRD GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; __edis(); for (;;) { DELAY_US(10); EPwm1Regs.CMPA.half.CMPAHR = 0; DELAY_US(10); EPwm1Regs.CMPA.half.CMPAHR = (220U << 8); } }
I have also take out the AUTOCON to show how the issue is caused by not using AUTOCONV nor the MEP_SFO library.
Nima,
When I explained my problem you asked me to send you my CCS project, which I did. If you think you have demonstrated that the anomaly has disappeared then please send me your whole project, not just a code snippet.
Until now I'm still convinced that the anomaly occurs even with the AUTOCONV enabled. I'm beginning to suspect that maybe there are difference between our setups. Which part are using? Is it a TMS320F28035 ? If yes is it on a controlCARD ? Are you running the exact code I sent you or did you write your own CCS project?
Furthermore what is the bandwidth of your oscilloscope?
Pierre
Pierre,
I have attached the CCS project. autoconv.zip
I am using a F28035 control card on a docking station.I'm using a 100MHz, 1GSamples/s scope.
Thanks! I'll try it again tomorrow. I have basically the same hardware as you.
Pierre
Pierre,
What frequency is the device running at? Also the EPWMCLK?
Here is what I was looking at in the lab:
1. We have to keep the CMPAHR value below the maximum number of MEP steps per coarse step (Not using auto-convert )
2. When we are in Up-down mode, the HRPWM load must occur on both CTR=0 and PRD.
When I use values below 115 for CMPAHR I see that the anomaly doesn't happen.
I'm going to ask our systems team to help with this. Because I believe the number of MEP steps is much larger than 115 so we should be able to use larger values.
Hello Pierre,
I just went through this post and I believe I have an explanation and a solution (although you've already found/implemented it).
The key piece in your configuration is that HR edge control is only applied to the falling edge (EDGMODE = 2).
When AQ settings 'Set' the output on a CAD match and reset the outputs on a 'CAU' match, the falling edge occurs when the counter is counting up. As a result the HRLOAD should be configured to load on 0. I would also select LOADAMODE = 0 to keep all values synchronized for that cycle, but this is not a necessary condition.
Similarly, when AQ settings 'Set' the output on a CAU match and reset the outputs on a 'CAD' match, the falling edge occurs when the counter is counting down. As a result the HRLOAD should be configured to load on PRD. LOADAMODE could be PRD or 0 based on your control requirements.
HRLOAD should be selected to load on both 0 or PRD, when HR edge control is applied to both rising and falling edges (EDGMODE = 3).
I hope this helps.
Hrishi
Hello Hrishi,
Indeed I try to keep the values synchronized because it seems logical to have CMPA and CMPAHR updated at the same time.
However in this case it's precisely how the anomaly appears: as soon as I try to synchronize the values it shows up.
The workaround I have been applying, i.e not synchronizing the values, allows me to have something that works. The update of CMPA needs to occur before the next rising edge whereas the update of CMPAHR only needs to occur before the next falling edge.
I still have no idea why the anomaly occurs but I think your message is a confirmation that my workaround should be effective. Could you take a look at the diagram attached to this message and confirm my understanding is correct?
Cheers,
Pierre