Skip to content

Commit 6202e13

Browse files
committed
pbdrv: adc: ev3: Improve ADC settling time.
Using the max SPI SCLK speed of 20 MHz, the ADC is not able to read up to the full 5V but rather reading somewhere around 50 mV less. By slowing down the SCLK rate, we give the ADC more time to settle after switching the mux and can get more accurate readings as a result. Testing has shown that 1 MHz slow enough to achieve this.
1 parent acaec85 commit 6202e13

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/pbio/drv/block_device/block_device_ev3.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ enum {
7979
*/
8080
enum {
8181
// The maximum ADC clock speed according to the datasheet is 20 MHz.
82-
// However, because the SPI peripheral does not have a fractional clock generator,
83-
// the closest achievable in-spec speed is a division factor of 8.
84-
//
85-
// 150 MHz / 8 = 18.75 MHz actual
86-
ADC_SPI_CLK_SPEED = 20000000,
82+
// However, likely due to capacitance, it takes more time to settle even
83+
// when maxing out other delays like C2T/T2C/WDELAY. Slowing down the
84+
// SCLK adds even more settling time since each CS triggers a conversion
85+
// and triggers the acquisition of the previous conversion.
86+
ADC_SPI_CLK_SPEED = 1000000,
8787
// Time between the end of one SPI operation and start of the next.
8888
ADC_SAMPLE_PERIOD = 2,
8989
};

0 commit comments

Comments
 (0)