krisjdev / pico-baby-if

0 stars 0 forks source link

Data pins being read incorrectly #1

Open krisjdev opened 3 months ago

krisjdev commented 3 months ago

The data input pins (GP 2-9) are not being read correctly by the PIO state machine, and its not 100% clear why. The data output pins (GP 10-17), that are driven by the same PIO program in data_io.pio seem to be correct (as tested via FPGA).

Single stepping through the main program sometimes causes it to read correctly.

Ideas:

Reproduce by cloning the repo at ca337c0, tie GP 2-9 either high or low and observe and incorrect value being read back on the terminal.

krisjdev commented 3 months ago

Reading the GPIO pins directly with gpio_get() does produce the correct values, so it's not got anything to do with the wiring

for (int i = 0; i < 8; i++) {
    printf("pin %d is %d\n", GPIO_IN_DATA_BASE_PIN+i, gpio_get(GPIO_IN_DATA_BASE_PIN+i));
}
krisjdev commented 3 months ago

Partially resolved by adding a new function (babyif_get_data_word_gpio()), but I would much rather that this use the PIO system -- not strictly necessary, but would be nice

https://github.com/krisjdev/pico-baby-if/blob/2f07f9f1f6b9ce9989ae3d9b6d7c3948a186a20e/babyif/babyif.c#L161-L185