cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32F7] What could be a reason that HAL_UART_Receive_IT does not return?

GSpre.1
Associate III

The corresponding UART works fine with HAL_UART_Receive. I've confirmed with GDB that this function fails to return. I realize I'm leaving out a lot of details here, but from the documentation I can see a lot of reasons why this function can *fail*, and a lot of ways one can screw up the handling of the interrupts, but I fail to understand how the function could just block and not return.

Any hints?

9 REPLIES 9
TDK
Guru

Could be an ISR starving it of resources. Easy enough to debug and check what's going on.

If you feel a post has answered your question, please click "Accept as Solution".
GSpre.1
Associate III

Thanks! Do you have any hints as to how I might want to proceed? I believe the only interrupt I'm dealing with is a tick timer, as set up automatically by the CubeMX code generator.

Run the code in debug mode. Hit pause, see where the cpu is at.
If you feel a post has answered your question, please click "Accept as Solution".

That's what I'm doing. I can only see I'm stuck at the call to HAL_UART_Receive_IT.

Single-step in disasm.

JW

Piranha
Chief II

Most likely the problem is something else. For example wrong flash latency, voltage scale, overdrive mode, clock frequency.

P.S.

huart->RxISR       = NULL;
 
    /* Computation of UART mask to apply to RDR register */
    UART_MASK_COMPUTATION(huart);
 
...
 
    /* Set the Rx ISR function pointer according to the data word length */
    if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
    {
      huart->RxISR = UART_RxISR_16BIT;
    }
    else
    {
      huart->RxISR = UART_RxISR_8BIT;
    }

Although the configuration itself is changed only at initialization, all of this junk is done at every transaction...

Ugh, yeah, I keep hearing horror stories of the HAL. Do you happen to know of a good, introductory-level example of doing UART communication without using the HAL?

I'm guessing this is now quite off-topic, but am I supposed to be able to `stepi` with GDB over st-link? Every time I try, the code just seems to run until I hit HAL_UART_Receive_IT (which is definitely a little while into the program), and then hang.

That's what I'm doing. I can only see I'm stuck at the call to HAL_UART_Receive_IT. (Sorry if this is a double-post; I can't tell if my previous reply was actually put in the right place.)