cancel
Showing results for 
Search instead for 
Did you mean: 

ModusToolbox General

New Contributor II

Hello Everyone,

I am trying to get a TCPWM configured as a PWM peripheral to drive an external device (for tests I am using an LED)

If I directly trigger the pin value the LED turns on, I cant get the PWM to give me an output signal.

the pin was configured as strong drive no buffer, and the digital output set to match the PWM signal.

this should get it going right?

Cy_TCPWM_PWM_Init( BlinkyPWM_HW, 0UL, &BlinkyPWM_config );

Cy_TCPWM_PWM_Enable( BlinkyPWM_HW, 0UL);

Cy_TCPWM_TriggerStart( BlinkyPWM_HW, BlinkyPWM_CNT_MASK );

I need a PWM configured as one shot to trigger an interrupt when it reaches overflow state.

  

0 Likes
Reply
1 Solution
Moderator
Moderator

Depending on your question description, I write a code example in attachment, the project is based on our code example CE220291.

I use the modus toolbox version 1.0 and CY8CKit-062 to test.

I config the PWM mode: continuous, if you want to use one shot, you can modify it in the configure window.

pastedImage_0.png

CE220291:https://www.cypress.com/documentation/code-examples/ce220291-psoc-6-mcu-tcpwm-square-wave

View solution in original post

5 Replies
Moderator
Moderator

About the modus toolbox TCPWM code example, you can refer to the below linker:

https://www.cypress.com/documentation/code-examples/ce220291-psoc-6-mcu-tcpwm-square-wave

Maybe you should try to replace your API "Cy_TCPWM_PWM_Enable( BlinkyPWM_HW, 0UL);" with " Cy_TCPWM_Enable_Multiple( BlinkyPWM_HW, BlinkyMASK);"

New Contributor II

I think the Problem was with the PWM_MASK, I was using another example that defined the MASK parameter.

now that I am using the one generated it worked right away

thank you

0 Likes
Reply
Moderator
Moderator

Depending on your question description, I write a code example in attachment, the project is based on our code example CE220291.

I use the modus toolbox version 1.0 and CY8CKit-062 to test.

I config the PWM mode: continuous, if you want to use one shot, you can modify it in the configure window.

pastedImage_0.png

CE220291:https://www.cypress.com/documentation/code-examples/ce220291-psoc-6-mcu-tcpwm-square-wave

View solution in original post

Employee

Just wanted to clarify (because the correction is in the zip file but not written in this thread) that the original code was initing the wrong TCPWM block. It's an easy mistake (been there, done that!) but this code is turning on counter 0 instead of 11.

Cy_TCPWM_PWM_Init( BlinkyPWM_HW, 0UL, &BlinkyPWM_config );

Cy_TCPWM_PWM_Enable( BlinkyPWM_HW, 0UL);

The configurator generates a define for you that helps with this:

Cy_TCPWM_PWM_Init( BlinkyPWM_HW, BlinkyPWM_NUM, &BlinkyPWM_config );

Cy_TCPWM_PWM_Enable( BlinkyPWM_HW, BlinkyPWM_NUM);

New Contributor II

Hello Guys,

after the PWM worked, now I am trying to read the current count while its running

it seemed very straight forward

counts=Cy_TCPWM_PWM_GetCounter(PWM_HW,PWM_MASK);

after it was initialized, enabled and triggered the start.

I am using the PWM for three things at once, period sets the maximum time of the signal sent, compare the actual length of the signal and with the counter I could get a rough time value since the signal was triggered.

Top labels