- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using the CY8C6347BZI-BLD54 and want to configure USBDM (AKA PORT14_PIN1) as a digital input.
I attempt to do this with the Cy_GPIO_Pin_FastInit() function. However, no matter the logical state of the pin, the Cy_GPIO_Read() function always returns 0.
I expect the following to light an LED, but it is not:
int main(void) {
Cy_GPIO_Pin_FastInit( GPIO_PRT14, 1, CY_GPIO_DM_HIGHZ, 1, HSIOM_SEL_GPIO );
for(;;)
{
if(Cy_GPIO_Read(EXT_GPIO5_PORT, EXT_GPIO5_NUM) == 1UL) {
// Light LED
}
}
}
Does anyone know why this wouldn't be functioning as I expect?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Below two registers should be configured to enable use USBIO as GPIO input pin.
/*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));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
When I tried with PSoC Creator at first I got following error.
It seems that USBDM can be either CMOS_OUTPUT or HI_Z_ANALOG.
So I changed the pin to Hi-Z analog.
Since it's an analog input, I think that we need some trick to make it readable from the digital side.
So how about trying something like below?
(I have not tested it as I don't have a board with this MCU)
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply moto.
I'm using PSoC Creator 4.3.0.1445 and those errors don't appear for me.
I'm happy to post my project too, if that is helpful and allowed on these forums.
The MCU has all other pins accounted for in our product, so using a USB pin as a GPIO Input would be a quick fix to a problem we are having.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm sorry for my insufficient description.
I'm also using PSoC Creator 4.3 (4.3.0.1445).
First of all, I got the error when I set the pin as "Digital Input Resistive Pull Up"
The error message was
Error: plm.M0046: E2728: <EXT_GPIO5(0)> cannot be placed at <P14[1]> because USB pins do not support drive modes other than CMOS_OUT and HI_Z_ANALOG.
So I assumed that the only valid choice(s) were either "CMOS_OUT" or "HI_Z_ANALOG" in the previous reply.
I also tried
(1) High Impedance Digital
(2) High Impedance Analog
Then to make the analog signal readable from the digital, I connected it through comparator to status register
As the circuit it seemed fine, but as I tried to compile, I got the following error.
Error: fit.M0059: FFB and IO placement failed: Invalid pin assignment USBDM. This pin does not support ANALOG. (App=cydsfit)
So, although the first error message suggested that USBDM supports only CMOS_OUT and HI-Z-Analog,
the only choice the PSoC Creator allows is HI-Z-Digital, which you are using.
Then in the PSoC 63 with BLE Architecture Technical Reference Manual (TRM),
I found following lines
===================
30.3.1.5 GPIO Mode Logic
The D+ and D– pins can be used either as GPIO pins or
USB I/O pins. This is controlled by the IOMODE bit of the
USBDEV_USBIO_CR1 register. This bit should be set HIGH
for GPIO functionality and LOW for USB operation.
===================
In the PSoC 63 with BLE Registers Technical Reference Manual (TRM)
USBFS0_USBDEV_USBIO_CR1 0x403F0048
So, how about trying
*(uint32_t *)CYREG_USBFS0_USBDEV_USBIO_CR1 |= (0x01 << CYFLD_USBFS_USBDEV_IOMODE__OFFSET) ;
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Below two registers should be configured to enable use USBIO as GPIO input pin.
/*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));