cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L412C8 USART2 RX TX pin swap not working

KAsim
Associate II

I am using the STM32L412C8 and I am having trouble with the USART2 RX/TX pin swapping. I enabled it in CubeMX but if I send data to the PA2 pin (originally TX but should be RX after the swap) I get nothing. If however I send my data to PA3(should be TX after the swap) data instantly comes in. Checking the CR2 register of the USART, the SWAP bit is set.

What am I doing wrong?

17 REPLIES 17
Uwe Bonnes
Principal II

Did you configure PA2 as peripheral?

S.Ma
Principal

Both pins should be alternate function configured. Otherwise, check the errata sheet.

Yes, and I tried both push-pull and open drain.

KAsim
Associate II

Both have been configured for USART2. The errata sheet has nothing relevant.

S.Ma
Principal

I've got STM32L4R5 connected to HC-06 BT module with wires, will give it a try tomorrow to check it at my desk.

S.Ma
Principal

Well it works on stm32l4r5. However, UE can t apparently be reset manually in debug mode.

OP's problem may also be the way how Rx is handled, regardless of the swap...

JW

KAsim
Associate II

Would you mind sharing your code or the ioc file from CubeMX?

What do you mean? I have used both HAL and LL functions to receive data and the result was the same.