I2C communication error after deep sleep

StefanS
Posts: 10
Joined: Sat Jul 07, 2018 1:12 pm

I2C communication error after deep sleep

Postby StefanS » Mon Jul 30, 2018 4:07 pm

Hello,

I'm using I2C and deep sleep in my application. And I want to wakeup ESP32 by low level on SDA line.
After hard reset I can receive data in I2C slave mode without any problems.
The same code fails after configuring SDA for deep sleep, entering deep sleep and waking up.

I2C setup code:

Code: Select all

	i2c_config_t cfg;
	memset(&cfg, 0x00, sizeof(cfg));
	cfg.mode = I2C_MODE_SLAVE;
	cfg.sda_io_num = SU_HARDWARE_I2CSDA;
	cfg.sda_pullup_en = GPIO_PULLUP_ENABLE;
	cfg.scl_io_num = SU_HARDWARE_I2CSCL;
	cfg.scl_pullup_en = GPIO_PULLUP_ENABLE;
	cfg.slave.slave_addr = SU_HARDWARE_I2CADDR;
	if(SU_WRAP(i2c_param_config(SU_HARDWARE_I2CPORT, &cfg)) != ESP_OK)
		goto JmpCleanup0;
	if(SU_WRAP(i2c_driver_install(SU_HARDWARE_I2CPORT, cfg.mode, gSuBufferSize, gSuBufferSize, 0)) != ESP_OK)
		goto JmpCleanup1;
Deep sleep setup code:

Code: Select all

	SU_WRAP(esp_sleep_enable_timer_wakeup(gSuSleepTimeout * 1000));
	SU_WRAP(esp_sleep_enable_ext0_wakeup(SU_HARDWARE_I2CSDA, 0));
	esp_deep_sleep_start();
Receive code (works after hard reset, fails with timeout after deep sleep wakeup):

Code: Select all

	if(i2c_slave_read_buffer(SU_HARDWARE_I2CPORT, op, 1, gSuTimeout) != 1)
	{
		SU_WRAP(ESP_FAIL);
		return false;
	}
I guess that I need to reset or configure something else.


Any idea?

Thank you

Stefan

StefanS
Posts: 10
Joined: Sat Jul 07, 2018 1:12 pm

Re: I2C communication error after deep sleep

Postby StefanS » Tue Jul 31, 2018 8:47 am

Just solved this myself.
I need to reconfigure the SDA line upon recover from deep sleep:

Code: Select all

rtc_gpio_deinit(SU_HARDWARE_I2CSDA)
Then I2c works as expected.

Who is online

Users browsing this forum: katebo, MSN [Bot], muhambykar and 19 guests