Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Bug in ADC library


in the Wixel SDK documentation, in the description of adc.h I read that the constant ADC_BITS_10 for setting ADC resolution to 10 bits is equal to 0b00010000. On the CC2511 documentation, section 12.10.3, register ADCCON3, I read that in order to set a decimation rate of 256 (that corresponds to the 10-bit resolution) I’ve to set bit 5:4 to 10, so the ADC_BITS_10 should be 0b00100000.

What is the right value?



Those values listed in adc.h are correct as far as I can tell. if you look into the file
github.com/pololu/wixel-sdk/blo … c/adc.c#L8
at line 8 or so, you see

The ADCCO3 register will be loaded with the correct values.

However if you are not using the ADC libraries but access those registers yourself you need to calculate the bit-values yourself, as you in 12.10.3.



To be clear,
both values are correct, that is, ADCCON3 register will end up with the correct value in both case.
The values from adc.h need to be used with the ADC library, while the values deduced from cc2511 documentation need to be written as is to the ADCCON3 register.