Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Using USB pins as GPIO in PSoC™ 6 MCU - KBA233923

Using USB pins as GPIO in PSoC™ 6 MCU - KBA233923

ArunKumarChoul
Employee
Employee
50 questions asked 50 sign-ins 25 sign-ins

Version: **

PSoC™ 6 MCU devices with USB support have dedicated pins for the D+ and D- USB lines (pins P14[0] and P14[1]). If the USB functionality is not required in your application, you can use these pins as regular GPIOs. When configured as GPIO, USB pins do not support drive modes other than CMOS_OUT (Strong drive) and HI_Z_ANALOG (High Impedance Analog)

Do the following to use the USB pins as GPIO:

  1. Set the IOMODE bit of the USBDEV_USBIO_CR1 register HIGH for GPIO functionality and LOW for USB operation.
  2. Set he GPIO drive mode for DM/DP I/O pad by configuring the DM_M and DM_P bits of the USBFS0_USBLPM_USBIO_CTL register.
    0x0: OFF: Mode 0: Output buffer off (High-Z). Input buffer off.
    0x1: INPUT: Mode 1: Output buffer off (High-Z). Input buffer on.
    Other values are not supported.

Use the following code snippet to configure the USB pins as GPIO:

/*Set USBIO to GPIO mode*/

*(uint32 *) CYREG_USBFS0_USBDEV_USBIO_CR1 |= (0x01u << CYFLD_USBFS_USBDEV_IOMODE__OFFSET);

/* Set GPIO input enable */

*(uint32 *) CYREG_USBFS0_USBLPM_USBIO_CTL |= ((0x01u << CYFLD_USBFS_USBLPM_DM_P__OFFSET) |(0x01u << CYFLD_USBFS_USBLPM_DM_M__OFFSET));

See the registers TRM of the respective PSoC™ 6 MCU device.

0 Likes
471 Views