cancel
Showing results for 
Search instead for 
Did you mean: 

Hi , I would like to know if there is a way to use DMA to get the TIM1 advanced timer update events ? I can successfully trigger an IRQ but having problems setting a DMA to trigger on every update. I am using STM32 L4 MCU.

RRV.1
Associate II

I am using the advanced timer TIM1 on STM32L476RG MCU. I have configured the timer in slave reset mode as given in section 30.3.26 of the reference manual. The counter resets every rising edge. I want to use this mode to measure low frequencies such as 500 Hz. The way I am trying to do that is by using the timer update event and calculating the total counter value using that

I would like to know how to configure and use DMA for timer update event(counter rollover in up counting mode) ?

4 REPLIES 4

By setting TIM1->DIER.UDE.

Then, you use DMA1 Channel6, after having set DMA1->CSELR.C6S to 0b0111.

What do you want to transfer using that DMA?

JW

RRV.1
Associate II

Thanks for the reply.

I want to transfer the timer counter value before update. Is that even possible ?

If so does this look correct ?

 htim1.Instance->DIER = TIM_DMA_UPDATE;

 DMA1_CSELR->CSELR |= (DMA_CSELR_C6S << 0b0111);

 HAL_DMA_Start(&hdma_tim1_up, (uint32_t)htim1.Instance->CCR1, counterValue,1);

> I want to transfer the timer counter value before update. Is that even possible ?

Set up the timer to Capture on the input signal, and set up the DMA to transfer upon that capture. You still can reset timer using the Slave mode controller, but I recommend against it, as it involves an unspecified delay from the input signal (1-2 cycles, not too much but it is unnecessary so why doing it at all). I don't use Cube so can't comment on that code snippet.

JW

RRV.1
Associate II

The reason for using the slave reset is so that the first value is always 0. Anyway if the input capture mode with DMA would give a more accurate reading then that would be the way to go. Thanks for the suggestion.