PDA

View Full Version : ADC configuration



rbrockman
11-16-2012, 04:44 AM
Looking for some input on how to configure each ADC input.

I'd like to be able to set:
* voltage reference
* adc resolution
* averaging

I see the function analogReference(uint8_t type), but it does not look to be implemented yet. Same with analogReadRes(unsigned int bits).

I'm working with ADC0_SC2 = ADC_SC2_REFSEL(1); to set the analog referece to 1.2v, but am not sure how it should be used, and how to set each adc channel.

Anyone care to share?

JBeale
11-16-2012, 06:51 AM
Note that there is only one ADC converter. The various analog input pins connect to it through a multiplexer. So whatever ADC configuration you have set up, applies to all input pins. Note also, there is a calibration procedure that must be done after changing any ADC setting.

There is a little bit of information here on speeding the ADC by changing from the default of 32 averaged readings, to single readings:
http://forum.pjrc.com/threads/38-Help-with-ADC-speed

This post links to some more extensive example code showing ADC setup and calibration:
http://forum.pjrc.com/threads/407-Teensy-3-0-ADC-details?p=951&viewfull=1#post951

rbrockman
11-17-2012, 12:31 AM
Thank you for pointing out these links.

There really needs to be a wiki to document the major functionality and various library functions.