pico-examples
pico-examples copied to clipboard
Confusing comment on the `pio_i2c` example
The PIO comments in i2c.pio state that:
; The TX FIFO should be accessed with halfword writes, to ensure
; the data is immediately available in the OSR.
In the c-sdk, the Tx FIFO is declared as an array of 32bit write only integers but the c code in pio_i2c.c goes some length to do 16bit writes.
This is a confusing claim as 32bits writes are expected to be atomic anyway.
I could not find information in the datasheet to confirm or deny that statement.
- If that is really necessary the datasheet should be updated with some explanation as to why this is required.
- If not the comment in
i2c.pioshould be amended and the code inpio_i2c.cbe simplified.
That might just be because of the 16-bit data format that i2c.pio has chosen to use for the TX FIFO? :shrug:
; TX Encoding:
; | 15:10 | 9 | 8:1 | 0 |
; | Instr | Final | Data | NAK |
I'm fairly sure there are probably other PIO examples that do full 32-bit writes to the TX FIFO?