You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to use the PIOs to read 8 bit serial data and speed seem terrible, any idea what is going on:
importtimeimportrp2fromtimeimportticks_ms, ticks_difffromrp2importPIOimportmicropythonfrommachineimportPin@rp2.asm_pio(autopull=True, sideset_init=PIO.OUT_LOW)defblink():
set(x, 1)
wrap_target()
in_(x, 8).side(1)
push(iffull, block).side(0)
wrap()
# Instantiate a state machine with the blink program, at 2000Hz, with set bound to Pin(25) (LED on the Pico board)sm=rp2.StateMachine(0, blink, freq=16_000_000, set_base=Pin(25), in_base=Pin(0))
sm.active(1)
@micropython.viperdefread(sm, buffer):
foriinrange(128):
sm.get(buffer)
# Run the state machine for 3 seconds. The LED should blink.buffer=memoryview(bytearray(1024))
start=ticks_ms()
read(sm, buffer)
end=ticks_ms()
print(ticks_diff(end, start) /1000)
Frequency of the PIO is 16MHz, it reads 8 bits every other cycle so 8 * 16 /2 = 64Mb/s = 8MB/s
I try to fill a 1024bytes 128 times so I expect it to be give or take 125ms. When I run the code it takes 1376 so roughly 10x what I expect.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I was trying to use the PIOs to read 8 bit serial data and speed seem terrible, any idea what is going on:
Frequency of the PIO is 16MHz, it reads 8 bits every other cycle so 8 * 16 /2 = 64Mb/s = 8MB/s
I try to fill a 1024bytes 128 times so I expect it to be give or take 125ms. When I run the code it takes 1376 so roughly 10x what I expect.
What is going on here ?
Beta Was this translation helpful? Give feedback.
All reactions