|
//set to 1/(1/(48000000/32) * 6) = 250000 SPS |
This comment in wiring.c is wrong:
//set to 1/(1/(48000000/32) * 6) = 250000 SPS
The code that follows this comment sets ADCs clock to 48M with a /32 prescale; and the sampling length to 6 clocks.... But a read of the ADC takes an additional clock for every bit produced. As wiring.c sets the ADCs to be 10 bit, the actual samples-per-second value is:
//set to 1/(1/(48000000/32) * (6+10)) = 93750 SPS
See Figure 45-4 in §45.6.2.8. Conversion Timing and Sampling Rate in the SAM D5x/E5x Family datasheet:
https://onlinedocs.microchip.com/oxy/GUID-F5813793-E016-46F5-A9E2-718D8BCED496-en-US-15/GUID-779D7258-1411-4AEE-B40D-4B7E7A2242BD.html
ArduinoCore-samd/cores/arduino/wiring.c
Line 118 in 26c39c0
This comment in
wiring.cis wrong://set to 1/(1/(48000000/32) * 6) = 250000 SPSThe code that follows this comment sets ADCs clock to 48M with a /32 prescale; and the sampling length to 6 clocks.... But a read of the ADC takes an additional clock for every bit produced. As
wiring.csets the ADCs to be 10 bit, the actual samples-per-second value is://set to 1/(1/(48000000/32) * (6+10)) = 93750 SPSSee Figure 45-4 in §45.6.2.8. Conversion Timing and Sampling Rate in the SAM D5x/E5x Family datasheet:
https://onlinedocs.microchip.com/oxy/GUID-F5813793-E016-46F5-A9E2-718D8BCED496-en-US-15/GUID-779D7258-1411-4AEE-B40D-4B7E7A2242BD.html