Use FTM to output PWM, and call the SDK library function FTM_DRV_UpdatePwmPeriod() to adjust the PWM period. May I ask if several channels within the same FTM can be set to different periods? Can the output period of PWM be greater than 20ms within a 20ms polling task?
Hi@LzdOo
1.Channels under the same FTM instance can be set with different duty cycles, but cannot be set with different frequencies.
2. I don't see any relations between 20ms task and 20ms duty cycle.
Hi Senlent
I attempted to set a 20Hz (50ms) PWM output within a 20ms task, but the actual output was 50Hz (20ms); however, it was successfully set within a 50ms task. Could you please explain what the reason is?
Hi@LzdOo
Could you please share your test project, so that i can help you to find the reason why.
Hi, Senlent
This is my Demo project.
Hi, Senlent
Your routine performs the delay within the "while" loop. However, the question I initially raised was:
In the task scheduling of FreeRTOS, a 20ms task can execute a PWM output with a cycle of 20ms, but cannot execute a PWM output with a cycle of 50ms.
Furthermore, my entire project has at least four periodic tasks, such as 1ms, 5ms, 10ms, and 20ms, and each task performs a different function.
Returning to the original question, can a 50ms PWM output be executed within a 20ms task? Is it understood that the MOD register is re-assigned every 20ms, and when I set the MOD value to 50ms within the 20ms task, it is not possible to achieve a 50ms PWM output in time and is interrupted by the next 20ms task? The effect is that although a 50ms setting was made, it still outputs at a 20ms frequency?
Hi@LzdOo
Please provide your new project so I can test and modify it. I cannot open your previous project.
Hi@LzdOo
Provide the complete project, no screenshots.