Psoc 6 PWM no output waveform

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
gbracht
Level 1
Level 1
10 sign-ins 5 questions asked First reply posted

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:

  // Initialize Buzzer PWM
  cy_en_tcpwm_status_t pwm_status;

  //pwm_status = Cy_TCPWM_PWM_Init(tcpwm_1_cnt_4_HW, tcpwm_1_cnt_4_NUM, &tcpwm_1_cnt_4_config);
  pwm_status = Cy_TCPWM_PWM_Init(tcpwm_1_cnt_4_HW, tcpwm_1_cnt_4_MASK, &tcpwm_1_cnt_4_config);
  if (pwm_status != CY_TCPWM_SUCCESS) {
    CY_ASSERT(0);
  }

  //Cy_TCPWM_PWM_Enable(tcpwm_1_cnt_4_HW, tcpwm_1_cnt_4_NUM);
  Cy_TCPWM_PWM_Enable(tcpwm_1_cnt_4_HW, tcpwm_1_cnt_4_MASK);

  // Initialize PWM output on P12_1
  Cy_GPIO_Pin_FastInit(GPIO_PRT12, 0U, CY_GPIO_DM_STRONG_IN_OFF, 0U, P12_0_TCPWM1_LINE4);
  Cy_GPIO_Pin_FastInit(GPIO_PRT12, 1U, CY_GPIO_DM_STRONG_IN_OFF, 0U, P12_1_TCPWM1_LINE_COMPL4);
0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Andri-setyabudi
Level 5
Level 5
50 likes received 50 sign-ins 25 solutions authored

Hi @gbracht , 

You need to configure the clock - source for TCPWM block. 
I have attached the file as reference. 
This is the result 

Andrisetyabudi_0-1685708278223.png

and for more reference -> MTB-doc 



warm regards,

Andri

View solution in original post

0 Likes
3 Replies
Giraffe1492
Level 5
Level 5
25 sign-ins 25 likes received 10 solutions authored

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:

  1. 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.
  2. 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/promopages/makeradar/makeradar-school/programming-tutorial/
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...

 

0 Likes
lock attach
Attachments are accessible only for community members.
Andri-setyabudi
Level 5
Level 5
50 likes received 50 sign-ins 25 solutions authored

Hi @gbracht , 

You need to configure the clock - source for TCPWM block. 
I have attached the file as reference. 
This is the result 

Andrisetyabudi_0-1685708278223.png

and for more reference -> MTB-doc 



warm regards,

Andri

0 Likes
ADSW
Moderator
Moderator
Moderator
250 sign-ins 50 solutions authored 25 likes received

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, 

0 Likes