Skip to main content
Explorer
March 7, 2025
Solved

Strange Behaviour HAL_TIM_PWM_Start_DMA

  • March 7, 2025
  • 2 replies
  • 482 views

Hello everyone.
I am encountering a very strange issue with the STM32H7B0 using the J-Link to debug.
I followed this tutorial to control the WS28B12 LED using Timer, PWM and DMA.
I use the following function to transmit the PWM data. 

if (HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, address, 74) != HAL_OK) Error_Handler();

 But here comes the strange thing:

If i run the code, nothing happens, or lets say, the data doesn't get transmitted:

Simi_Myr_0-1741345039513.png

But if i look at value of the address variable in the debugger before running the ...Start_DMA...:

Simi_Myr_1-1741345266206.png

And then Resume the program it suddenly works:

Simi_Myr_2-1741345326500.png

Why does this happen?
Any help is appreciated

    This topic has been closed for replies.
    Best answer by Sarra.S

    Hello @Simi_Myr

    The behavior that you're describing, where the program works after inspecting the variable in the debugger, means that there might be a timing issue or a need for a delay! This is probably related to the debug mode settings.

    Try adding  a breakpoint in your callback function to monitor the execution flow and ensure that the source data has been transferred to the destination buffer 

     

    2 replies

    Sarra.SAnswer
    ST Employee
    March 7, 2025

    Hello @Simi_Myr

    The behavior that you're describing, where the program works after inspecting the variable in the debugger, means that there might be a timing issue or a need for a delay! This is probably related to the debug mode settings.

    Try adding  a breakpoint in your callback function to monitor the execution flow and ensure that the source data has been transferred to the destination buffer 

     

    Super User
    March 7, 2025

    > the data doesn't get transmitted

    Looks like your code sets everything to 0, or at least most of it (50/74 values) but we can't see the rest. The data looks like a bunch of 0's being transmitted.

    TDK_0-1741357593852.png