Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By Thomas S.
#53901 Sorry for cross posting, but I sent this to the "arduino" category (not even "ESP Arduino") and got no reply.

I looked into core_esp8266_wiring_shift.c vs wiring_shift.c

To my astonishment I saw no delays in the esp8266 version. As it runs 5 times as fast as a 16 MHz arduino, I wonder if it is ok to assume, that connected hardware can cope with this speed.

Later i noticed, that i2c is around 400 kHz, so it should have been to fast even on a 16 MHz arduino.

What am I am missing?
User avatar
By martinayotte
#53909 You were looking at the wrong place ... :ugeek:

The core_esp8266_wiring_shift.c has nothing related to I2C, this is plain shifting used for example to 74HC595.

The I2C stuff is in core_esp8266_si2c.c, where you can see twi_setClock() function to set clock at 100KHz or 400KHz, or even 600KHz if you are running the CPU at 160MHz.

Beware that I2C on ESP8266 is all done with software bit-banging, while on AVR it is done in hardware.
User avatar
By Thomas S.
#53933 Yes Martin, you are right. I am confusing wiring_shift with i2c.

But then my question should be, if it isn't a risk to not delay the loop in core_esp8266_wiring_shift.c. This is used e.g. by the HX711 library.

I also looked into core_esp8266_si2c.c to see how such short delays are programmed:

Code: Select allstatic void twi_delay(unsigned char v){
  unsigned int i;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
  unsigned int reg;
  for(i=0;i<v;i++) reg = GPI;
#pragma GCC diagnostic pop
}


What does the GPI mean? Is it important, or could it have been any other assignment as well? (Only out of curiosity)
User avatar
By martinayotte
#53979 I must admit that I don't understand this twi_delay() ...
GPI is "GPIO_IN RO (Read Input Level)" as defined in esp8266_peri.h :
Code: Select all#define GPI    ESP8266_REG(0x318) //GPIO_IN RO (Read Input Level)

So, why twi_delay() need to read "v" times this register without using it ?
Maybe simply using this as a GPIO clock reference ?