Again, trying to find out how to configure digital inputs and output through ports registers, I’ve been trying to apply pinMode
commands to three different GPIOs and check its effect over some registers. But regardless the pin mode selected, it seems I’m watching the wrong registers.
The code I’ve been using is:
uint8_t fase = 0;
#define output 0
#define input 1
#define input_pulldown 2
#define input_pullup 3
void print_reg(void)
{
Serial.print("\nGPIO_IN_REG : 0b"); Serial.print(GPIO_IN_REG, BIN);
Serial.print("\tGPIO_ENABLE_REG : 0b"); Serial.print(GPIO_ENABLE_REG, BIN);
Serial.print("\tIO_MUX_GPIO25_REG : 0b"); Serial.print(IO_MUX_GPIO25_REG, BIN);
Serial.print("\tIO_MUX_GPIO12_REG : 0b"); Serial.print(IO_MUX_GPIO12_REG, BIN);
Serial.print("\tIO_MUX_GPIO13_REG : 0b"); Serial.print(IO_MUX_GPIO13_REG, BIN);
}
void setup (void)
{
Serial.begin(115200);
delay(500);
Serial.print("Configuração inicial:");
print_reg();
}
void loop (void)
{
switch (fase) {
case output:
pinMode(25, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT);
Serial.print("\nOUTPUT:");
break;
case input:
pinMode(25, INPUT); pinMode(12, INPUT); pinMode(13, INPUT);
Serial.print("\nINPUT:");
break;
case input_pulldown:
pinMode(25, INPUT_PULLDOWN); pinMode(12, INPUT_PULLDOWN); pinMode(13, INPUT_PULLDOWN);
Serial.print("\nINPUT_PULLDOWN:");
break;
case input_pullup:
pinMode(25, INPUT_PULLUP); pinMode(12, INPUT_PULLUP); pinMode(13, INPUT_PULLUP);
Serial.print("\nINPUT_PULLUP:");
break;
default: break;
}
delay(1000);
print_reg();
if (++fase > 3) fase = 0;
}
And the results I’ve been cyclically obtaining are:
OUTPUT:
GPIO_IN_REG : 0b111111111101000100000000111100 GPIO_ENABLE_REG : 0b111111111101000100000000100000 IO_MUX_GPIO25_REG : 0b111111111101001001000000100100 IO_MUX_GPIO12_REG : 0b111111111101001001000000110100 IO_MUX_GPIO13_REG : 0b111111111101001001000000111000
INPUT:
GPIO_IN_REG : 0b111111111101000100000000111100 GPIO_ENABLE_REG : 0b111111111101000100000000100000 IO_MUX_GPIO25_REG : 0b111111111101001001000000100100 IO_MUX_GPIO12_REG : 0b111111111101001001000000110100 IO_MUX_GPIO13_REG : 0b111111111101001001000000111000
INPUT_PULLDOWN:
GPIO_IN_REG : 0b111111111101000100000000111100 GPIO_ENABLE_REG : 0b111111111101000100000000100000 IO_MUX_GPIO25_REG : 0b111111111101001001000000100100 IO_MUX_GPIO12_REG : 0b111111111101001001000000110100 IO_MUX_GPIO13_REG : 0b111111111101001001000000111000
INPUT_PULLUP:
GPIO_IN_REG : 0b111111111101000100000000111100 GPIO_ENABLE_REG : 0b111111111101000100000000100000 IO_MUX_GPIO25_REG : 0b111111111101001001000000100100 IO_MUX_GPIO12_REG : 0b111111111101001001000000110100 IO_MUX_GPIO13_REG : 0b111111111101001001000000111000
This code was run in Arduino 2.0.0-beta.7 because, for some reason, with VSCode+PlatformIO the code seems not to be flashed.
Given these results, which might be the registers affected by “pinMode” command?
Please help.
Thank you.
Regards,
Ciro.