2016-11-02 12:09 AM
2016-11-03 09:41 AM
Hi m.anjana,
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;
}
-Hannibal-