Hello, I am working on setting up a pico with an 8 but ADC. I have some code based on what I thought should work, but i get an error that the read parameter cannot be a StateMachine. If I use the 0x50200020 register for the PIO instead I end up with the byte array as all zeros. I can't figure out what I am doing wrong. I checked the out pin with a scope and get a clock signal and the ADC is actually returning values on the pins, but the data is not making it to the buffer
Thank you
Code:
from machine import Pin, mem32import rp2@rp2.asm_pio(set_init=rp2.PIO.OUT_LOW, autopush=True,push_thresh=8)def parallel_read(): pull(block) mov(x, osr) label("read") set(pins, 1) # set PD high set(pins, 0) # set PD low in_(pins, 8) # read 8 pins and put them into FIFO jmp(x_dec, "read") # take next reading (if any readings left) count = 10 sm = rp2.StateMachine(0, prog=parallel_read, in_base=Pin(0), set_base=Pin(8))ba = bytearray(count * 4) dma = rp2.DMA()sm.active(1) dma.config(read=sm, write=ba, count=count * 4, ctrl=0x0002002b)sm.put(count)
Statistics: Posted by danth — Sat May 25, 2024 3:14 am — Replies 0 — Views 3