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)
Each port has an associated GPIO_PRTx_PC2 register. Individual bits of the register correspond to one of the pins of the port. Setting and unsetting the particular bit can be used for enabling or disabling the input buffer associated with that pin. Disabling the input buffer is one of the methods to disable the input pin.
In this example, you disable the Rx pin of an SCB Component configured as UART. While transmitting data, disabling the pin disables the reception of data as follows:
1. Double-click on the UART Component to open the configuration box and configure the direction as TX+RX as shown in Figure 1. Attach the digital input pin (RX) to rx_in of the Component.
Figure 1. Configurator Settings for the UART Component
2. Look for the UART_RX pin of the device being used. In this case, you have used P3. To disable the input buffer, you need to clear Bit 0 of the GPIO_PRT3_PC2 register. Figure 2 shows the functionality of different bits of GPIO_PRTx_PC2.
Figure 2. Functionality of Different Bits of the GPIO_PRTx_PC2 Register
3. Disable the input buffer of the UART_RX pin during runtime by clearing Bit 0 of Port 3 in firmware using the following code:
uint32 temp_reg_val; // initialize a variable.
temp_reg_val = CY_GET_REG32(CYREG_GPIO_PRT3_PC2); // to disable the input buffer OF P3, RX_PC2 is used.
uint32 temp_reg_original = temp_reg_val; // storing the initial value of register.
temp_reg_val = temp_reg_val | (0x01<<RX_SHIFT); // disabling the PIN 3 which is the RX pin for UART.
// RX_SHIFT corresponds to the pin number(here, pin 0) of port.
CY_SET_REG32(CYREG_GPIO_PRT3_PC2, temp_reg_val); // setting the register with disable condition for RX pin.
4. Enable the input buffer by loading the GPIO_PRT3_PC2 register with its initial value as follows:
CY_SET_REG32(CYREG_GPIO_PRT3_PC2, temp_reg_original); //restoring the original value of register.
Figure 3 shows the detailed code snippet.
Figure 3. Code snippet to disable and enable a pin in firmware