Sto usando UART IO di interrupt (no DMA).
HAL_UART_Transmit_ITla funzione imposta il EIEbit nel CR3registro. Secondo il datasheet STM32F407 (e il comportamento reale), questo genera interrupt solo in modalità multi buffer (quando il DMARbit è impostato). EIEabilita la generazione di interruzioni per errore frame ( FE), errore overrun ( ORE), noise noise ( NE). Questo errore, a quanto ho capito, solo per la ricezione.
Parte della HAL_UART_IRQHandlerfunzione:
tmp1 = __HAL_UART_GET_FLAG(huart, UART_FLAG_ORE);
tmp2 = __HAL_UART_GET_IT_SOURCE(huart, UART_IT_ERR);
/* UART Over-Run interrupt occurred ----------------------------------------*/
if((tmp1 != RESET) && (tmp2 != RESET))
{
__HAL_UART_CLEAR_OREFLAG(huart);
huart->ErrorCode |= HAL_UART_ERROR_ORE;
}
if(huart->ErrorCode != HAL_UART_ERROR_NONE)
{
/* Set the UART state ready to be able to start again the process */
huart->State = HAL_UART_STATE_READY;
HAL_UART_ErrorCallback(huart);
}
HAL_UART_IRQHandlercontrolla ogni errore. Se si è verificato un errore e il EIEbit è impostato, reimposta lo stato UART, ma non reimposta i bit di abilitazione dell'interrupt, quindi l' TXEinterrupt verrà sempre generato, ma la UART_Transmit_ITfunzione considera lo stato HAL_UART_STATE_READYcome non valido e non fa nulla. Ciclo infinito.
Parte della UART_Transmit_ITfunzione:
static HAL_StatusTypeDef UART_Transmit_IT(UART_HandleTypeDef *huart)
{
uint16_t* tmp;
uint32_t tmp1 = 0;
tmp1 = huart->State;
if((tmp1 == HAL_UART_STATE_BUSY_TX) || (tmp1 == HAL_UART_STATE_BUSY_TX_RX))
{
}
else
{
return HAL_BUSY;
}
}
È un bug in Cube HAL?