2018-09-04 11:26 AM
Hi, i want to try adc ch0 and ch1 in stm32f053 nucleo, i have 10k ohm and 1k ohm between 3v3, gnd and analog input. ( Basically voltage divider for measure.)
However, i've faced absurd values in adc channel and, these values never changes. I'm sharing all of the codes about adc initialization and main. I just want to read number between 0-2047. Where am i wrong ? Thans a lot.
Here is pins, where i want to measure adc values.
This is adc_init function as you see.
This is hal_msp_init function as you see.
This is the main for init adc functions in my main.
Also while loop.
Finally, i've faced this result when i was debugging.
I know there is a point i've missed. Where am i wrong ?
With warmest regards.
2018-09-04 10:05 PM
Just took a brief look at you code the first thing i can think of is try call HAL_ADC_Start after HAL_ADC_MspInit.
It also looks like you code expect to use Continues Conversion mode being enabled which is not the case.
If using continues conversion you should consider changing the overrun behavior to overwrite data, so that you get the latest conversions.
I do not know if it helps but this is my best guess
2018-09-04 11:12 PM
Yes, this solving sound like works however i is not worked, i've changed Msp_init and Adc_Start also changed ADC_OVR_DATA_OVERWRITTEN instead of ADC_OVR_DATA_PRESERVED. It is working same adc value, like "134217959" and never changes.
Thanks for your help
2018-09-05 01:56 AM
It seems you have a datatype problem with your display.
ADC data are 12 bit at most, and usually represented as unsigned short (uint16_t).
I don't dig into HAL code, though.