I'm attempting to multi-thread data collection to get a better bandwidth. I am using the Timer micropython class. This code takes one data point into my array but doesn't loop like I wanted. Am I missing some piece of code? Does the way I setup my timer make sense?
[def _addData_():
global adcPin
global dataArray
global curPos, numPnts, countDown
dataArray[curPos] = adcPin()
curPos += 1
curPos %= numPnts #resets curPos
countDown -= 1
if countDown <1:
timChannel.irq(handler=None, trigger = Timer.TIMEOUT)
global tim
global timChannel
tim = Timer(0, mode = Timer.PERIODIC, width = 32)
timChannel = tim.channel(Timer.A | Timer.B, freq = freq)
timChannel.irq(handler = _addData_(), trigger = Timer.TIMEOUT)
time.sleep_ms(1000)
]