cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

Anonymous
Not applicable

I have a PWM (component "PWM (TCPWM mode)" v2.10) that controls a line output on my CY8C4025LQI-S401). The PWM signal should not always be active. So it is stopped with Stop() and restarted with Start().

While it is stopped the pin should be driven low until the PWM starts again. In fact, it goes High-Z not low. The PWM datasheet actually confirms that. This can be clearly revealed with an external pull-up resistor, that pulls the pin up to a certain level after PWM stop (see measurements attached).

How can drive the line output low while the PWM is not running by software, without connecting an extra pin that drives the pin low externally? The pin is configured as strong drive.

I have tried a lot so far but did not succeed.

Thank you!

0 Likes
Reply
17 Replies
Anonymous
Not applicable

PWM_end_floating.jpg

0 Likes
Reply
HeLi_263931
Honored Contributor II

You can look at the "kill" functionality of the PWM.

0 Likes
Reply
Anonymous
Not applicable

The datasheet says for the Stop signal Event:

The Stop signal event determines the type of action taken when a stop signal is asserted. The stop event will cause a kill operation (line and line_n outputs will go inactive).

So how can I do a kill operation and why should the outputs be active low then?

0 Likes
Reply
HeLi_263931
Honored Contributor II

when the STOP input gets active, the PWM gets stopped, and the output goes to LOW (its inactive state). YOu can do this be connecting the input to a control register, or by using the TriggerCommand API function.

Do not use the _Stop() and _Start() functions, start the component only on startup.

0 Likes
Reply
Anonymous
Not applicable

You mean if I use instead

Start: TCPWM_TriggerCommand(TCPWM_MASK, TCPWM_CMD_START);

Stop: TCPWM_TriggerCommand(TCPWM_MASK, TCPWM_CMD_STOP);

For initialisation I still use the TCPWM_Start() function.

But unfortunately this has no apparent effect on the PWM.

Are the API calls correct? Are the masks wrong?

0 Likes
Reply
HeLi_263931
Honored Contributor II

Reading the API doc, the call seems to be correct. Did you try to use a control register to trigger the STOP condition via an input?

You probably also need to configure the TCPWM to stop the PWM counter on a kill signal (see page 12 in the data sheet)

0 Likes
Reply
Anonymous
Not applicable

Sorry I don't get it by now.

I have tried the TriggerCommand and it has no effect. But it might be only a trigger. Maybe I need to generate another signal to trigger?

I don't know how to use a control Register for an input. I don't have any code examples. Can you help me with this?

I also found this solution in another discussion:

/* Set the CNT_STOP_SEL bits to 0 which selects a logic 0 as Stop input */
TempVal = CY_GET_REG32(CYREG_TCPWM_CNT0_TR_CTRL0);
TempVal &= ~0x0000F000;
CY_SET_REG32(CYREG_TCPWM_CNT0_TR_CTRL0, TempVal);

/* Set the CNT_STOP_SEL bits to 1 which selects a logic 1 as Stop input */
TempVal =CY_GET_REG32(CYREG_TCPWM_CNT0_TR_CTRL0);
TempVal |= 0x00001000;
CY_SET_REG32(CYREG_TCPWM_CNT0_TR_CTRL0, TempVal);

But it is not working either. Thus not driving the output low after stopping.

0 Likes
Reply
HeLi_263931
Honored Contributor II

Add a control register component to your schematic. Set it to 1 bit width. Enable the "Stop" input on your PWM. Draw a wire from the control register output to the Stop input. Use the Control register API to set the signal to 0 or 1.

0 Likes
Reply
Anonymous
Not applicable

I don't have control Registers for my device/Project. So I cannot use them.

0 Likes
Reply
Anonymous
Not applicable

Setting a pin to digital output, and using api calls to control it should work as a replacement for the control register components I think.

0 Likes
Reply
Anonymous
Not applicable

Can you make an example? I don't know these API calls. Not enough documentation...

0 Likes
Reply
Anonymous
Not applicable

I found this: Force PWM Output to "Low level" and “High level” in Traveo™ S6J3110/ 3120/ 3200/ 3300/ 3350/ 3400 Se...

Does anybody knows how to use it? Any documentation of this mask and the API calls? I have found nothing...

0 Likes
Reply
HeLi_263931
Honored Contributor II

This does not apply to the PSoC MCU, its for a completely different device.

Anonymous
Not applicable

I've attached an example that uses a pin to kill the PWM after 20~ seconds, modify it as you want

(I've not tested it, but the general setup is from the example project, and the functionality should be similar to what you want)

0 Likes
Reply
Anonymous
Not applicable

Thank you for the example! Unfortunately it is not working. The PWM output won't stop. It just keeps running... I have no idea...

0 Likes
Reply
Anonymous
Not applicable

Hmmmm; I must have something wrong then

Sorry I don't have much time to test/work on the example, but if you try starting with the PWM example code from the PSoC Creator to build upon, you should get good progress towards your goal

The only tricky thing is if you can successfully get the output to go fully low, or if it will keep going to the floating/high-Z input mode upon killing the PWM...

0 Likes
Reply
Anonymous
Not applicable

Hi everybody

I could solve it with the TriggerCommand of the PWM. I just start the PWM once and then only use this function:

Start: PWM_TriggerCommand(PWM_MASK,PWM_CMD_START);
Stop: PWM_TriggerCommand(PWM_MASK,PWM_CMD_STOP);

When it is stopped like this, the output will be driven low. Just perfect!

I already tested this way earlier but probably used the wrong mask and was not successful. However it's a pitty but I could not find any documentation about PWM settings, registers and masks.

Many thanks to all of you!