cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S001J3 ADC AIN2 Configuration and Alignment Behavior in STM8S001J3 MCU

shyamparmar
Associate III

Dear STM32 Community,

I am working on the STM8S001J3 microcontroller and trying to configure Pin 7 as ADC channel AIN2. However, I am facing some challenges:

ADC Count Not Generating:
I have configured the pin for ADC operation, but it does not generate any counts. I suspect the issue might be related to ADC initialization or incorrect AFR2/NAFR2 settings. Could someone please guide me with the correct initialization function and the required AFR2 and NAFR2 configuration for ADC channel AIN2?

Alignment Differences:
I observe different values when selecting right alignment or left alignment in the ADC result. I would like to understand whether the values obtained in these two alignments are supposed to be identical or if there is a conversion factor I should consider.

Any advice or corrections to my setup would be greatly appreciated.

Thank you in advance for your help!

1 REPLY 1
AA1
Senior III

I don't understand what are ADC counts.

AFR2 = 0x04. NAFR2 = ~0x04 = 0xFB. But AFR2/NAFR2 are not registers. They are option bytes and are in EEPROM. By now write them with STVP.

RM0016 page 440 explains well data alignment and how to read the result of a conversion.