2022-12-19 12:55 AM
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
2022-12-19 01:04 AM
this worked for me
https://www.youtube.com/watch?v=qqzZ9C0umQ4
I am able to detect up to 1Mhz signals with an stm32g030 (64Mhz)
2022-12-19 01:51 AM
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.
2022-12-19 02:13 AM
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
2022-12-19 02:28 AM
>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
2022-12-19 07:00 AM
>> 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.
>>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.
2022-12-19 08:15 AM
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
2022-12-19 08:18 PM
Thank you very much, will do this.
2022-12-20 05:10 AM
I did as waclawek.jan said, and this is working (used TIM6 instead of TIM15). Thanks again for quick response.
2023-02-09 01:54 AM
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