cancel
Showing results for 
Search instead for 
Did you mean: 

How to use a same uart for two devices

RComa.1
Associate II

Hello every one , i'm using a STM32L100RX, i am using PC11 and PC10 ports as USART3, so far everything it's okay, but i need to use the same usart (USART3) on the PB11 and PB10 pins...i need configure these pins in runtime because i have another device on it! something like multiplexor, so what i do?¿

this is my code:

GPIO_InitTypeDef def,def2;
 
  HAL_GPIO_DeInit(GPIOB,GPIO_PIN_11); //Deinit port 11 and 10 of B PORT
  HAL_GPIO_DeInit(GPIOB,GPIO_PIN_10);
 
  def.Alternate = GPIO_AF7_USART3;
  def.Pull = GPIO_NOPULL;
  def.Mode = GPIO_MODE_AF_PP;
  def.Pin = GPIO_PIN_11;
  def.Speed = GPIO_SPEED_FREQ_HIGH;
  HAL_GPIO_Init(GPIOC,&def);
 
  def2.Alternate = GPIO_AF7_USART3;
  def2.Pull = GPIO_NOPULL;
  def2.Mode = GPIO_MODE_AF_PP;
  def2.Pin = GPIO_PIN_10;
  def2.Speed = GPIO_SPEED_FREQ_HIGH;
  HAL_GPIO_Init(GPIOC,&def2); //Set now the usart 3 to the desired PORT

but it doesn't work...any idea?¿

Regards!

10 REPLIES 10