Go Down

Topic: Arduino DUE pinMode vs PIO_ODR (Read 1 time) previous topic - next topic

RichardHuang

Hi All,

Just a quick question, I am try to replace (pinMode) with (register setting).
But my process is not work. The output data always is 0.

unsigned long Data;
void setup() {
 
  PIOD->PIO_PER = 0xFFFFFFFF;  //Enable PIO
  PIOD->PIO_ODR = 0xFFFFFFFF;  //Set to INPUT   
  Serial.begin(115200); 

}

void loop() {

  Data = PIOD->PIO_PDSR & 0xFFFFFFFF;
  Serial.println(Data,BIN);
  delay(1);
 
}

I modify the process as below for debug and it work well.
Would someone help me to solve this problem?
I plan to use register setting to connect DUE with a Parallel ADC. Thank you.

unsigned long Data;
void setup() {
 
  //  PIOD->PIO_PER = 0xFFFFFFFF;  //Enable PIO
  //  PIOD->PIO_ODR = 0xFFFFFFFF;  //Set to INPUT   
  pinMode(12, INPUT);
  Serial.begin(115200); 

}

void loop() {

  Data = PIOD->PIO_PDSR & 0xFFFFFFFF;
  Serial.println(Data,BIN);
  delay(1);
 
}


ard_newbie


You have to power on PIOD thru PMC registers in setup().

RichardHuang

Thank you for your help ard_newbie.
Would you show me the command for power on PIO thru PMC registers?
Thank you again.

ard_newbie


PMC->PMC_PCER0 |= PMC_PCER0_PID14; // PIOD power ON (Sam3x datasheet page 38)

RichardHuang

Thanks a lot for your great help ard_newbie.
It is work.


Go Up