ADC wrong conversion SAM4E16E

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello.

I have a board with this MCU and this board is powered from +12V baterry. I use resistor divider to measure its voltage. Voltage on ADC input pin is about 2.42V, but when I run my code, measured value in 12-bit resolution is 0xFFF;

 

AVREF is connected to 3.28V like VIOs. When I conected potentiometer on ADC input it looks like TOP value be somewhere about 1.5V.

In real-time debug I didnt found any wrong settings of AFEC(I thinked Gain was wrong but it was 1 :/)

I tried to look for AVREF settings but not I didnt found anything in datasheet.

Thanks for help.

Atmel-ICE
Atmel Studio 7.0

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have no experience with SAM4E but in the ASF example "AFEC Feature Test Example" they configure an offset, maybe that is what you need.

        /*
         * Because the internal AFEC offset is 0x800, it should cancel it and shift
         * down to 0.
         */
        afec_channel_set_analog_offset(AFEC1, AFEC_CHANNEL_0, 0x800);
        afec_channel_set_analog_offset(AFEC0, AFEC_CHANNEL_POTENTIOMETER, 0x800);

/Lars

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Indeed there is such an offset to handle negative and positive ranges by default. You can read this AN (see §1.5):

 

http://www.atmel.com/images/atme...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah that was the problem ... many thanks ;)

SOLVED!

Atmel-ICE
Atmel Studio 7.0