cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 ADC Trigger using PWM out pin to measure the frequency

VDhev.1
Associate II

Hi,

We want pwm out raising edge should trigger the adc conversion after that callback should trigger then we can able to measure input adc frequency.

We know timer peripheral can trigger the adc we don't know how to implement.

Which timer we has to use for our application (HRTIM, Advanced Timer).

Adc callback should trigger every pwm raising edge to get the adc value and the timestamp to calculate the frequency.

Please help to get solve this issue.

6 REPLIES 6
Javier1
Principal

"We want pwm out raising edge should trigger the adc conversion after that callback should trigger then we can able to measure input adc frequency."

oh man im having hard time understanding you, you should try google translate.

You meant this?

0693W00000GYBmsQAH.png

in case you dont know what to google https://www.google.com/search?q=stm32+triggering+adc

What i believe you want to do is quite straight foward and normal way of triggering ADC readings

Depends of what ADC youre using but if you go to cubeMX: you can see which timers have the option to trigger your adc conversions

0693W00000GYC01QAH.pngThen you just configure your tim3/8/... to trigger event (it doesnt need to have any pwm channel on for you aplication)

0693W00000GYCFPQA5.png

VDhev.1
Associate II

Hi @Javier Muñoz​,

Thanks you for your reply.

0693W00000GYLCyQAP.pngI want to generate pwm output with 500HZ 50%duty cycle.

This PWM output and ADC trigger should be linked together.

Every PWM output rising edge adc callback should be triggered to read the adc value after that internally capture the timestamp of two different rising edge to measure adc frequency (means input and output adc frequency should be same).

Above mentioned logic which timer would be possible?

Thanks & Regards,

Vasu

As i said thats the normal way of triggering an ADC, any PWM triggered ADC tutorial should work for you.

>Every PWM output rising edge adc callback should be triggered to read the adc value after that internally capture the timestamp of two different rising edge to measure adc frequency (means input and output adc frequency should be same).

The adc sampling frequency will have the same fixed frequency as the PWM triggering it , i dont see why you want to calculate it

VDhev.1
Associate II

Hi,

The adc sampling frequency will have the same fixed frequency as the PWM triggering it , i dont see why you want to calculate it

  • In order to find hardware failure and environmental condition.

I dont understand what you want to archieve, sorry, icannot help.

If youre worried about hardware faliure check some tutorial about the watchdog usage .