Skip to content

analog_read() sampling rate is much slower than wiring.c thinks it is #387

@mzero

Description

@mzero

//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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions