But why do you want to do that? The data sheet explicitly recommends to call only PWM_Start() instead of Init() and Enable()...
A call to the PWM_Start() function will automatically call the PWM_Init() and PWM_Enable() functions (as the case with most of the PSoC components). So, in most of the cases, there is no need to call them again.
Well, the problem is that with this implementation you cannot configure the PWM in software before actually starting the PWM. Any configurations that you do will be overwritten by PWM_Init() called from within PWM_Start().
For example, using the setup below, the following piece of code won't have the desired effect, which is making the RGB LED emit orange light:
- 2 PWMs driving the two LED pins on the PSoC 4 Pioneer board
- Both PWMs have period=255, and compare=0
PWM_LED_Red_WriteCompare(128u); PWM_LED_Red_Start(); PWM_LED_Green_Start(); CyDelay(1000); PWM_LED_Red_Stop(); PWM_LED_Green_Stop();
When you run this code, the PWMs will output 'low' (and thus the pins go 'high') for the entire period. The LED will emit yellow light.
You could of course fix it by writing:
PWM_LED_Red_Start(); PWM_LED_Red_WriteCompare(128u); PWM_LED_Green_Start(); CyDelay(1000); PWM_LED_Red_Stop(); PWM_LED_Green_Stop();
Personally, I find this very unintuitive…
So instead of using the default values configured in the component dialog, you want to set them via the API? Is there a reason for that?
In that case, you in fact need to call Init() and Enable() on your own. Maybe you can send a request to Cypress to somehow provide this capability, or at least explain (in the data sheet or an AppNote) how to do this properly.
This is actually desired and correct behavior.
See page 16 of the datasheet:
Basically, if you call start, stop, change settings and start again it will not overwrite your settings. That said the first time start is called, it is expected the settings in the customizer are correct.
This is true with other components such as UART.