I am trying to use this (github) to read input from the J.00 to J.07 registers as fast as possible by changing the code:
// set up a pointer for convenient access -- this pointer is to the selected GPIO controller
GPIO_mem volatile *pin = (GPIO_mem volatile *)((char *)base + (GPIO_2 & pagemask));
pin->CNF[0] = 0x00ff;
pin->OE[0] = 0xff;
pin->OUT[0] = 0xff;
// pin->IN = 0x00; read only
// disable interrupts
pin->INT_ENB[0] = 0x00;
// don't worry about these for now
//pin->INT_STA[0] = 0x00;
//pin->INT_LVL[0] = 0x000000;
//pin->INT_CLR[0] = 0xffffff;
fprintf(stderr, "press ctrl-C to stop\n");
// "blink" the output values
uint8_t val = 0xff;
while (true) {
sleep(1);
val = val ^ 0xff;
pin->OUT[0] = val;
}
to:
// set up a pointer for convenient access -- this pointer is to the selected GPIO controller
GPIO_mem volatile *pin = (GPIO_mem volatile *)((char *)base + (GPIO_3 & pagemask));
pin->CNF[1] = 0x00ff;
//pin->OE[1] = 0xff;
//pin->OUT[0] = 0xff;
// pin->IN = 0x00; read only
// disable interrupts
//pin->INT_ENB[1] = 0x00;
// don't worry about these for now
//pin->INT_STA[0] = 0x00;
//pin->INT_LVL[0] = 0x000000;
//pin->INT_CLR[0] = 0xffffff;
fprintf(stderr, "press ctrl-C to stop\n");
// "blink" the output values
uint8_t val = 0xff;
int cnt = 0;
while (true) {
printf("%d \n", pin->IN[1]);
}
This code prints 2 ** i when pin J.0i is high. When I set any of pins J.00 to J.03 to high I get the expected output, but when I set any of pins J.04 to J.07 to high I get a seemingly random mix of 0 and the proper value as the output. Does anyone know why this could be? As a final note, pins J.00 to J.03 are I2C in SFIO mode and J.04 to J.07 are I2S in SFIO mode. All 8 pins are set to GPIO mode but this is the only difference I can discern.