Controlling Port Pins | Cypress Semiconductor
Support & Community
Controlling Port Pins
Can I directly control a GPIO in C?
Yes, you can do this. The GPIO pins are controlled by various registers.
Data Register: The state of a GPIO can be controlled / read by writing / reading the PRTxDR register. For example to make P1 HIGH, Bit5 of PRT1DR should be set.
Drive Mode Registers: There are three drive mode registers for each port that control the drive mode of the pins in a particular port. These are the PRTxDM0, PRTxDM1 and PRTxDM2 registers. The combination of the bits of these three registers decide the drive mode of a particular pin. For example, the drive mode of P2 will be decided the combination of Bit3 of PRT2DM0, PRT2DM1 and PRT2DM2 registers. Details can be found in the Technical Reference Manual.
Global Select register: The PRTxGS register decides if a GPIO pin is under the control of the CPU or is connected to the Global In or Global Out bus. When the bit in PRTxGS register is cleared, the pin can be controlled by the CPU by writing to the PRTxDR register. When the bit in PRTxGS register is set, the pin is connected to the Global bus and connects to the internal hardware blocks.
Interrupt Control Registers: PRTxIE, PRTxIC0 and PRTxIC1 are registers that control the interrupt mode of a GPIO pin.
For more details on GPIO, you can read the following post of PSoC Hacker.