Page 2 of 2

Re: Single pin Hardware serial

Posted: Tue Aug 23, 2022 5:12 am
by fpiSTM
Probably a HAL or LL functions exist for that. You can try to generate the code with CubeMX.

Re: Single pin Hardware serial

Posted: Tue Aug 23, 2022 8:54 am
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