Single pin Hardware serial
Re: Single pin Hardware serial
Probably a HAL or LL functions exist for that. You can try to generate the code with CubeMX.
- Alextrical
- Posts: 39
- Joined: Tue Aug 02, 2022 12:59 pm
- Location: Cornwall, UK
Re: Single pin Hardware serial
I just found the solution, and then saw your response. You are 100% correct. This allows me to set Bit15 of CR2,
It turns out that also calling before setting the bit works
TX is now using the RX Pin. Woo
Next to follow the guides for HalfDuplex and see how that goes

It turns out that also calling
Code: Select all
__HAL_RCC_USART2_CLK_ENABLE();
TX is now using the RX Pin. Woo
Code: Select all
Serial2.begin(9600);
USART2->CR1 &= ~(1 << 0); // UE = 0... disable USART
USART2->CR2 |= (1 << 15); //Set RX TX Swap
USART2->CR1 |= (1 << 0); // UE = 1... Enable USART