2020-02-16 08:43 PM
Hi everyone,
I have some questions about using ADC. I have an analog channel and want to read it for a specified time according to my PWM signal because it has been used as a voltage sense on an inductor. However, I need more samples and have to check the changes. To do this, set two-timers, one has been used to get compare of PWM value, other trig the ADC for 100samples. Here I am confused right here. I'm not sure how to calculate the timing, also I'm afraid of getting overrun and wrong data. So, I need your help and have some questions about this application. By the way, I'm using STM32G431 which is new MCU.
2020-02-17 04:03 AM
DMA transfers nonetheless occupy the bus.
And the core must still process the high amount of ADC samples.
2020-02-17 04:25 AM
DMA should be started once the signal reaches a certain level, leaving the analog watchdog window. When the required amount of samples are collected, DMA stops, and no longer occupies the bus. ADC doing conversions itself have no impact on the rest of the system (except on power consumption).
2020-02-17 04:42 AM
> DMA should be started once the signal reaches a certain level, leaving the analog watchdog window.
Which would require careful evaluation of the attached hardware. Noise shall not trigger false "PWM" cycles then.
With motor control or similar hardware with substantial coil inductances (and the resulting EMF), this could be the case.
2020-02-17 04:59 AM
Then, if I use the compare event of PWM to start DMA while in ADC conversion mode, it will take as many samples as the number of samples I have specified and occur interrupt. It will wait until the next event, so it will not work. I'm right?
2020-02-18 04:21 AM
Then, if I use the compare event of PWM to start DMA while in ADC conversion mode, it will take as many samples as the number of samples I have specified and occur interrupt. It will wait until the next event, so it will not work. I'm right?
2020-02-18 04:55 AM
Hi
If you want to convert the maximum of samples during the T (according to your drawing) using the ADC in DMA mode with the Trigger on the rising edge of your signal, yes if it will work.
Have you tried to code something in this way ?
Is that what you asked for and explained in your diagram ?
And what do you want to do with ADC converted value ? mathematical post processing ? amplitude monitoring ?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2020-02-21 01:30 AM
I have tried continous mode and trigged compare event but there has been sync error.
To test sampling time, I toggles a pin. The time is not constant, always changes.