-->
Page 1 of 4

Direct GPIO port register manipulation

PostPosted: Thu Apr 07, 2016 7:52 am
by 123francoz
Hi everyone, i'm new here,
i got my ESP8266 yesterday and i already started playing with it on Arduino IDE.
After testing some wifi examples, i went through hardware benchmarking,
i'm now able to set and clear a single GPIO with these instructions, (example on GPIO2):
Code: Select all    GPOS = 1<<2;
    GPOC = 1<<2;

that i found in the "core_esp8266_wiring_digital.c" file.
Now i need to manipulate multiple GPIOs at the same time,
(read or write the entire port in only one instruction).
I tryed GPOP, ex:
Code: Select all    GPOP = GPOP | 0x00000004;
    GPOP = GPOP & 0xFFFFFFFB;

but obviously it gives me "'GPOP' was not declared in this scope".
Anyone know the proper register name?
Thank you

Re: Direct GPIO port register manipulation

PostPosted: Thu Apr 07, 2016 9:24 am
by martinayotte
if you look in hardware/esp8266/2.1.0/cores/esp8266/esp8266_peri.h, you will see the following defines :

Code: Select all#define GPO    ESP8266_REG(0x300) //GPIO_OUT R/W (Output Level)
#define GPOS   ESP8266_REG(0x304) //GPIO_OUT_SET WO
#define GPOC   ESP8266_REG(0x308) //GPIO_OUT_CLR WO
#define GPOP(p) ((GPO & (1 << ((p) & 0xF))) != 0)

Re: Direct GPIO port register manipulation

PostPosted: Thu Apr 07, 2016 3:53 pm
by 123francoz
Thank you, i got it working with these instructions:
Code: Select all    GPO = GPO | 0x00000004;
    GPO = GPO & 0xFFFFFFFB;

But something strange is happening,
it seems to have a sort of interrupt every about 3 seconds that delays the execution and sends some ramdon data through USART.
the instruction
Code: Select all  noInterrupts();

in the setup makes only the delay shorter but it is still there.
Do you know anything about it?

Re: Direct GPIO port register manipulation

PostPosted: Thu Apr 07, 2016 4:43 pm
by 123francoz
Thank you, i got it working with these instructions:
Code: Select all    GPO = GPO | 0x00000004;
    GPO = GPO & 0xFFFFFFFB;

But something strange is happening,
it seems to have a sort of interrupt every about 3 seconds that delays the execution and sends some ramdon data through USART.
the instruction
Code: Select all  noInterrupts();

in the setup makes only the delay shorter but it is still there.
Do you know anything about it?