current measurement (ADC) when pwm is ON.
Hi,
I have stm32wle5 and a circuit to measure current. stm32 will generate a PWM using timer1 ch1. The opamp's output is also connected to the ADC input of stm32. I want to measure the current (read ADC values) when PWM is on. Preferably in the middle of the PWM high edge. In most of the examples, people use internal triggers to trigger ADC. I thought as all channels of one timer have the same frequency, can I use one channel to output pwn and another channel as PWM generation without output just to trigger ADC? And set their duty_cycle and everything the same? I'm unsure if they are entirely synced and if this is the right solution. Do you have any other recommendations?
I also don't know how to do the measurement at the middle of PWM's high edge.
circuit:
timer1 and channel one config:
timer1 ch2 config:
ADC config:
Note that I don't do a continuous conversion and just want one or maybe a few samples and take the average in each PWM period.
Any help would be appreciated.
Thanks
UPDATE:
I want to do one single measurement every hour but do this when the MOSFET switch is on, e.g., PWM output is one.
