RP2350B: Working on Bidirectional bus using PIO at two different state machines (MicroPython 1.27.0) #19020
Replies: 3 comments 2 replies
-
You're reading directly (a few ns) after toggling the direction, thus reading the inherent capacitance effects of those lines or pins. And – btw – what are the PIOs doing after they have been activated? Execute what ever is in the remaining parts of the 32 WORDS? You probably want some sort of a STOP command and a restart before using them again. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @GitHubsSilverBullet , thanks for the help. I have spaced out the time (more than one second) between the read and the writes, however it is still giving me the last write. Also, I have made a mistake on the PIO - the SM should be in the loop waiting for the system to issue reads/writes. I have added the @rp2.asm_pio(out_init=(rp2.PIO.OUT_LOW,) * 16, out_shiftdir=rp2.PIO.SHIFT_RIGHT)
def write_data():
wrap_target()
mov(pindirs, ~null)
pull()
out(pins, 16)
wrap()
@rp2.asm_pio(out_init=(rp2.PIO.OUT_LOW,) * 16, in_shiftdir=rp2.PIO.SHIFT_LEFT)
def read_data():
wrap_target()
mov(pindirs, null)
in_(pins, 16)
push()
wrap()However, this still got stuck at the |
Beta Was this translation helpful? Give feedback.
-
|
There's a difference between wrap_target()
mov(pindirs, null) # change to input
in_(pins, 16) # read |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Micropython team,
I'm trying to perform a read and write on the same bus without accidentally reading the previous written value.
The issue seems to be if after I have written the bus (at "write enable") for example 0xA5A5, and then reading it back (at "write disable/Read enable") it gives me the last written value.
Here is the context: I'm writing a sample code for reading/writing on a S29GL Flash. The board and the NOR flash are already connected in a board I personally did.
I have split the writing of address and data on different state machine and different PIO too:
SM0 = address pins on GPIO16-39 @ PIO0
SM4 = write data pins on GPIO0-15 @ PIO1
SM5 = read data pins from GPIO0-15 @ PIO1
I was advised to change the
pindirswhen working on bidirectional pins. So I added thesemov(pindirs, null)andmov(pindirs,~null)accordingly in each of the state machine, read and write respectively.However, when switching to the inputs (
mov(pindirs,~null)) at reading the bus, it stalled after the first read. I'm not able to pinpoint whether I have left important command or setting beforehand.I'm a bit stuck here after searching all over the place for some similar attempts, so I appreciate any help. :D
Beta Was this translation helpful? Give feedback.
All reactions