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.
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?
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.
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?
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)
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:
But it is not working either. Thus not driving the output low after stopping.
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.
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.
Does anybody knows how to use it? Any documentation of this mask and the API calls? I have found nothing...
Thank you for the example! Unfortunately it is not working. The PWM output won't stop. It just keeps running... I have no idea...
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...
I could solve it with the TriggerCommand of the PWM. I just start the PWM once and then only use this function:
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!