2020-07-22 12:15 AM
Hi,
I am trying to receive and trasnmit data with STM32F030C8 mcu, i can receive any data from serial monitor, but when i try to use HAL_UART_Transmit to send data, i can not see anything on serial monitor. Any advise?
uint8_t data[25];//this my data buffer to send
HAL_UART_Transmit(&huart2, data, sizeof(data), HAL_MAX_DELAY); //in startup i use this to send data bufer
static void MX_USART2_UART_Init(void)//this is my usart2 setup
{
huart2.Instance = USART2;
huart2.Init.BaudRate = 115200;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
2020-07-22 04:32 AM
Read out and check/post the USART and relevant GPIO registers content.
JW
2020-07-22 09:16 AM
for uart, better use low layer.
2020-07-22 12:10 PM
If you can receive, you could do a loopback by connecting TX and RX directly and check transmission. And: check TX pin with a LA/scope. How accurate is the MCU/UART clock?