2020-12-06 02:08 AM
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.
2020-12-06 02:49 AM
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
2020-12-06 04:18 AM
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.
2020-12-06 07:43 AM
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.
2020-12-06 08:11 AM
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 :)