Question: How do you dynamically connect or disconnect a GPIO from a digital block in PSoC® 1 - for example, a PWM?
The GPIO can be connected or disconnected from a digital block using the PRTxGS register that controls the connection to the global in/out bus. Writing a 1 to the corresponding bit in this register connects the GPIO to global input or global output net. Based on the drive mode of the pin, the input/output direction is controlled. If the corresponding bit in the PRTxGS register is written a 0, the GPIO is disconnected from global in/out net and the pin is controlled by CPU using PRTxDR register.
For example, consider the device editor configuration in Figure 1.
In Figure 1, the PWM digital block’s CompareOut output connects to Port_0_0 through the Row_0_Output_0 and the GlobalOutEven_0. In firmware, Port_0_0 can be dynamically disconnected or connected to the GlobalOutEven_0 as follows:
PRT0GS &= ~ 0x01; // Disconnect Port_0_0 from the GlobalOutEven_0
PRT0GS |= 0x01; // Connect Port_0_0 to the GlobalOutEven_0