2020-09-25 02:39 PM
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) ?
2020-09-25 03:57 PM
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
2020-09-28 02:58 PM
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);
2020-09-28 03:26 PM
> 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
2020-09-28 04:59 PM
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.