I guess it is not just a question Keil product, but I need your advice. I am using STM32f1 with CubeMX and keil mdk5. in my project i have to read muti channel ADC value ADC is in Scan conversion mode Enable, Number of conversion 2, Rank1 Channel Temperature sensor and Rank 2 Chane Vrefint.
while(1){ HAL_ADC_Start(&hadc); while(HAL_ADC_PollForConversion(&hadc,0) != HAL_OK); channel_1 = HAL_ADC_GetValue(&hadc); while(HAL_ADC_PollForConversion(&hadc,0) != HAL_OK); channel_2 = HAL_ADC_GetValue(&hadc); HAL_ADC_Stop(&hadc); }
Problem is booth call HAL_ADC_GetValue() retint value of Rank1 ti is voltage on Channel Temperature sensor. I can not figure out how to read value from next RANK 2
Thanks for help.
If you don't want to use DMA you have to reconfigure ADC for each channel and read one by one. In other case - you must use DMA to obtain data from more than one channel. DMA is easy, what's the problem using it?
My point is to have a precisely defined time of sampling individual channels. For example in time 0ms chamel1 in time 1ms chamel2 in time 5ms chamel3 etc.
I change my idea and I use DMA
As I remember ADC may give you interrupt after each conversion. Even when using DMA.