1

I have shorted the 23rd pin of port A with 3.3v output pin (i.e. tieing 23rd pin of port A to logic high). Now I am trying to read the 23rd pin of port A by using following code-

void setup() {
  Serial.begin(9600); // put your setup code here, to run once:
  char print_str[40];
  REG_PIOA_PER = 0x00800000;   //Write 1's to A register pins to override other peripherals and allow GPIO use for pins
  REG_PIOA_ODR = 0x00800000;   //Set A register pins to INPUT
  sprintf(print_str, "\n%08X", REG_PIOA_PDSR);
  Serial.println(print_str);
}

void loop() {
  // put your main code here, to run repeatedly:
}

According to the code, the serial output should be 0x00800000. But I am always getting 0. Could you please tell me, what is going wrong?

3
  • 1
    23rd pin is PA22 ... did you connect the correct pin? Commented Jun 5, 2019 at 23:47
  • Check the value of REG_PIOA_WPMR. Commented Jun 6, 2019 at 11:03
  • Hint: Take a look at the GPIO library for SAM. There is an initialization missing. github.com/mikaelpatel/Arduino-GPIO/blob/master/src/Hardware/… Commented Jun 6, 2019 at 12:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.