- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm having trouble dynamically reconfiguring UART pins to GPIO and back. Currently, I'm using a UART peripheral with TX 9[1] and RX 9[0] on the CYBLE-416045-02 and have tried the following:
Set to GPIO, and set TX pin to low
uint32 reg;
reg = CY_GET_REG32(CYREG_HSIOM_PRT9_PORT_SEL0);
CY_SET_REG32(CYREG_HSIOM_PRT9_PORT_SEL0 ,CY_GET_REG32(CYREG_HSIOM_PRT9_PORT_SEL0) & 0xFFFFFF0F);
Cy_GPIO_SetDrivemode(TX_PIN_0_PORT, TX_PIN_0_NUM, CY_GPIO_DM_STRONG);
Cy_GPIO_Write(TX_PIN_0_PORT, TX_PIN_0_NUM, 0);
Then later set back to UART pins
CY_SET_REG32(CYREG_HSIOM_PRT9_PORT_SEL0, reg);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So to answer myself, I was resetting the wrong bits. Below I set all the pins to GPIO controlled then back, this is fine for my use case.
Set to GPIO, and set TX pin to low
uint32 reg;
reg = CY_GET_REG32(CYREG_HSIOM_PRT9_PORT_SEL0);
CY_SET_REG32(CYREG_HSIOM_PRT9_PORT_SEL0 ,CY_GET_REG32(CYREG_HSIOM_PRT9_PORT_SEL0) & 0x00000000);
Cy_GPIO_SetDrivemode(TX_PIN_0_PORT, TX_PIN_0_NUM, CY_GPIO_DM_STRONG);
Cy_GPIO_Write(TX_PIN_0_PORT, TX_PIN_0_NUM, 0);
Then later set back to UART pins
CY_SET_REG32(CYREG_HSIOM_PRT9_PORT_SEL0, reg);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
KeCo,
Have you checked out the following links:
Re: UART TX to GPIO programmatically?
Re: Reconfigure UART RX pin to GPIO after 10sec
Len
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So to answer myself, I was resetting the wrong bits. Below I set all the pins to GPIO controlled then back, this is fine for my use case.
Set to GPIO, and set TX pin to low
uint32 reg;
reg = CY_GET_REG32(CYREG_HSIOM_PRT9_PORT_SEL0);
CY_SET_REG32(CYREG_HSIOM_PRT9_PORT_SEL0 ,CY_GET_REG32(CYREG_HSIOM_PRT9_PORT_SEL0) & 0x00000000);
Cy_GPIO_SetDrivemode(TX_PIN_0_PORT, TX_PIN_0_NUM, CY_GPIO_DM_STRONG);
Cy_GPIO_Write(TX_PIN_0_PORT, TX_PIN_0_NUM, 0);
Then later set back to UART pins
CY_SET_REG32(CYREG_HSIOM_PRT9_PORT_SEL0, reg);