c - STM32f3 - Multiple ADC -


i have , stm32f3 discovery board, , i'm trying use 4 adc channels. read function:

int adc_read(int channel) {     adc_regularchannelconfig(adc1, channel, 1, adc_sampletime_7cycles5);     adc_startconversion(adc1);     while (adc_getflagstatus(adc1, adc_flag_eoc) != set);     return adc_getconversionvalue(adc1);     } 

everything goes well, until program stucks in while loop. there way avoid putting adc_flag_eoc in loop? or other way make program work?

is far understand depending on version of board using must use adc_softwarestartconvcmd or adc_startconversion.

so maybe not starting adc conversion properly, please try this:

adc_regularchannelconfig(adc1, channel, 1, adc_sampletime_7cycles5);  #if defined(series_stm32f10x)   adc_softwarestartconvcmd(adc1, enable); #elif defined(series_stm32f30x)   adc_startconversion(adc1); #else   adc_softwarestartconv(adc1); #endif  while(adc_getflagstatus(adc1, adc_flag_eoc) == reset); return adc_getconversionvalue(adc1); 

also, don't forget set pins mode input with: pinmode(pin, input_analog);

finally, take @ post user had similar problem yours , solved re-enabling external trigger with:

adc_initstructure.adc_externaltrigconv = adc_externaltrigconv_none; 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -