Skip to content

Commit 7f72619

Browse files
committed
Document SAMD_AnalogCorrection library's 12 bit resolution requirement
The platform bundled SAMD_AnalogCorrection library is only compatible with 12 bit ADC resolution. This can be confusing to the user because: - The definition of ADC_RESOLUTION_BITS in the CorrectADCResponse sketch gives the impression this value can be modified by the user. - The default analogRead() resolution is 10 bits. The first is resolved by the addition of a comment prohibiting changing the value of ADC_RESOLUTION_BITS. The second is resolved by the addition of an `analogReadResolution(12)` call to the code generated by the CorrectADCResponse sketch.
1 parent eb0a10a commit 7f72619

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libraries/SAMD_AnalogCorrection/examples/CorrectADCResponse/CorrectADCResponse.ino

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
6) Open the Serial Monitor and press the reset button on the Arduino ZERO
1919
7) At the and of the procedure you can find logged
2020
- the offset and gain values for the board where the sketch has been just executed
21-
- the instruction line to copy/paste in the final sketch
21+
- the code to copy/paste in sketches using this library
2222
*/
2323

2424
#include "SAMD_AnalogCorrection.h"
@@ -32,7 +32,7 @@
3232
#define ADC_MIN_GAIN 0x0400
3333
#define ADC_UNITY_GAIN 0x0800
3434
#define ADC_MAX_GAIN (0x1000 - 1)
35-
#define ADC_RESOLUTION_BITS 12
35+
#define ADC_RESOLUTION_BITS 12 // do not change. This library only supports 12 bit resolution.
3636
#define ADC_RANGE (1 << ADC_RESOLUTION_BITS)
3737
#define ADC_TOP_VALUE (ADC_RANGE - 1)
3838

@@ -162,7 +162,8 @@ void setup()
162162
Serial.println(offsetCorrectionValue);
163163
Serial.print(" Gain = ");
164164
Serial.println(gainCorrectionValue);
165-
Serial.println("\r\nAdd the next line to your sketch:");
165+
Serial.println("\r\nAdd the next lines to your sketch:");
166+
Serial.println(" analogReadResolution(12);");
166167
Serial.print(" analogReadCorrection(");
167168
Serial.print(offsetCorrectionValue);
168169
Serial.print(", ");

0 commit comments

Comments
 (0)