cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with simple 3-channel ADC reading

Jim Seymour
Senior
Posted on July 17, 2015 at 18:46

I'm new to the STM32 and am trying to read three ADC channels on an F0 part.  I've used the STM32CubeMX utility to configure my hardware and then have looked over some of the ADC examples in the STM32Cube_FW_F0_V1.2.0 package.

However, I've not seen a simple example that shows how to read three channels.  I don't need fast access.  I don't need DMA.  I just need to read all three pins in a loop that's going to execute perhaps once every 100 milliseconds.

Can someone help point me to some sample code?

I tried using the ADC_DMA_Transfer example, but it seems that I only get one reading (not all three).  I must be missing something simple.

3 REPLIES 3
Posted on July 17, 2015 at 19:33

I don't need DMA.

The way the STM32 works, you kinda do.

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F0%20ADC-DMA%20touble&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=1522

Can't help you with the HAL/Cube stuff.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Jim Seymour
Senior
Posted on July 17, 2015 at 21:26

Thanks for the reply.  Your code is using function calls I'm not familiar with.  (eg: ADC_DMACmd()).  The code generated by STM32CubeMX use functions in the form ''HAL_ADC_*''.

Which method is ''best''?  And where can I find the routines that you used?

I'm developing with the Keil uVision5, if that matters.

Posted on July 17, 2015 at 23:02

I use the SPL (Standard Peripheral Library), a library ST has used in similar form for their ARM parts over the last decade or so.

http://www.st.com/web/en/catalog/tools/PF257884

Ignore all the distractions, there is a Red Download button way down at the bottom.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..