Hi DA HEON HONG,
I understand from your query that you are trying to generate PWM using the "ePWM" block of the "C2000 Microcontroller Blockset" library with the same time period as the sampling period of the "Solver" in Simulink, where no output is found from the "ePWM" pin of the F280049C board.
In this case, please know that generating the sawtooth carrier signal with the same period as the sampling period of the "Solver" is possible due to the following reasons:
- When the model with the "ePWM" block is built using "Embedded Coder", it goes through code generation, which is dumped into the microcontroller board in machine level form. So, it does not depend on the solver to take the next discrete step in time.
- When the code is dumped into the microcontroller, it runs in a continuous mode, which does not depend on the discrete steps of the solver.
However, you can generate a PWM of the desired frequency or period using the following steps:
- Define the "Timer period" of the "ePWM" block using the following formula to find the sawtooth ("Up" or "Down" count in this case) carrier signal in "Clock cycles"
"Timerperiod= F_clk/F_des
Here, F_clk = Clock frequency of the microcontroller,
F_des= Desired frequency of PWM
- The reference value to which the sawtooth pulse is compared needs to be defined in the block. You can define it by filling in the "CMPA units" field in "Clock cycles" or "Percentage" and providing the value in the "CMPA value" field to define the pulse width of the PWM.
- Set the logic of comparison in the "ePWMA" tab of the "ePWM" block.
- Connect the appropriate "ePWM" pin with the measurement device.
For more information on the "ePWM" block, please refer to the following MathWorks documentation link:
Hope this answers your query.