Does this mean the buffer is always running?
How much of delay is there between the IRQ event and the start of the read_timed function?
I believe I'm missing something critical and would appreciate any insights. Ideally, there would be a mechanism to acquire a circular buffer and mark when a trigger arrives and simply roll the array. In short, I'd like to realize some sort of scope type function as my application requires multiple signal averaging events to obtain decent signal to noise ratio.
PYBD SF3W 1.12 with the ulab library
Other pertinent details include setting the system frequency in boot.py: machine.freq(216000000)
Other relevant posts that don't fully address the issue:
viewtopic.php?f=16&t=9163&p=51609&hilit ... lay#p51609
viewtopic.php?f=2&t=6840&hilit=trigger+delay&start=10
viewtopic.php?f=6&t=4700&p=27229&hilit= ... upt#p27229
Code: Select all
import micropython
from pyb import ExtInt, Pin, LED
import ulab as np
import gc
micropython.alloc_emergency_exception_buf(100)
trigCount = 0
adc = pyb.ADC('X1')
buf = np.zeros(10000)
sumBuf = np.zeros(10000)
timerADC = pyb.Timer(4, freq=200000)
def sumCB(arg):
'''
So the question is whether or not we disable IRQs during this operation?
What if another trigger comes?
Ultimately to be used for signal averaging
'''
global sumBuf
global buf
sumBuf = buf+sumBuf
# gc.collect()
def readCB(arg):
n=adc.read_timed(buf,timerADC)
global trigCount
trigCount+=1
# gc.collect()
micropython.schedule(sumCB, 'Sum Arrays')
ex1 = ExtInt('X9', ExtInt.IRQ_RISING, Pin.PULL_UP, readCB)