AnsweredAssumed Answered

STM32L496 UART1 Problem

Question asked by Sim Be on Jan 18, 2018
Latest reply on Jan 31, 2018 by Sim Be

Hello,

 

in a recent design I am experiencing some trouble on the L496RGT6 MCU when using UART1 in connection with an FT232RL. I am using HAL drivers.

The following problem occurs: Transmitting data in blocking an non-blocking mode works fine. But receiving leads to problems as UARt stays busy receiving. For receiving I use the HAL_UART_Receive_IT(...) function. When receiving data the Callback routine is executed as desired, but when executing the next receive out of the Callback UART is staying busy. My Callback routine is shown below. My code is exported by CubeMX with the SW4 Toolchain. The code is testet on two MCU. Same code wors fine on other STM32 F-/L-Series MCUs.

 

Are there any similar problems known yet? Has someone an idea for a workaround?

 

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){
    if(huart->Instance == USART1){

         // sending back received char

        HAL_UART_Transmit(&huart1, (uint8_t *)UART1_Rx_Data, 1,100);
        HAL_UART_Transmit(&huart1, (uint8_t *)"\r\n", 2,100);

 

         // print out current uart state and call receive_it again
        if (HAL_UART_Receive_IT(&huart1,(uint8_t *)UART1_Rx_Data,1) == HAL_OK){
            HAL_UART_Transmit(&huart1, (uint8_t *)"OK\r\n", 4,100);
        }
        if (HAL_UART_Receive_IT(&huart1,(uint8_t *)UART1_Rx_Data,1) == HAL_ERROR){
            HAL_UART_Transmit(&huart1, (uint8_t *)"ERROR\r\n", 7,100);
        }
        if (HAL_UART_Receive_IT(&huart1,(uint8_t *)UART1_Rx_Data,1) == HAL_BUSY){
            HAL_UART_Transmit(&huart1, (uint8_t *)"BUSY\r\n", 6,100);

        }

    }
}

 

Kind regards,

Simon

Outcomes