2021-06-08 08:08 AM
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!
Solved! Go to Solution.
2021-06-08 09:31 AM
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!
2021-06-08 08:22 AM
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();
}
}
2021-06-08 08:28 AM
Yes I also did that, sorry for not mentioning.
2021-06-08 08:44 AM
It should be as simple as that.
Do you see some signal on UART pins even when not swapped ?
2021-06-08 09:01 AM
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?
2021-06-08 09:31 AM
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!