how can i set port C as input on arduino due? I want to read input from eight pins at the same time.
I have tried this but it does not seem to work:
REG_PIOC_ODR = 0x3fc;
REG_PIOC_PER = 0x3fc;
int pixelData = REG_PIOC_PDSR >> 2;
how can i set port C as input on arduino due? I want to read input from eight pins at the same time.
I have tried this but it does not seem to work:
REG_PIOC_ODR = 0x3fc;
REG_PIOC_PER = 0x3fc;
int pixelData = REG_PIOC_PDSR >> 2;
To do this you will need to set the mode on each pin to input. A quick way of doing this is to write something like:
void setDataBusInput()
{
byte i ;
for( i = 33; i < 42; i++ )
pinMode( i, INPUT ) ; // Sets pins 33-41 to Inputs
}
Then you can use:
inputBuffer[i] = PIOC->PIO_PDSR & 0xFF; // Read data in
which will read the data present on the port. I just pulled this code from something I had previously written, you can adjust the values to match the pins you want to use.