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

ModusToolbox™ General Forum Discussions

jepaz
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

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
1 Solution
LinglingG_46
Moderator
Moderator
Moderator
10 questions asked 5 questions asked 250 sign-ins

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
LinglingG_46
Moderator
Moderator
Moderator
10 questions asked 5 questions asked 250 sign-ins

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);"

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
LinglingG_46
Moderator
Moderator
Moderator
10 questions asked 5 questions asked 250 sign-ins

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

markgsaunders
Employee
Employee
50 sign-ins 10 solutions authored 5 solutions authored

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);

jepaz
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

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.