Skip to main content
Visitor II
October 7, 2024
Question

STM32G0 TX Busy Flag Set when ClockPrescaler is 8

  • October 7, 2024
  • 3 replies
  • 934 views

Hi,

 

HAL_UART_STATE_BUSY_TX is always Set when I change the ClockPrescaler of USART Paremeter.

gceti1_0-1728306451623.png

My Cube configurations are in photo above. I have to drive Usart with 100 Baudrate. Systemclock Frequency is 50Mhz.

 

gceti1_1-1728306542177.png

 

When SystemClock is 50Mhz and ClockPrescaler is 1, it limits in order to set baudrate of USART. It says "Baud Rate must be between 763 Bits/s and 3.125 MBits/s." .Therefore I set ClockPrescaler to 8. 

When program has started, USART has stopped after send USART 3-4 bytes. I am using HAL_UART_Transmit_DMA to transmit with USART. When I checked inside of transmit function, I saw huart->gState flag is always HAL_UART_STATE_BUSY_TX and newer be set ready. 

 

I didnt solve where is the problem? Could you please help me to solve it please?

 

 

    This topic has been closed for replies.

    3 replies

    Super User
    October 8, 2024

    HAL_UART_STATE_BUSY_TX indicates the process is currently running and is not yet complete. If it never completes, perhaps an error condition happened. You will need to check for and clear any error conditions in the HAL_UART_ErrorCallback callback. The error condition will be indicated in the ErrorCode member of the handler. You can also debug the program, pause it when the error occurs and examine the handle and/or UART registers to see what happened.

    gceti.1Author
    Visitor II
    October 10, 2024

    Hi,

    Thank you for your reply. I checked out the HAL_UART_ErrorCallback callback. It looks there are no errors occured, the error callback function never called. 

    While everything is same, changing of prescaler as huart3.Init.ClockPrescaler = UART_PRESCALER_DIV1; works perfectly. What changes when set prescaler to huart3.Init.ClockPrescaler = UART_PRESCALER_DIV8; ?

    gceti.1Author
    Visitor II
    October 14, 2024

    Hello,

    Is there any one facing with this issue? 

    The main problem is ClockPrescaler of Uart, If I let it as UART_PRESCALER_DIV1 everything is fine, except UART_PRESCALER_DIV1 it goes to error. 

    For instance

    Let baudrate 9600 bps. 

    If UART_PRESCALER_DIV1 is it works,

    Without changing anything except Uart Prescaler, error occurs.

     

     

    gceti.1Author
    Visitor II
    October 15, 2024

    Hello again,

    I solved the problem.

    I am using STM32G070CBTx MCU. ClockPrescaler feature is not available on USART3 peripheral. Everything is fine with using same configuration with USART1 peripheral.

     

    100 Baudrate or lower can be using with setting ClockPrescaler with USART1 and USART2. The others (USART3 and USART4) is not compatible with ClockPrescaler parameter.

     

    I did not find information about this issue. May be ClockPrescaler parameter is not selectable for USART3 and USART4