- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I've been trying to get the pwm function my Psoc6 board to drive a buzzer at 4kHz but have been unable to do so. I already tried the example give here: https://community.infineon.com/t5/ModusToolbox-General/Modus-PSoC6-TCPWM-PWM-output/td-p/70325
After I was unable to get that to work I tried with the pdl library as well. I have inserted a code snippet below. I am using the Cy_TCPWM_TriggerStart and Cy_TCPWM_TriggerStop functions to start and stop the pulse generation but I am not getting any output from P12_0 or P12_1.
So I have a couple of questions:
1) After looking through the code below, are there any obvious mistakes that I made in the initialization of the pwm obj and gpio pins?
2) Is it a problem to call the start function more than once without calling stop in between?
Code Snippet:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From the code snippet you provided, it seems that you have initialized the PWM and GPIO pins correctly. However, I noticed that you have not started the PWM. To start the PWM, you need to call the Cy_TCPWM_TriggerStart function after enabling the PWM. Add the following line of code after enabling the PWM:
Cy_TCPWM_TriggerStart(tcpwm_1_cnt_4_HW, tcpwm_1_cnt_4_MASK);
To answer your questions:
- There are no obvious mistakes in the initialization of the PWM object and GPIO pins based on the code provided. Just make sure to start the PWM as mentioned above.
- It is not recommended to call the start function more than once without calling stop in between. If you need to restart the PWM, make sure to call the stop function before starting it again.
If you still face issues, please double-check the hardware connections and ensure that the buzzer is connected to the correct pins (P12_0 and P12_1).
https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-a...
https://www.infineon.com/cms/en/product/microcontroller/?redirId=54599#collapse-d60188f4-2a69-11ec-b...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @gbracht ,
Are you still working on this thread ?
If you still facing some issues, please don't hesitate to let us know.
Warm regards,