Sharing I2C Pins Between Main Core and LP Core on ESP32-C6
Posted: Wed Jul 02, 2025 6:40 am
Hi all,
I'm working on a project using the ESP32-C6 with ESP-IDF v5.4.1, and I have a question regarding the use of I2C on both the Main Core and the LP Core.
Goal:
I want to use the same I2C pins (e.g., GPIO6 and GPIO7) for communication from:
The Main Core when it's awake
The LP Core when the Main Core is in deep sleep
So essentially, only one core will be active at a time and accessing the I2C bus.
Questions:
Is it possible to share I2C pins between Main Core and LP Core, as long as only one core is using the I2C peripheral at any time?
What is the recommended procedure to cleanly release the I2C peripheral and pins on one core and reinitialize them on the other core?
Do I need to reset GPIO mux/function (i.e., FuncSel or IOMUX) explicitly when switching ownership?
Are there any conflicts or known limitations with the LP Core I2C peripheral using GPIO6/7 after the Main Core has used them?
Notes:
I use gpio_set_direction(..., GPIO_MODE_DISABLE) and gpio_reset_pin() to release pins.
I observed that the FuncSel sometimes stays at 1 (GPIO)
Any insights, suggestions, or example approaches would be appreciated!
I'm working on a project using the ESP32-C6 with ESP-IDF v5.4.1, and I have a question regarding the use of I2C on both the Main Core and the LP Core.
Goal:
I want to use the same I2C pins (e.g., GPIO6 and GPIO7) for communication from:
The Main Core when it's awake
The LP Core when the Main Core is in deep sleep
So essentially, only one core will be active at a time and accessing the I2C bus.
Questions:
Is it possible to share I2C pins between Main Core and LP Core, as long as only one core is using the I2C peripheral at any time?
What is the recommended procedure to cleanly release the I2C peripheral and pins on one core and reinitialize them on the other core?
Do I need to reset GPIO mux/function (i.e., FuncSel or IOMUX) explicitly when switching ownership?
Are there any conflicts or known limitations with the LP Core I2C peripheral using GPIO6/7 after the Main Core has used them?
Notes:
I use gpio_set_direction(..., GPIO_MODE_DISABLE) and gpio_reset_pin() to release pins.
I observed that the FuncSel sometimes stays at 1 (GPIO)
Any insights, suggestions, or example approaches would be appreciated!