Go Down

Topic: Arduino Due Port Manipulation (Read 1 time) previous topic - next topic

dishimwe

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:
Code: [Select]

    REG_PIOC_ODR = 0x3fc;
    REG_PIOC_PER = 0x3fc;
    int pixelData = REG_PIOC_PDSR >> 2;

jiblets

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:

Code: [Select]

void setDataBusInput()
  {
    byte i ;
    for( i = 33; i < 42; i++ )
      pinMode( i, INPUT ) ; // Sets pins 33-41 to Inputs
  }



Then you can use:

Code: [Select]

        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.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy