PIO sender : need a 3d register as storage : fair to use ISR register? #15855
Unanswered
VigonOracle
asked this question in
RP2040 / Pico
Replies: 2 comments
-
It should be fair. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Here's an example of using the OSR to cache an extra parameter. Note that this is a part of a bus analyzer I wrote, that compresses data and only returns transitions, instead of all the data. I will be putting the whole thing up on github when I get around to it. Also not that this uses some variables when it compiles to include (or not) some PIO code. def pio_pins():
"""build PIO program with compiled-in variables from our namespace"""
# this uses osr as an extra register, since no data comes into here
if trigger_pin is not None:
# wait for toggle in the right direction on the trigger channel
wait(1 - trigger_polarity, gpio, trigger_pin)
wait(trigger_polarity, gpio, trigger_pin)
wrap_target()
label("loop")
mov(y, osr) # retrieve count from cache
jmp(y_dec, "count") # decrement time counter (can't increment!)
label("count")
mov(osr, y).delay(extra_delay_cycles) # cache count
mov(isr, null) # clear shift register
in_(pins, pin_count)
mov(y, isr) # get new word for comparison
jmp(x_not_y, "changed")
# keep cycle count the same by setting delay
jmp("loop").delay(_delay_cycles)
label("changed")
mov(x, y) # update current value
push() # first word is data, already in isr
mov(isr, invert(osr)) # get current count
push() # push it
wrap() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm quite new to PIO on rp2040, and just wrote à DIO protocol sender (one output pin only). I want to reuse pulled value several time (repeat for RF sending), so I have to store the OSR value before OUTing it. As I already need x and y general purpose registers for other function, is it fair to make something like :
So long story short : is it good practice to use ISR as a storage register as my PIO doesn't push data?
Beta Was this translation helpful? Give feedback.
All reactions