Posted on November 02, 2016 at 08:09The original post was too long to process during our migration. Please click on the attachment to read the original post.
First you should check if the NVIC is configured forUSART1_IRQn insidestm32f1xx_hal_msp.c. If it is not, you should enable the NVIC interrupt in the USART configuration window of CubeMX.
Second , you should initialize the data buffer as global and not local , the you pass it as pointer inside the USART interrupt transfer start function . The receive should start after checking the transfer has really complete by managing a ready flag. See example below:
/*- Start the transmission process */
if(HAL_UART_Transmit_IT(&UartHandle, (uint8_t*)DataTX, DataTX_SIZE)!= HAL_OK)
{
Error_Handler();
}
/*##-3- Wait for the end of the transfer ###################################*/
while (UartReady != SET)
{
}
/* Reset transmission flag */
UartReady = RESET;
/*##-4- Put UART peripheral in reception process ###########################*/
if(HAL_UART_Receive_IT(&UartHandle, (uint8_t *)DataRX, DataRX_SIZE) != HAL_OK)
{
Error_Handler();
}
Third, you manage the UartReady flag inside the Tx call back as follow :
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UartHandle)
{
/* Set transmission flag: transfer complete */
UartReady = SET;
}