2017-05-12 06:50 PM
this if((Timeout == 0U)||((HAL_GetTick() - Tickstart ) > Timeout)) should be if((Timeout == 0U)||((HAL_GetTick() - Tickstart ) < Timeout))
static HAL_StatusTypeDef USART_WaitOnFlagUntilTimeout(USART_HandleTypeDef *husart, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
{ /* Wait until flag is set */ while((__HAL_USART_GET_FLAG(husart, Flag) ? SET : RESET) == Status) { /* Check for the Timeout */ if(Timeout != HAL_MAX_DELAY) { if((Timeout == 0U)||((HAL_GetTick() - Tickstart ) > Timeout)) { /* Disable the USART Transmit Complete Interrupt */ CLEAR_BIT(husart->Instance->CR1, USART_CR1_TXEIE);/* Disable the USART RXNE Interrupt */
CLEAR_BIT(husart->Instance->CR1, USART_CR1_RXNEIE);/* Disable the USART Parity Error Interrupt */
CLEAR_BIT(husart->Instance->CR1, USART_CR1_PEIE);/* Disable the USART Error Interrupt: (Frame error, noise error, overrun error) */
CLEAR_BIT(husart->Instance->CR3, USART_CR3_EIE);husart->State= HAL_USART_STATE_READY;
/* Process Unlocked */
__HAL_UNLOCK(husart);return HAL_TIMEOUT;
} } } return HAL_OK;}2017-05-13 09:40 AM
>>this if((Timeout == 0U)||((HAL_GetTick() - Tickstart ) > Timeout)) should be if((Timeout == 0U)||((HAL_GetTick() - Tickstart ) < Timeout))
Wouldn't that cause it to return HAL_TIMEOUT in 100% of cases where the first read didn't have the desired status?
2017-05-14 06:17 PM
Thank you for your reply.
Sorry,My English is not good.
My Problem is : STM32F051C8 SOFTWARE RESET THEN STOP MX_USART1_UART_Init(); no restart
This USART_ISR_TEACK always SET.
I before software reset(Iwdg reset),
while(HAL_UART_AbortTransmit(&huart1)!=HAL_OK);
while(HAL_UART_AbortReceive(&huart1)!=HAL_OK); while(HAL_UART_Abort_IT(&huart1)!=HAL_OK); while(HAL_UART_AbortTransmit_IT(&huart1)!=HAL_OK); while(HAL_UART_AbortReceive_IT(&huart1)!=HAL_OK); while(HAL_UART_Abort(&huart1) !=HAL_OK); while(HAL_UART_DeInit(&huart1)!=HAL_OK);Than Infinite loop this UART_WaitOnFlagUntilTimeout(huart, USART_ISR_TEACK, RESET, tickstart, HAL_UART_TIMEOUT_VALUE)
if(UART_WaitOnFlagUntilTimeout(huart, USART_ISR_TEACK, RESET, tickstart, HAL_UART_TIMEOUT_VALUE) != HAL_OK)
{ /* Timeout occurred */ return HAL_TIMEOUT; }