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?
REG_PIOA_WPMR.