- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Greetings!
Using the PSOC 6 Pioneer kit (PSOC 62 processor).
I have two PWM blocks that share the same clock source. Is there a way to create a phase shift, so that the two PWM outputs are synchronized, with a constant phase shift between them?
In other words, they are the exact same frequency and duty cycle, but one would be a delayed output of the other?
Solved! Go to Solution.
- Tags:
- pwm module
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi RiTa_288331
Cy_TCPWM_TriggerStart API is intended to trigger one or more TCPWMs at once.
So, to implement needed by you functionality, I used this API, but changed starting counter value for one of PWMs:
uint32_t PHASE_SHIFT = 20;
(void)Cy_TCPWM_PWM_Init(pwm_1_HW, pwm_1_NUM, &pwm_1_config);
(void)Cy_TCPWM_PWM_Init(pwm_2_HW, pwm_2_NUM, &pwm_2_config);
Cy_TCPWM_PWM_Enable(pwm_1_HW, pwm_1_NUM);
Cy_TCPWM_PWM_Enable(pwm_2_HW, pwm_2_NUM);
Cy_TCPWM_PWM_SetCounter(pwm_1_HW, pwm_1_NUM, PHASE_SHIFT);
/* pwm_1 and pwm_2 should belong to same TCPWM block group (TCPWM0 or TCPWM1) */
Cy_TCPWM_TriggerStart(pwm_1_HW, pwm_1_MASK | pwm_2_MASK);
Here is how it look like on logical analyzer for waveform with 25% duty cycle:
Good luck with development on PSoC!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RiTa,
Consult the PWM datasheet. It indicates how to link multiple PWMs together to be synchronized.
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi RiTa_288331
Cy_TCPWM_TriggerStart API is intended to trigger one or more TCPWMs at once.
So, to implement needed by you functionality, I used this API, but changed starting counter value for one of PWMs:
uint32_t PHASE_SHIFT = 20;
(void)Cy_TCPWM_PWM_Init(pwm_1_HW, pwm_1_NUM, &pwm_1_config);
(void)Cy_TCPWM_PWM_Init(pwm_2_HW, pwm_2_NUM, &pwm_2_config);
Cy_TCPWM_PWM_Enable(pwm_1_HW, pwm_1_NUM);
Cy_TCPWM_PWM_Enable(pwm_2_HW, pwm_2_NUM);
Cy_TCPWM_PWM_SetCounter(pwm_1_HW, pwm_1_NUM, PHASE_SHIFT);
/* pwm_1 and pwm_2 should belong to same TCPWM block group (TCPWM0 or TCPWM1) */
Cy_TCPWM_TriggerStart(pwm_1_HW, pwm_1_MASK | pwm_2_MASK);
Here is how it look like on logical analyzer for waveform with 25% duty cycle:
Good luck with development on PSoC!