I'm trying to use the oversampling feature of the ADuCM4050 to produce 14-bit values from the ADC channels.
The steps I'm doing to initialize the ADC peripheral are:
From there I can start a conversion by setting the SINGLE bit in the ADC_CNV_CFG register, wait for the conversion to be completed using the DONE0 bit in the ADC_STAT register or the conversion done interrupt and it gives me a 12-bit value as expected.
Then I tried configuring the oversampling per the user manual: I set the OS and EN bits of the ADC_AVG_CFG register and set the FACTOR bits to one of the following values: 0x02 for 13-bit, 0x08 for 14-bit, 0x20 for 15-bit, 0x80 for 16 bit.
With this configuration the ADC output values 2, 4, 8, 16 times bigger than the related 12-bit value for 13, 14, 15, 16 bits, respectively, as expected.
Finally, I tried putting the MCU into hibernation mode. I de-initialize the ADC and put it to sleep, when the MCU wakes up I re-initialize the ADC and try to do readings again. From this point on, the ADC values are divided instead of multiplied by the expected value: outputs are 1/2, 1/4, 1/8, 1/16 of the original value when configuring for 13, 14, 15, 16 bits, respectively.
Am I doing something wrong? How can I get the ADC to output values with resolution higher than 12 bits in this situation?
Thanks in advance.
Try to re-enable the ADC_AVG_CFG.EN bit upon waking up from hibernate mode since this bit is not retained when chip goes into hibernate mode.
For more details about this refer to the Harware Reference Manual.