Skip to main content
VDhev.1
Associate
November 19, 2021
Question

STM32G4 ADC Trigger using PWM out pin to measure the frequency

  • November 19, 2021
  • 3 replies
  • 2495 views

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.

This topic has been closed for replies.

3 replies

Javier1
Principal
November 19, 2021

"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

hit me up in https://www.linkedin.com/in/javiermuñoz/
Javier1
Principal
November 19, 2021

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

hit me up in https://www.linkedin.com/in/javiermuñoz/
VDhev.1
VDhev.1Author
Associate
November 21, 2021

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

Javier1
Principal
November 22, 2021

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

hit me up in https://www.linkedin.com/in/javiermuñoz/
VDhev.1
VDhev.1Author
Associate
November 22, 2021

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.
Javier1
Principal
November 22, 2021

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

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

hit me up in https://www.linkedin.com/in/javiermuñoz/