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

PSoC™ 6 Forum Discussions

KeCo_3781066
Level 2
Level 2
5 sign-ins First question asked First solution authored

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);

0 Likes
1 Solution
KeCo_3781066
Level 2
Level 2
5 sign-ins First question asked First solution authored

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);

View solution in original post

0 Likes
2 Replies
Len_CONSULTRON
Level 9
Level 9
500 solutions authored 1000 replies posted 750 replies posted

KeCo,

Have you checked out the following links:

Re: UART TX to GPIO programmatically?

Re: Reconfigure UART RX pin to GPIO after 10sec

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
KeCo_3781066
Level 2
Level 2
5 sign-ins First question asked First solution authored

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);

0 Likes