m5stack / M5Dial

51 stars 10 forks source link

Internal i2c pullups #17

Open nikthefix opened 1 month ago

nikthefix commented 1 month ago

Looking at the schematic, there don't appear to be any i2c bus pullup resistors for the shared Touch, RTC and RFID lines. I'm experiencing corrupted data from the RTC. Could this be the cause of the problem or are the lines pulled to 3.3V elsewhere - in a way that I've missed?

Thanks

nik

felmue commented 1 month ago

Hello @nikthefix

checking with gpio_dump_io_configuration it looks like GPIO11 and GPIO12 have (soft) pull-ups enabled. That said, I wasn't able to find where in the setup code the (soft) pull-ups are actually enabled.

Have you tried to lower the i2c speed?

Thanks Felix

nikthefix commented 1 month ago

@felmue

Yes I've recommended reducing the i2c from 400 to 100kHz here:

In RTC8563_Class.hpp Set line 85 to RTC8563_Class(std::uint8_t i2c_addr = DEFAULT_ADDRESS, std::uint32_t freq = 100000,

I don't have the M5Dial product myself but have reproduced it on breadboard and am trying to help a colleague. I have his sketch working perfectly on the CoreS3. The CoreS3 schematic shows the system I2C pullup resistors as expected. The M5Dial schematic shows no pullups. Internal pullups will not be sufficient in this case as they are too weak - based on my experience.

If there's no hardware pullup to 3.3V on the internal SCL & SDA lines then there are gonna be problems.

If I'm right, I would expect Touch to fail periodically.

Thanks for responding.

nik

felmue commented 1 month ago

Hello @nikthefix

hmm, I wonder if that actually changes the frequency as Wire1.getClock() already always returns 100'000. E.g. at the very beginning of the program as well as after RTC IC interaction. (And again, I was not able to find in the code / libraries where the frequency for Wire1 gets set to 100'000.)

Maybe try to change the frequency with Wire1.setClock(50000) to even a lower value?

Thanks Felix

esp32beans commented 1 month ago

The rtc.ino example works on my M5Dial. Reading the touch screen works without problems.

nikthefix commented 1 month ago

@esp32beans

Yes the rtc.ino example works for me too but the sketch has very low i2c traffic and as @felmue pointed out, the internal weak pullups are employed and probably sufficient in this case. More frequent polling of the RTC chip at 400kHz seems to cause data corruption. Best case scenario is that the Lilygo schematic is wrong and that this problem is caused by something else entirely. But I have doubts.

nik