ADC Performance CPU Latency

Brief

Measure ADC result read latency from CPU

Details

This example demonstrates CPU latency when reading ADC (Analog-to-Digital Converter) results. The application performs multiple ADC conversions and measures the average number of CPU cycles required to read each conversion result across multiple reads, validating that the read latency falls within acceptable bounds.

Block diagram

Test cases:

  • Runs several iterations of ADC conversions.

  • For each iteration

    • Forces the ADC sequencer to start conversion

    • Waits for completion signal

    • For each SOC channel, performs multiple consecutive reads and measures average CPU cycles per read

  • Uses hardware counters to measure read latency, accounting for counter overhead

    • overheadCycles: Calculated once upfront by measuring two consecutive counter reads

    • startCycles: Timestamp captured before the multiple-read loop

    • ADC Read Operations: Performs APP_ADC_READS_PER_SOC consecutive reads of the SOC

    • endCycles: Timestamp captured after completing all reads

    • Average Calculation: Subtracts overhead, then divides total cycles by APP_ADC_READS_PER_SOC to get average cycles per read

Validation:

  • The example validates that read latency falls within an acceptable range

    • 2-6 CPU cycles.

Peripherals used

ADC
  Instance  : APP_ADC
     Sequencers  : 1
     SEQ1        :
       SOCs      : SOC0 to 15. All on the same channel
     Interrupts  :
       INT1      : Enabled. Src-SOC15

VREF
    Reference   : Internal
       Mode      : 3.3V range
SoC
    INTERRUPTS
       Instance  : APP_ADC_INT1_INT
         Source  : ADC INT1
         Handler : APP_ADC_INT1_INT_Handler

External connections

Analog signal input to ADC pin

  • Connect: BoosterPack header J3 pin 23 to Analog signal from an external source

LED Details: PASS LED (LED8), FAIL LED (LED7)