cancel
Showing results for 
Search instead for 
Did you mean: 

Can't swap TX/RX pins of UART in project 'Zigbee_SE_Msg_Server_Router' on STM32WB50CG.

eeeeee
Associate III

Hi,

I'm trying to swap the TX/RX pins of UART but I can't make it happen without the project configuration file that is not present in the Zigbee_SE_Msg_Server_Router project.

I tried to change the pins in the 'hw_conf.h' file but that doesn't seem to change anything. Am I missing something?

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
eeeeee
Associate III

I believe I've found the problem. There was another adjustment to be made in the file 'stm32wbxx_hal_msp.c'.

There is a GPIO_InitStruct in this file that also needs to be modified to the right pins. After that it worked for me.

Thanks for your time!

View solution in original post

5 REPLIES 5
Mike_ST
ST Employee

Try to activate the "SWAP" feature:

/**

 * @brief USART1 Initialization Function

 * @param None

 * @retval None

 */

void MX_USART1_UART_Init(void)

{

   huart1.Instance = USART1;

   huart1.Init.BaudRate = 115200;

   huart1.Init.WordLength = UART_WORDLENGTH_8B;

   huart1.Init.StopBits = UART_STOPBITS_1;

   huart1.Init.Parity = UART_PARITY_NONE;

   huart1.Init.Mode = UART_MODE_TX_RX;

   huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;

   huart1.Init.OverSampling = UART_OVERSAMPLING_8;

   huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

   huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;

   huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_SWAP_INIT; //UART_ADVFEATURE_NO_INIT;

   if (HAL_UART_Init(&huart1) != HAL_OK) {

       Error_Handler();

   }

   if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) {

       Error_Handler();

   }

   if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) {

       Error_Handler();

   }

   if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK) {

       Error_Handler();

   }

}

eeeeee
Associate III

Yes I also did that, sorry for not mentioning.

Mike_ST
ST Employee

It should be as simple as that.

Do you see some signal on UART pins even when not swapped ?

eeeeee
Associate III

Yes I have a LED on RX and TX each. When I run another project and I initialize the UART, the LEDs on each signal goes on. When I initialize this project, I only see the TX signal go on.

I figured it would maybe be because it is a protected project or something?

eeeeee
Associate III

I believe I've found the problem. There was another adjustment to be made in the file 'stm32wbxx_hal_msp.c'.

There is a GPIO_InitStruct in this file that also needs to be modified to the right pins. After that it worked for me.

Thanks for your time!