High speed ADC code for M4

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ltuser
 
Posts: 14
Joined: Wed Aug 28, 2019 2:53 pm

High speed ADC code for M4

Post by ltuser »

I would like to use circuit python to capture audio. I would like to know if there is any existing code that I can use to capture 1 channel of audio. The sample rate of the M4 is around 1 Msps and I was looking for code that would get the highest sample rate with the Itsy Bitsy M4. Thanks in advance.

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: High speed ADC code for M4

Post by mikeysklar »

There are a few closed issues discussing ADC performance in the github repo for CircuitPython.

I recommend starting with the benchmark code that was originally used to see where you are at.

Code: Select all

import time
import board
import analogio

adc = analogio.AnalogIn(board.A1)

SAMPLES = 256
while True:
    start = time.monotonic()
    for _ in range(SAMPLES):
        adc_val = adc.value
    duration_secs = time.monotonic() - start
    sample_secs = duration_secs / SAMPLES
    rate = 1/sample_secs
    print('Time per sample: {}ms rate:{} Total time: {}ms'.format(sample_secs*1000, rate, duration_secs*1000))
https://github.com/adafruit/circuitpython/issues/484

https://github.com/adafruit/circuitpython/issues

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”