cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 ADC?

SWenn.1
Senior III

Good morning......

I am using the ADC with 2 channels (Ch 9 and Ch 10). I am using an LPTIM to take these samples every 15ms. I have the ADC callback (HAL_ADC_ConvCpltCallback) to interrupt on 'End of sequence of conversion' (per .ioc --- or so I think). Can someone tell me what registers in the ADC I should be looking at to find the analog values of the two channels? I am not using DMA and only see one DR (Data Register in the module). When doing more than one channel must I use DMA??

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

See "Managing a sequence of conversions without using the DMA" in the reference manual.

I doubt 24.5 ADC cycles is enough to read the value in time to avoid the overrun. But it's possible. It doesn't wait for you to read the value before converting the next channel.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

9 REPLIES 9
TDK
Guru

> When doing more than one channel must I use DMA??

Effectively, yes. Or interrupt and handle it before the next sample arrives.

If you feel a post has answered your question, please click "Accept as Solution".
SWenn.1
Senior III

So I am using interrupts.....I have multiple A/D channels selected (2) and SCAN mode enabled. I am using software to trigger the A/D. If I set End of Conversion selection to be 'End of Single Conversion' won't I go into the ISR to transfer the first value from the DR then because of scan mode (and maybe I have to set continuous mode here as well???) won't I then do another A/D sample without having to send another trigger and pop back into the ISR after that one has set the EOC flag? In effect I would then just capture DR in the next element of the array ......No DMA needs to be involved

0693W00000HqhN1QAJ.png

And what chip are you using?
If you feel a post has answered your question, please click "Accept as Solution".
SWenn.1
Senior III

STM32WB55

TDK
Guru

See "Managing a sequence of conversions without using the DMA" in the reference manual.

I doubt 24.5 ADC cycles is enough to read the value in time to avoid the overrun. But it's possible. It doesn't wait for you to read the value before converting the next channel.

If you feel a post has answered your question, please click "Accept as Solution".
SWenn.1
Senior III

Thanks that worked....had to increase both to 94.5 ADC cycles (running at 16MHz)....

Nikita91
Lead II

If you use injected channels, you can convert 4 channels at high speed and get the results on 4 data register.

SWenn.1
Senior III

What do you recommend for sampling one channel at a relatively high frequency (say 10ms) and then every 50th sample grabbing BOTH the high frequency channel as well as a second low frequency channel? I am used to doing this in the MSP430 world but it definitely seems different here in STM32......

It almost seems like I have to have the ADC set up in single conversion mode then via a counter at 50 change to scan with dma or something.....The injected channel would work BUT it would definitely throw off the sampling period of the 50th high frequency channel which would affect FFTs, etc.

Nikita91
Lead II

100 Hz is compatible with interrupt.

Can use 2 injected channels, and in the end of scan interrupt handler read the high frequency ADC value, and every 50 read also the low frequency ADC value.