I have some issues trying to transmit data with my USART pins.
I use STM32-Nucleo-L476RG board with USART2 enabled. I generated the code with CubeMX and in my main() function, i call HAL_UART_Transmit() function to send data as the following :
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
uint8_t Test[] = "Hello World !!!\r\n"; //Data to send
HAL_UART_Transmit(&huart2,Test,sizeof(Test),1000);// Sending in normal mode
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
HAL_Delay(500);
}
(Note : PA5 is my LED, USART2_Tx is on PA2)
Using the command screen
on my Linux Terminal to monitor the UART signal, I receive "Hello World !!!" multiple times, so i was thinking UART communication was working.
BUT.
Pinning a scope on the USART_Tx pin corresponding to USART2, i cannot see any signal transmitted (the line is always at 0V). So i receive my USART signal on my computer via USB, but I can't send any data to another Nucleo (for example).
Anyone has an idea of what could be the problem? Any function to call to instantiate something? I can send more details about my code/pin configs via cubeMX if needed.
PS : I also tested with STM32-Nucleo-F401RE and the result is the same so I think the problem definitely comes from me.
Thanks.
To solve the problem, I tried to use other UART/USART available (from 1 to 3), without results. I also tried to closed-loop my Tx/Rx pins to Receive data from the Tx pin. Also without results.
Concerning the clock/pin init :
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART2;
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
Error_Handler();
}
/* Peripheral clock enable */
__HAL_RCC_USART2_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**USART2 GPIO Configuration
PA2 ------> USART2_TX
PA3 ------> USART2_RX
*/
GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
This function is called in my main() function before the main loop.
From what I see on my board, SB62 & SB63 do not have the connector on top of them, and SB13 & SB14 both have the connector on top of them. I think it could be the issue. Updating the post when I can test it.