Control GPIO Output After Stopping the PWM - KBA218991

Version: **

 

Question:

How do I control the GPIO output after stopping the PWM?

 

Answer:

Once the GPIO is connected to the PWM, it cannot be directly controlled by the firmware because when the Pin connects to the PWM “line”, the HSIOM4A register is changed automatically. Thus, you cannot use the firmware Pin_1_Write(0); or Pin_1_Write(1); to control the GPIO output level.

 

If it is necessary to control the GPIO output, change the inner connection by changing the HSIOM4A register manually. The project schematic of an example project attached with this article is shown in Figure 1.

 

Figure 1. Project Schematic

1.pngThis project uses Port 0_Pin 2 as Pin_1. The following code is used to modify the HSIOM_PORT_SEL0 register.

 

"CY_SET_REG32(CYREG_HSIOM_PORT_SEL0, CY_GET_REG32(CYREG_HSIOM_PORT_SEL0)&(~Pin_1__0__HSIOM_MASK));"

 

Pin_1 will be configured as a GPIO. Refer to PSoC4 Register TRM for details.