HAL_UART_Receive() not working correctly.
Hey,
I'm using STM32F303RET6 and need to implement UART communication via USART1 (PA9 as Tx and PA10 as Rx).
I managed to print "Hello World" on my console,Which means Tx is working fine and my console is configured correctly, but couldn't receive bytes from the console.

This is how I set up the USART using MXCube
static void MX_USART1_UART_Init(void)
{
/* USER CODE BEGIN USART1_Init 0 */
/* USER CODE END USART1_Init 0 */
/* USER CODE BEGIN USART1_Init 1 */
/* USER CODE END USART1_Init 1 */
huart1.Instance = USART1;
huart1.Init.BaudRate = 38400;
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_16;
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART1_Init 2 */
/* USER CODE END USART1_Init 2 */
}and this is what i'm trying to do in order to get the data from the console
uint8_t myRxData[1];
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_UART_Receive(&huart1, myRxData, 10,1000);
//HAL_UART_Receive_IT(&huart1, myRxData, 10);
//HAL_UART_Receive_DMA(&huart1, myRxData, 10);
}I also added this in order to echo while trying the IT method and even tried the DMA with no luck.
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(huart);
/* NOTE : This function should not be modified, when the callback is needed,
the HAL_UART_RxCpltCallback can be implemented in the user file.
*/
HAL_UART_Transmit(&huart1, myRxData, 1, 1000);
}What am I doing wrong??
Thanks in advance,
Rony.
