Matt Venn
12/22/2023, 1:21 PMMatt Venn
12/22/2023, 1:23 PMMatt Venn
12/22/2023, 1:24 PMMatt Venn
12/22/2023, 1:24 PMMatt Venn
12/22/2023, 1:24 PMTim Edwards
12/22/2023, 1:38 PMMatt Venn
12/22/2023, 1:39 PMMatt Venn
12/22/2023, 1:39 PMTim Edwards
12/22/2023, 1:48 PMMatt Venn
12/22/2023, 1:49 PMTim Edwards
12/22/2023, 1:50 PMMatt Venn
12/22/2023, 1:50 PMTim Edwards
12/22/2023, 2:06 PM|=
and &=
; that implies a memory read followed immediately by a memory write. I will stare at the housekeeping code a bit---the housekeeping GPIO access is a little awkward because it shares the registers between the wishbone and SPI interfaces, and so it does all 32-bit reads and writes as four separate 8-bit reads and writes, which might have something to do with the phenomenon you're seeing. Meanwhile, does it work if you replace the expression with a separated read and write?---#define SET(PIN,N) (PIN = PIN | (1<<N))
or #define SET(PIN,N) (temp = PIN; PIN = temp | (1<<N))
?Matt Venn
12/22/2023, 2:07 PMMatt Venn
12/22/2023, 2:08 PMTim Edwards
12/22/2023, 2:10 PMreg_mprj_io_32/34/36
to GPIO_MODE_MGMT_STD_OUTPUT
to begin with. The user project will be able to read the value regardless.Matt Venn
12/22/2023, 2:11 PM#define SET(PIN,N) (PIN = PIN | (1<<N))
doesn't work. as soon as the next set happens it clears all other bitsTim Edwards
12/22/2023, 2:11 PMreg_mprj_datah
only, or is it also true for reg_mprj_datal
?Matt Venn
12/22/2023, 2:12 PMMatt Venn
12/22/2023, 2:13 PMMatt Venn
12/22/2023, 2:15 PMTim Edwards
12/22/2023, 2:16 PM#define SET(PIN,N) temp = PIN; PIN = temp | (1<<N)
without the outer parentheses around the expression. Or maybe #define SET(PIN,N) {int temp = PIN; PIN = temp | (1<<N)}
(which may be better as it allows the variable temp
to be defined within the context of the definition).Matt Venn
12/22/2023, 2:18 PMTim Edwards
12/22/2023, 2:19 PMMatt Venn
12/22/2023, 2:19 PMMatt Venn
12/22/2023, 2:19 PMMatt Venn
12/22/2023, 2:20 PMMatt Venn
12/22/2023, 2:20 PMTim Edwards
12/22/2023, 2:22 PMMatt Venn
12/22/2023, 2:23 PMTim Edwards
12/22/2023, 2:23 PM|=
expression implies a read followed by a write.Matt Venn
12/22/2023, 2:24 PMMatt Venn
12/22/2023, 2:31 PMMatt Venn
12/22/2023, 2:31 PMMatt Venn
12/22/2023, 2:31 PMMatt Venn
12/22/2023, 2:32 PMMatt Venn
12/22/2023, 2:35 PMMatt Venn
12/22/2023, 2:36 PMTim Edwards
12/22/2023, 2:39 PMGPIO_MODE_MGMT_STD_BIDIRECTIONAL
(make sure it's defined as 0x1801
).Matt Venn
12/22/2023, 2:40 PMMatt Venn
12/22/2023, 2:40 PMTim Edwards
12/22/2023, 3:32 PM|=
doesn't work is that the GPIO data read value is not equal to the GPIO data write value. I think that STD_BIDIRECTIONAL
must be set on all channels for this to work. Because the read value is the value at the pad. If the pad input buffer is turned off (by using STD_OUTPUT
), then it will read back zero. This should probably be better explained in documentation (also, it might be a good idea to change the implementation so that when the input buffer is off, the register value will be read back instead of the pad value. Or have an additional bit to toggle between reading from the pad vs. reading from the register value).Tim Edwards
12/22/2023, 3:58 PMGPIO_MODE_MGMT_STD_BIDIRECTIONAL
on all the GPIO pads you're trying to set from the management side, and then the original expression with reg_mprj_datal |= ...
should work like you expect.