Skip to main content
Senior
April 18, 2024
Solved

Timer + DMA problem

  • April 18, 2024
  • 1 reply
  • 1001 views

I am using TIM+DMA, and the main problem is that the first value should be loaded into ARR before the timer starts, but it is not. Also, regarding length, if it should be set in bytes, it should be clearly documented in a comment for that function, which currently it is not.

 uint32_t val_tim[] = {1500, 1200, 2000, 3000, 4000, 5000};

HAL_TIM_Base_Start_DMA(&htim2, val_tim, 6 * 4);

This topic has been closed for replies.
Best answer by waclawek.jan

> the first value should be loaded into ARR before the timer starts, but it is not.

You have to write it "manually". Note, that if you've set ARR preload (TIM_CR1.ARPE), you need to generate an Update to get the new ARR value valid.

>  it should be clearly documented in a comment for that function, which currently it is not.

And what does that comment say? 

IMO it takes number of transactions rather than bytes, but I don't use Cube/HAL.

JW

1 reply

waclawek.jan
waclawek.janBest answer
Super User
April 18, 2024

> the first value should be loaded into ARR before the timer starts, but it is not.

You have to write it "manually". Note, that if you've set ARR preload (TIM_CR1.ARPE), you need to generate an Update to get the new ARR value valid.

>  it should be clearly documented in a comment for that function, which currently it is not.

And what does that comment say? 

IMO it takes number of transactions rather than bytes, but I don't use Cube/HAL.

JW

nimaltdAuthor
Senior
April 18, 2024

thanks for answer. i think it has written only length.