i try to sample an analog signal at 40khz with adc but i dont success to do it in real time in this code :
Code: Select all
import time, pyb from pyb import ADC adc = pyb.ADC(pyb.Pin("P6")) # create an ADC on pin P5 tim = pyb.Timer(6, freq=40000) # create a timer running at 10Hz buf = bytearray(5) # creat a buffer to store the samples while(True): # The ADC has 12-bits of resolution for 4096 values. print("----------") adc.read_timed(buf, tim) # sample here i=1 for val in buf: # loop over all values print(i, val) # print the value out i=i+1 time.sleep(1000)
Do you have another way to do this ?