pico-examples icon indicating copy to clipboard operation
pico-examples copied to clipboard

Confusing comment on the `pio_i2c` example

Open ithinuel opened this issue 4 years ago • 1 comments

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.pio should be amended and the code in pio_i2c.c be simplified.

ithinuel avatar Oct 14 '21 07:10 ithinuel

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?

lurch avatar Oct 14 '21 11:10 lurch