Single pin Hardware serial

Post here first, or if you can't find a relevant section!
User avatar
fpiSTM
Posts: 1758
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Single pin Hardware serial

Post by fpiSTM »

Probably a HAL or LL functions exist for that. You can try to generate the code with CubeMX.
User avatar
Alextrical
Posts: 39
Joined: Tue Aug 02, 2022 12:59 pm
Location: Cornwall, UK

Re: Single pin Hardware serial

Post by Alextrical »

I just found the solution, and then saw your response. You are 100% correct. This allows me to set Bit15 of CR2, :D

It turns out that also calling

Code: Select all

__HAL_RCC_USART2_CLK_ENABLE();
before setting the bit works

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
Next to follow the guides for HalfDuplex and see how that goes
Post Reply

Return to “General discussion”