2022-05-16 5:05 PM
Hi guys.
I have 2 GPIOs, one is used as a PWM, the other one is used as ADC.
and the peak comes in the falling edge of the PWM singal.and the plus width is only like 2us.
I want to get the value of the peak voltage using ADC.
The problem is, if I use a interrupt like PWM falling edge, then start the adc, it will take more than 2us. so I cannot get the right value.
is there any solutions to this problem?
PS: I am using STM32G4,fast enough I think.
2022-05-16 6:40 PM
Is it possible to use a simple peak detection circuit (using a diode and capacitor)? Perhaps another gpio pin could be used to reset the peak if needed (via a FET).
2022-05-16 10:22 PM
Hi grestm.
I need to use the value of the peak voltage in my algorithm.
i know the exact timing of the peak voltage shows, but cannot manage to messure it due to the siganl frequency is about 500k.
2022-05-17 12:14 AM
That chip has a fast ADC. You should be able to hardware trigger the ADC using the waveform/GPIO edge and DMA the result to a buffer - and use the DMA half-full interrupt to process the buffered data at a more relaxed rate.
2022-05-17 2:08 AM
Simply start ADC in continuous mode with automatic transfer in circular DMA buffer and ~1µs sampling time.
On edge interrupt read sample position in circular DMA buffer and corresponding value at this position.
So you have also some more samples around the edge available.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.