Pages: [1]   Go Down
Author Topic: Arduino Due Port Manipulation  (Read 1064 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
    REG_PIOC_ODR = 0x3fc;
    REG_PIOC_PER = 0x3fc;
    int pixelData = REG_PIOC_PDSR >> 2;
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
void setDataBusInput()
  {
    byte i ;
    for( i = 33; i < 42; i++ )
      pinMode( i, INPUT ) ; // Sets pins 33-41 to Inputs
  }


Then you can use:

Code:
        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.
Logged

Pages: [1]   Go Up
Jump to: