This code will toggle the Arduino pins 8 through 13 every ~29ns:
int main(int argc, char **argv)
{
// Set up the GPIOs such that the LED GPIO
// can be used as both Inputs and Outputs.
const unsigned int mask = 0x3f;
GPIO_REG(GPIO_INPUT_EN) &= ~mask;
GPIO_REG(GPIO_PULLUP_EN) &= ~mask;
GPIO_REG(GPIO_OUTPUT_EN) |= mask;
unsigned int base = GPIO_REG(GPIO_OUTPUT_VAL) & ~mask;
while(1) {
GPIO_REG(GPIO_OUTPUT_VAL) = base;
base ^= mask;
}
return 0;
}
Any ideas on how to manipulate GPIO pins faster. (Unrolling the loop didn’t seem to help.)
This seems to be the resulting assembly code:
204001d4: 00f72623 sw a5,12(a4)
204001d8: 03f7c793 xori a5,a5,63
204001dc: ff9ff06f j 204001d4 <main+0x34>