STM32 ADC?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-05 09:26 AM
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
Solved! Go to Solution.
- Labels:
-
ADC
-
DMA
-
LPTIM
-
STM32WB series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-05 01:43 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-05 09:41 AM
> When doing more than one channel must I use DMA??
Effectively, yes. Or interrupt and handle it before the next sample arrives.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-05 11:25 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-05 11:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-05 01:03 PM
STM32WB55
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-05 01:43 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-05 02:02 PM
Thanks that worked....had to increase both to 94.5 ADC cycles (running at 16MHz)....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-05 02:51 PM
If you use injected channels, you can convert 4 channels at high speed and get the results on 4 data register.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-05 04:12 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-06 02:00 AM
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.