cancel
Showing results for 
Search instead for 
Did you mean: 

Timer, DMA and ARR preload question

Michal Dudka
Senior III

I need generate some pattern at GPIO outputs (in defined times i have to write some known combinations on outputs) as reaction on external trigger signal. I've let external signal to trigger timer (thru TRGI). I'am using TIM_CC event as DMA request writing on GPIO - thats OK. But i need reconfigure timer ARR each period. I've plan use ARR preload and use TIM_UPDATE event as DMA request for writing new values into (preloaded) ARR. But there is awkward problem.

When timer is stopped and i can write first ARR value directly into ARR register. Then external trigger starts timer and now timer running with empty ARR preload/buffer/shadow register. I have to write as fast as possible new value into it. That push me to use another (third) DMA channel with request from TIM_TRIGGER event.

Is there any way how to write actual ARR and preload/shadow/buffer ARR value before timer start ? Any my attempts writing into ARR while timer doesn't run ends in immediate change of ARR value.

Or have anyone some good idea how to make that task in some clever way ? I can set some restrictions on times of course. For example minimum delays between them (period) etc.

4 REPLIES 4

I don't understand what's your problem, but you probably don't need to preload ARR if you are going to write into it in Update-triggered DMA.

JW

Michal Dudka
Senior III

You are right - i've think that ARR preload provide me some protection (for situations when period is very short and DMA does not manage data on time). But preload will not help... ok, with disabled preload it is simple. SW only must secure that all "periods" are longer then DMA "acces time"...

Thanks.

TDK
Guru

Generate an update event with the TIMx->EGR after writing to load it into the ARR register. So update ARR, then generate an update event, then start the timer.

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

I think that doesn't solve my problem. I've looking for mechanism how to write one value into ARR and different value into preload when timer is disabled. But how waclavek.jan points - using preload doesnt give me any advantage and my question became unnecessary... thanks for help 🙂