Part Number: TMS320F28379D
Hello,
I am currently in the process of implementing the possibility of only firing a single PWM pulse when a specific command is send from a MATLAB GUI. Before and after the command the PWM unit should output 0. For that a trip zone event is forced, in which the output of the EPWM is forced low. In order to detect the single pulse, I want to utilize an EPWM interrupt, that detects when the CMPA counter is decrementing. I verified that this interrupt is indeed being triggered and also at the correct position. However when I start the EPWM, so when I clear the trip zone flag, I always receive two unexpected triggers of the interrupt. For testing purposes I always toggle a GPIO pin, which is the yellow line in the picture below. The blue line is the pulse. As you can see after the first two unexpected triggers of the interrupt, the interrupt then is triggered always at the falling edge of the pulse, which is correct. For now I uncommented the force trip zone event in the interrupt, so the EPWM is never forced low by the interrupt, as I first want to understand why the interrupt is unexpectedly triggered. Below you can also find my code.
In menu.c the specific commands are called when starting the PWM unit. Before starting the EPWM, the cases PWMFREQ and PWMDUTY are triggered in the switch statement, after that RUNPWMSINGLE is called. The corresponding function calls as well as the interrupt implementation can be found in pwm.c. Note that I only use EPWM1, so all other initializations of the other EPWM units can be ignored. I initially thought that the the two while loops in the runPWMSINGLE function may cause the problem, however when removing these from the code, the behavior regarding the interrupt is still the same.
I also attached the Matlab GUI that sends all the commands. You may have to adjust the COM-Port for your system. You first have to flash the code to the C2000, after that start the Matlab script, press the connect button enter the desired frequency/duty cycle and click start. Pressing start again terminates the EPWM.
Thank you very much for your help.
Best Nikitadelfino_cpu1.zip
