Closed NathanKuo0821 closed 2 years ago
@NathanKuo0821 The constructor of M5UnitLCD and M5UnitOLED can set the I2C port number in the fourth argument. Try the following
M5UnitLCD display (I2C2_SDA,I2C2_SDL,400000, I2C_NUM_1);
@NathanKuo0821 The constructor of M5UnitLCD and M5UnitOLED can set the I2C port number in the fourth argument. Try the following
M5UnitLCD display (I2C2_SDA,I2C2_SDL,400000, I2C_NUM_1);
Dear Sir, Thanks for your reply . When I set the I2C_NUM_1 in M5UnitLCD as below , ESP32 keeps crashing and restarting. Is this a bug for M5UnitLCD using ESP32 I2C2?
M5UnitLCD display (I2C2_SDA,I2C2_SDL,400000, I2C_NUM_1);
Error Log: [E][common.cpp:939] writeBytes(): i2c write error : ack wait [E][common.cpp:939] writeBytes(): i2c write error : ack wait [D][DetectionManage.cpp:148] displayinit(): width=0 , height=0 Guru Meditation Error: Core 1 panic'ed (IntegerDivideByZero). Exception was unhandled. Core 1 register dump: PC : 0x400e1ba6 PS : 0x00060f30 A0 : 0x800e207a A1 : 0x3ffb1c00 A2 : 0x00000020 A3 : 0x00000000 A4 : 0x00000032 A5 : 0x3ffbe218 A6 : 0x60027000 A7 : 0x00004e20 A8 : 0x800e1b9e A9 : 0x3ffb1be0 A10 : 0x00000000 A11 : 0x00000000 A12 : 0x00000001 A13 : 0x000007bf A14 : 0x00000001 A15 : 0x00000001 SAR : 0x00000018 EXCCAUSE: 0x00000006 EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000
Backtrace: 0x400e1ba6:0x3ffb1c00 0x400e2077:0x3ffb1c40 0x400d9a15:0x3ffb1c60 0x400d9a75:0x3ffb1c80 0x400ddd3f:0x3ffb1ca0 0x400ddda9:0x3ffb1cc0 0x400d2580:0x3ffb1ce0 0x400d44a3:0x3ffb1d00 0x400e2cae:0x3ffb1fb0 0x4008a33a:0x3ffb1fd0
Nathan Kuo
@NathanKuo0821 What version of ArduinoESP32 do you have? Is the M5GFX up-to-date?
@NathanKuo0821 What version of ArduinoESP32 do you have? Is the M5GFX up-to-date?
The version as below , Is this ok? framework-arduinoespressif32 3.20000.220418 (2.0.0) m5stack/M5GFX@^0.0.20
Error Log: [ 18][E][common.cpp:1051] writeBytes(): i2c write error : ack wait [ 19][D][DetectionManage.cpp:148] displayinit(): width=0 , height=0 Guru Meditation Error: Core 1 panic'ed (IntegerDivideByZero). Exception was unhandled.
Core 1 register dump: PC : 0x400eb5f7 PS : 0x00060930 A0 : 0x800ebbf6 A1 : 0x3ffb2460 A2 : 0x00002710 A3 : 0x3ffbe158 A4 : 0x00000032 A5 : 0x60027000 A6 : 0x00000020 A7 : 0x00004e20 A8 : 0x800eb5ed A9 : 0x3ffb2440 A10 : 0x00000000 A11 : 0x00000000 A12 : 0x3ffb99c4 A13 : 0x3ffc38a8 A14 : 0x3ffb9904 A15 : 0x3ffb991c SAR : 0x00000010 EXCCAUSE: 0x00000006 EXCVADDR: 0x00000000 LBEG : 0x40089234 LEND : 0x4008923f LCOUNT : 0x00000000
Backtrace:0x400eb5f4:0x3ffb24600x400ebbf3:0x3ffb24a0 0x400de61d:0x3ffb24d0 0x400de879:0x3ffb24f0 0x400de8e5:0x3ffb2510 0x400d4ec0:0x3ffb2530 0x400d69df:0x3ffb2570 0x400ec5e7:0x3ffb2820
Nathan Kuo
If I switch to "I2C1" pin and "I2C_NUM_0" , everything works fine.
M5UnitLCD display (I2C1_SDA,I2C1_SDL,400000, I2C_NUM_0);
or change I2C1 pin to gpio 32/33 and "I2C_NUM_0" , it also still works.
/*
#define I2C1_SDA 15
#define I2C1_SDL 16
#define I2C2_SDA 32
#define I2C2_SDL 33
*/
#define I2C1_SDA 32
#define I2C1_SDL 33
#define I2C2_SDA 15
#define I2C2_SDL 16
M5UnitLCD display (I2C1_SDA,I2C1_SDL,400000, I2C_NUM_0);
I have no idea for this , please give me some more advice. Thanks again.
@NathanKuo0821
The TwoWire of the ArduinoESP32 has a prepared instance.
Perhaps your creating a separate instance would cause inconvenience.
Try using Wire
instead of I2C1
and Wire1
instead of I2C2
.
@NathanKuo0821 The TwoWire of the ArduinoESP32 has a prepared instance. Perhaps your creating a separate instance would cause inconvenience. Try using
Wire
instead ofI2C1
andWire1
instead ofI2C2
.
I also tried the example "ESP32 Using Two I2C Bus Interfaces" in this guide "https://randomnerdtutorials.com/esp32-i2c-communication-arduino-ide/" using I2C1 and I2C2 to control other sensors and it works fine. So I don't know what else I can do to verify I2C1 and I2C2 in our device.
Have you tried M5UnitLCD with ESP32 I2C2 before?
Nathan Kuo
@NathanKuo0821 The TwoWire of the ArduinoESP32 has a prepared instance. Perhaps your creating a separate instance would cause inconvenience. Try using
Wire
instead ofI2C1
andWire1
instead ofI2C2
. Dear Sir,
You are right, I2C2 is working. We can close this thread. Thanks again for your help.
Nathan kuo
Hi All,
I have defined two I2Cs in ESP32 to control M5UnitLCD. Now there is a problem, when i use I2C1 to control LCD everything works fine, but when i switch to I2C2, I2C error occurs, and i use gpio 15/16 or 32/33 to control I2C1 without problem, but I2C2 LCD has problems , can anyone help? Thansk
ERROR LOG: [D][esp32-hal-i2c.c:1344] i2cProcQueue(): Busy Timeout start=0xd7, end=0x10 9, =50, max=50 error=1 [E][esp32-hal-i2c.c:318] i2cDumpI2c(): i2c=0x3ffbe218 [I][esp32-hal-i2c.c:319] i2cDumpI2c(): dev=0x60027000 date=0x16042000 [I][esp32-hal-i2c.c:321] i2cDumpI2c(): lock=0x3ffb8b00 [I][esp32-hal-i2c.c:323] i2cDumpI2c(): num=1 [I][esp32-hal-i2c.c:324] i2cDumpI2c(): mode=1 [I][esp32-hal-i2c.c:325] i2cDumpI2c(): stage=3 [I][esp32-hal-i2c.c:326] i2cDumpI2c(): error=1 [I][esp32-hal-i2c.c:327] i2cDumpI2c(): event=0x3ffb8b88 bits=0 [I][esp32-hal-i2c.c:328] i2cDumpI2c(): intr_handle=0x3ffb8bbc [I][esp32-hal-i2c.c:329] i2cDumpI2c(): dq=0x3ffb8b64 [I][esp32-hal-i2c.c:330] i2cDumpI2c(): queueCount=1 [I][esp32-hal-i2c.c:331] i2cDumpI2c(): queuePos=0 [I][esp32-hal-i2c.c:332] i2cDumpI2c(): errorByteCnt=0 [I][esp32-hal-i2c.c:333] i2cDumpI2c(): errorQueue=0 [I][esp32-hal-i2c.c:334] i2cDumpI2c(): debugFlags=0x00000000 [I][esp32-hal-i2c.c:311] i2cDumpDqData(): Debug Buffer not Enabled [I][esp32-hal-i2c.c:354] i2cDumpInts(): Debug Buffer not Enabled [D][esp32-hal-i2c.c:1353] i2cProcQueue(): Gross Timeout Dead start=0x15a, e nd=0x18c, =50, max=50 error=1 [E][esp32-hal-i2c.c:318] i2cDumpI2c(): i2c=0x3ffbe218 [I][esp32-hal-i2c.c:319] i2cDumpI2c(): dev=0x60027000 date=0x16042000 [I][esp32-hal-i2c.c:321] i2cDumpI2c(): lock=0x3ffb8b00 [I][esp32-hal-i2c.c:323] i2cDumpI2c(): num=1 [I][esp32-hal-i2c.c:324] i2cDumpI2c(): mode=1 [I][esp32-hal-i2c.c:325] i2cDumpI2c(): stage=3 [I][esp32-hal-i2c.c:326] i2cDumpI2c(): error=1 [I][esp32-hal-i2c.c:327] i2cDumpI2c(): event=0x3ffb8b88 bits=0 [I][esp32-hal-i2c.c:328] i2cDumpI2c(): intr_handle=0x3ffb8bbc [I][esp32-hal-i2c.c:329] i2cDumpI2c(): dq=0x3ffb8b64 [I][esp32-hal-i2c.c:330] i2cDumpI2c(): queueCount=1 [I][esp32-hal-i2c.c:331] i2cDumpI2c(): queuePos=0 [I][esp32-hal-i2c.c:332] i2cDumpI2c(): errorByteCnt=0 [I][esp32-hal-i2c.c:333] i2cDumpI2c(): errorQueue=1 [I][esp32-hal-i2c.c:334] i2cDumpI2c(): debugFlags=0x00000000 [I][esp32-hal-i2c.c:311] i2cDumpDqData(): Debug Buffer not Enabled [I][esp32-hal-i2c.c:354] i2cDumpInts(): Debug Buffer not Enabled [I][esp32-hal-i2c.c:1138] i2cProcQueue(): Bus busy, reinit [E][common.cpp:939] writeBytes(): i2c write error : ack wait [D][esp32-hal-i2c.c:1344] i2cProcQueue(): Busy Timeout start=0x1f8, end=0x2 2a, =50, max=50 error=1 [E][esp32-hal-i2c.c:318] i2cDumpI2c(): i2c=0x3ffbe218 [I][esp32-hal-i2c.c:319] i2cDumpI2c(): dev=0x60027000 date=0x16042000 [I][esp32-hal-i2c.c:321] i2cDumpI2c(): lock=0x3ffb8b00 [I][esp32-hal-i2c.c:323] i2cDumpI2c(): num=1 [I][esp32-hal-i2c.c:324] i2cDumpI2c(): mode=1 [I][esp32-hal-i2c.c:325] i2cDumpI2c(): stage=3 [I][esp32-hal-i2c.c:326] i2cDumpI2c(): error=1 [I][esp32-hal-i2c.c:327] i2cDumpI2c(): event=0x3ffb8b88 bits=0 [I][esp32-hal-i2c.c:328] i2cDumpI2c(): intr_handle=0x3ffb8bbc [I][esp32-hal-i2c.c:329] i2cDumpI2c(): dq=0x3ffb8b64 [I][esp32-hal-i2c.c:330] i2cDumpI2c(): queueCount=1 [I][esp32-hal-i2c.c:331] i2cDumpI2c(): queuePos=0 [I][esp32-hal-i2c.c:332] i2cDumpI2c(): errorByteCnt=0 [I][esp32-hal-i2c.c:333] i2cDumpI2c(): errorQueue=0 [I][esp32-hal-i2c.c:334] i2cDumpI2c(): debugFlags=0x00000000 [I][esp32-hal-i2c.c:311] i2cDumpDqData(): Debug Buffer not Enabled [I][esp32-hal-i2c.c:354] i2cDumpInts(): Debug Buffer not Enabled [D][esp32-hal-i2c.c:1353] i2cProcQueue(): Gross Timeout Dead start=0x27b, e nd=0x2ad, =50, max=50 error=1 [E][esp32-hal-i2c.c:318] i2cDumpI2c(): i2c=0x3ffbe218 [I][esp32-hal-i2c.c:319] i2cDumpI2c(): dev=0x60027000 date=0x16042000 [I][esp32-hal-i2c.c:321] i2cDumpI2c(): lock=0x3ffb8b00 [I][esp32-hal-i2c.c:323] i2cDumpI2c(): num=1 [I][esp32-hal-i2c.c:324] i2cDumpI2c(): mode=1 [I][esp32-hal-i2c.c:325] i2cDumpI2c(): stage=3 [I][esp32-hal-i2c.c:326] i2cDumpI2c(): error=1 [I][esp32-hal-i2c.c:327] i2cDumpI2c(): event=0x3ffb8b88 bits=0 [I][esp32-hal-i2c.c:328] i2cDumpI2c(): intr_handle=0x3ffb8bbc [I][esp32-hal-i2c.c:329] i2cDumpI2c(): dq=0x3ffb8b64 [I][esp32-hal-i2c.c:330] i2cDumpI2c(): queueCount=1 [I][esp32-hal-i2c.c:331] i2cDumpI2c(): queuePos=0 [I][esp32-hal-i2c.c:332] i2cDumpI2c(): errorByteCnt=0 [I][esp32-hal-i2c.c:333] i2cDumpI2c(): errorQueue=1 [I][esp32-hal-i2c.c:334] i2cDumpI2c(): debugFlags=0x00000000 [I][esp32-hal-i2c.c:311] i2cDumpDqData(): Debug Buffer not Enabled [I][esp32-hal-i2c.c:354] i2cDumpInts(): Debug Buffer not Enabled [I][esp32-hal-i2c.c:1138] i2cProcQueue(): Bus busy, reinit
CODE: //I2C BUS
define I2C1_SDA 15
define I2C1_SDL 16
define I2C2_SDA 32
define I2C2_SDL 33
/ I2C Bus / TwoWire I2C1 = TwoWire(0); //I2C1 bus TwoWire I2C2 = TwoWire(1); //I2C2 bus
// LCD
include
M5UnitLCD display (I2C2_SDA,I2C2_SDL,400000); void setup() { Serial.begin(115200); I2C2.begin(I2C2_SDA,I2C2_SDL);
display.begin();
if (display.isEPD()) { display.setEpdMode(epd_mode_t::epd_fastest); display.invertDisplay(true); display.clear(TFT_WHITE); } if (display.width() < display.height()) { display.setRotation(display.getRotation() ^ 1); }
// width=240 , height=135 log_d("width=%d , height=%d",display.width(),display.height());
display.setColorDepth(1); // mono color display.setFont(&fonts::Font4); display.setTextWrap(false); display.setTextSize(3); display.setTextColor(TFT_BLACK);
display.fillScreen(WHITE);
display.drawString("Ready" , 0, (display.height()/3)); }
Nathan Kuo