Тёмный
No video :(

INPUT CAPTURE using DMA || Measure High Frequencies and Low Width 

ControllersTech
Подписаться 40 тыс.
Просмотров 17 тыс.
50% 1

Purchase the Products shown in this video from :: controllerstec...
________________________________________________________________________________________
Get the code from github.com/con...
Check out more STM32 TIMERS Videos • STM32 TIMERS
________________________________________________________________________________________
****** SUPPORT US BY DONATING*****
paypal.me/cont...
******Join the Membership******
/ @controllerstech
Join the Discord Server / discord
Join the Telegram Group t.me/controlle...
Follow me on Instagram / controllerstech
For more info, visit www.controller...

Опубликовано:

 

24 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 49   
@dmitrymarukh6857
@dmitrymarukh6857 Год назад
WOW! What a great example of not understanding what DMA is for! All you have to do is configure the timer in slave reset mode and two DMA channels with circular buffers. Two lines of code to start DMA and one line to take two captured values from the buffers and divide one by another. Only 3 lines of code, no IRQ and no scanning arrays to find somewhat useful data.
@sungjinkim7730
@sungjinkim7730 Год назад
THANK YOU;;;;;;;;;;;;;;;;;;;
@Gruftgrabbler
@Gruftgrabbler 3 месяца назад
Hello can you please explain your suggestions in a more clear way? I have trouble to understand it.
@dmitrymarukh6857
@dmitrymarukh6857 3 месяца назад
@@Gruftgrabbler I'll give you an example for STM32G051, but most STM32 timers can be configured this way. First, open Cube and go to Timers configuration. Select TIM1 and choose Slave Mode = Reset Mode and Trigger Source = TI1FP1, this will reset timer by signal on TIM1_CH1 pin. Select "Channel 1" = Input Capture direct mode, this will use TI1 as capture signal for CC1 channel. Select "Channel 2" = Input Capture indirect mode, this will also use TI1 for CC2 channel. Now, in configuration for Channel 1 select polarity = rising edge, for channel 2 = falling edge. In DMA settings add two DMA channels for TIM1_CH1 and TIM1_CH2. Configure both DMA in Circular mode with Data Width = Half Word. The way it works, is that rising edge of PWM signal on TIM1_CH1 pin captures PWM period in CC1 and resets timer to 0. The falling edge of the same signal captures pulse length in CC2. The DMA then transfers captured values into two memory locations. Since DMA is configured in circular mode next capture will override previous values in the same locations. To start he process you use HAL_TIM_IC_Start_DMA with an address of first memory location, e.g. uint16_t period, and again with address of second location, e.g. uint16_t duration. Whenever your program needs data, you simply do duty = (100*duration)/period. Note, that you need to deal with zero values when there are no pulses. Also some MCUs support dedicated PWM capture mode, that does all of this automatically for you, but it can be tricky to make work, so I prefer the above method.
3 месяца назад
@@dmitrymarukh6857 I can't thank you enough for this information. I am just starting my journey with STM32 and this is a hidden gem! Tried and worked. I used duty = (100*(duration+1))/(period+1), as I was thinking the counter started from 0. I wonder if this is correct or not...
@Gruftgrabbler
@Gruftgrabbler 3 месяца назад
​@@dmitrymarukh6857 Ah I understand. Thank you very much for the accurate explanation. This will be a very good reference for future ones. In my own project I am measuring the duty cycle of a 1Mhz signal using the "PWM Input" Mode of a Timer. (Using a STM32G4 series) It is a very elegant solution but also has the downside of consuming a lot of cpu time. According to my understanding it basically does the exact same thing as you described. However I think the advantage of doing it manually is that you can increase the DMA buffer size and avoid triggering the ISR so often. Saving the captured CCRs in a buffer and later doing some stuff with it when the buffer is full. Is that something you would agree? In my application I am using a workaround where I disable the corresponding global Timer interrupt after a rising edge occurs and I am enabling that in a second timer which runs on ~1/10 of the pam frequency and which is also doing the actual math. Yeah this is throwing away a lot of possible readings but right now I am currently satisfied with this workaround, I might upgrade that later on.
@Karroo74
@Karroo74 2 года назад
All what you do is very useful. Thank you!
@ricolauersdorf687
@ricolauersdorf687 Год назад
Hello Sir! Your videos are my source for fastest learning STM32. And i really thank you very much! Could you maybe please show, how to dma read parallel gpio information triggered by io? I think, it should be possible to arrange a input capture triggered dma and then read from gpio register, instead of timer capture register, as i have seen something similar. It would be great sir!
@bisoncom5139
@bisoncom5139 2 года назад
WARNING: The DMA code to calculate the averaged width is full of error. It doesn't check the array boundaries at all. DON'T blindly copy/paste them!
@dmitrymarukh6857
@dmitrymarukh6857 Год назад
Not to mention that the code itself is pointless. All that scanning and averaging is only there because the timer is not configured to automatically reset on rising edge
@user-ui7hb7op3b
@user-ui7hb7op3b Год назад
can you help me explain more detail sir, thanks
@user-ih4qk2ij1n
@user-ih4qk2ij1n 5 месяцев назад
Hi, friend! Thanks for your valuable video. Did you upload a video about another way to measure fast frequencies that you mentioned at the end of the video? Please share the link.
@nsanandkumarak
@nsanandkumarak 2 года назад
Hi Controller Tech, May i know how many years of experience do you have? you are really great...you are making useful videos, teaching, and making a good embedded engineers. The real usage of peripherals...explanation is well
@ControllersTech
@ControllersTech 2 года назад
With stm, i have around 4 years..
@adesuyisunday4287
@adesuyisunday4287 2 года назад
Nice. Can you do sinewave inverter using stm32 and in hbridge configuration? Something like that
@winnersolutions1982
@winnersolutions1982 4 месяца назад
Congratulations for the good work! Can the STM32F446RE read six input PWM signals (500Hz) simultaneously? Thanks
@dmitrymarukh6857
@dmitrymarukh6857 3 месяца назад
If you use the simple method I've described in my comment, STM32F446 can capture up to 14 PWM signals, depending on the package. TIM1-5 and TIM8 two signals each, and TIM9/TIM12 one signal each. 64-pin RE package may not have all of them available due to pin multiplexing.
@swapnilmeshram8774
@swapnilmeshram8774 2 года назад
Sir CAN you explain, why this same piece of code is not working with Nucleo STM32H743ZI2 board... It is perfectly working fine with Nucleo STM32F767ZI board but with Nucleo STM32H743ZI2 dma interrupt is not working, HAL_TIM_IC_CaptureCallback this function is not getting called once...
@tandungbui5694
@tandungbui5694 10 месяцев назад
Hello sir, i cant understand the variable riseData number meaning. Can you make the video explain the code in callback function?
@tandungbui5694
@tandungbui5694 10 месяцев назад
i use STM32F103 so the maximum Preriod is 65535 but it still get the riseData with uint32_t type. How it can be?
@user-pz6ve6jc3w
@user-pz6ve6jc3w Год назад
I want to measure 40 MHz frequency. How ca I do it ?
@Bianchi77
@Bianchi77 2 года назад
Nice video, thank you :)
@mortezaghorbani7927
@mortezaghorbani7927 7 месяцев назад
how to measure it without input capture?
@deutrion
@deutrion 2 года назад
Thanks forthe video
@ZahraVahidi-ki9pv
@ZahraVahidi-ki9pv 3 месяца назад
I had a question about the PWM function you replaced in minute 7:00; what was the correct one? because actually the one that you replaced wasn't different from the wrong one
@ControllersTech
@ControllersTech 3 месяца назад
It was HAL_TIMex_PWMN_Start
@ZahraVahidi-ki9pv
@ZahraVahidi-ki9pv 3 месяца назад
@@ControllersTech but I again got error with this function; it seems STM32 HAL library doesn't have this function, what can I use instead?
@ControllersTech
@ControllersTech 3 месяца назад
That is why I replaced it in the video.
@ZahraVahidi-ki9pv
@ZahraVahidi-ki9pv 3 месяца назад
@@ControllersTech I get weird output with "HAL_TIM_PWM_Start" too, I'm using STM32F103C8T6
@ZahraVahidi-ki9pv
@ZahraVahidi-ki9pv 3 месяца назад
Thanks for your responding
@mirsadnadarevic-karlsson1463
@mirsadnadarevic-karlsson1463 2 года назад
U are the best
@Andr_e_y
@Andr_e_y 2 года назад
HAL_TIM_IC_CaptureCallback on the f767 board also does not work for me. Judging by the debugging The isMeasured flag is not set
@ControllersTech
@ControllersTech 2 года назад
If you are capturing a low frequency pulse, it will take some time for it to collect the required number of samples..
@Andr_e_y
@Andr_e_y 2 года назад
@@ControllersTech I capture 1 MHz, as in the example. TIM2 - 54MHz count up to 65535.
@sidpan-op8dm
@sidpan-op8dm Год назад
What is dma used for?
@bigmeechmane
@bigmeechmane 2 года назад
Any tips on getting an input capture of a 50 Hz signal with this method?
@ControllersTech
@ControllersTech 2 года назад
Use small frequency for timer..
@bigmeechmane
@bigmeechmane 2 года назад
@@ControllersTech I tried that, I'm hoping to use the 16 bit timer for this task, I've only successfully tested timer 2 (32bit), I'm also using a STM32F4...
@usmanhaider4653
@usmanhaider4653 2 года назад
Plz add serial number to same topic videos.
@surajjadhav7043
@surajjadhav7043 2 года назад
Sir,Can you Please make a video on the Azure RTOS implementation on the STM32
@sugiyartosugiyarto1587
@sugiyartosugiyarto1587 2 года назад
Sir please make look up table using stm32cubemx..thanks
Далее
QSPI in STM32 || Write and Read || N25Q
16:51
Просмотров 27 тыс.
STM32 TIMERS #4. INPUT CAPTURE  || Frequency and Width
13:57
NPC Bloxfruits🤖🔥| Doge Gaming
00:13
Просмотров 1,2 млн
Measuring Signal Period With Timers | VIDEO 35
30:59
Просмотров 2,2 тыс.
STM32 TIMERS #9. One Pulse Mode
13:42
Просмотров 11 тыс.
STM32 DMA ч.1
26:54
Просмотров 1,9 тыс.
STM32. Урок 14. DMA. Direct Memory Access
41:23
Просмотров 12 тыс.
DMA on STM32 HAL with 2 example projects | VIDEO 36
1:03:17