Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
Connect/Disconnect GPIO to/from Digital Block - KBA90265
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.
Figure 1. PWM Connection to GPIO
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