cancel
Showing results for 
Search instead for 
Did you mean: 

TIM1 (Input Capture Mode) should DMA one single input Capture value (direct time period measurement, counter reset at every capture) to Memory at every TIM15 counter expiry.

BSam
Associate II

Hello, I want to trigger TIM1 (Input Capture Mode) using TIM15 counter elapse (say every 1 sec). TIM1 should measure input frequency , reset counter every capture, and do one DMA of Input capture value to Memory buffer at every 1 sec (say). I tried Putting TIM1 in Slave modes (Combined Reset Trigger Mode , Reset Mode) with Input trigger as ITR0 (for TIM15 to be Master). TIM15 in Master mode with Trigger Event Selection as Update Event, Output Compare no output Mode. Also tried other alternatives that seemed relevant, but it is not working. Normal DMA is working, but picking one capture frequency at every interval and moving it to memory is what I am not being able to get. Kindly give me some inputs. Thank you

9 REPLIES 9
Javier1
Principal

this worked for me

https://www.youtube.com/watch?v=qqzZ9C0umQ4

I am able to detect up to 1Mhz signals with an stm32g030 (64Mhz)

we dont need to firmware by ourselves, lets talk
BSam
Associate II

Hi, I am being able to capture frequency. My requirement is different. I have PWM input with varying frequency. TIM1 is capturing values and moving capture values to memory buffer. Please note every capture also resets counter to 0, so that I do not have to subtract two subsequent capture to calculate time period of input frequency.

But I do not want to store every Capture value. I want to pick a sample at some fixed interval. The interval time is set by TIM15. Every expiry of TIM15 counter should trigger DMA of TIM1 IC capture.

Which STM32?

> Please note every capture also resets counter to 0

You cannot use the Slave-mode controller for two different purposes at the same time (i.e. both Reset and Trigger). Read the TIM chapter in RM.

> Every expiry of TIM15 counter should trigger DMA of TIM1 IC capture.

Then do just this. Don't attempt to put TIM15-TIM1 into the master-slave link. Leave TIM1 to do the capture + reset thing, and use TIM15-update-triggeded DMA to transfer data from TIM1_CCRx to memory. Maybe this is not something easily clickable in CubeMX, I don't know, I don't use CubeMX.

JW

>Which STM32?

STM32L412

>use TIM15-update-triggeded DMA to transfer data from TIM1_CCRx to memory.

Yes, I want something like this. But can DMA linked to TIM15 transfer TIM1_CCRx data (the peripheral is different) ? I do not find a way to do this.

I do not want to use interrupt.

I am using CubeIDE.

Thank you

>> My requirement is different.

Is it?

>> I have PWM input with varying frequency

This is the same

>> TIM1 is capturing values and moving capture values to memory buffer

This is the same, but they use DMA in the video.

>>Please note every capture also resets counter to 0, so that I do not have to subtract two subsequent capture to calculate time period of input frequency.

I dont think you understand how input capture mode works, TIM1 if correctly configured should calculate the delta between edges for you.

https://community.st.com/s/question/0D50X00009XkfUBSAZ/how-to-reset-timer-counter-value-once-captured

>>But I do not want to store every Capture value.

This is why you should be using DMA, as in the video i linked

>> I want to pick a sample at some fixed interval.

You do this by triggering the DMA and the input capture with software or another timer.

(DMA_start DMA_stop....)

>>The interval time is set by TIM15. Every expiry of TIM15 counter should trigger DMA of TIM1 IC capture.

I dont see the problem or how is this any different, use the TIM15 to start and/stop the capture and the DMA at your will.

we dont need to firmware by ourselves, lets talk

Nowhere I suggested using interrupt.

> But can DMA linked to TIM15 transfer TIM1_CCRx data (the peripheral is different) ?

In STM32L4xx, yes.

> I do not find a way to do this.

Read the DMA chapter in RM. Set up DMA for peripheral-to-memory transfer, and set TIM1_CCRx as the peripheral-side address.

JW

BSam
Associate II

Thank you very much, will do this.

BSam
Associate II

I did as waclawek.jan said, and this is working (used TIM6 instead of TIM15). Thanks again for quick response.

BSam
Associate II

Hello All, I have a new question in the same context. Instead of DMA-ing the captured frequency values to internal RAM (which I was doing so far - as waclawek.jan suggested) is it possible to DMA the values towards QSPI interface on which I have a W25Q128JV Flash.

Please Note : I could not make this Flash work in Quad mode. Flash access is working in Single SPI mode (using HAL QSPI driver).

Right now I am copying the captured frequency data from Internal RAM to QSPI Flash (W25Q128). I want to avoid that. We are looking for 10,000 samples per sec data.

Thanks again for your earlier help. My regards