M5Dial icon indicating copy to clipboard operation
M5Dial copied to clipboard

Internal i2c pullups

Open nikthefix opened this issue 1 year ago • 12 comments
trafficstars

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

nikthefix avatar Jun 05 '24 09:06 nikthefix

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

felmue avatar Jun 05 '24 15:06 felmue

@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

nikthefix avatar Jun 05 '24 15:06 nikthefix

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

felmue avatar Jun 05 '24 23:06 felmue

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

esp32beans avatar Jun 06 '24 01:06 esp32beans

@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

nikthefix avatar Jun 06 '24 12:06 nikthefix

Hey @nikthefix may I ask you how you fixed the error in your case? Did you add pullups ?

beniroquai avatar Sep 15 '24 14:09 beniroquai

@beniroquai I solved the problem on my breadboard reproduction of the M5Dial by adding modest 10K pullup resistors to the i2c lines. Everything worked as expected after that.

Are you experiencing problems with the M5Dial?

If I had the M5Dial hardware I would attempt to do the same as a necessary mod. It's possible that M5stack have revised the board for later iterations.

Worth checking out the latest schematic.

nik

nikthefix avatar Sep 16 '24 12:09 nikthefix

Thanks! I think I'm still stuck with the two different I2C "ports". It seems that changing the frequency of one also alters the other (?). I want to use the Dial as a slave. Changing wire.begin() as slave on 100kHz won't allow me to use the touch. If I initialize at 400kHz it works. Not sure how error prone this is as I use simple wires..

beniroquai avatar Sep 16 '24 12:09 beniroquai

@beniroquai Assuming that you've sorted the hardware issue with the M5Dial,

I don't know which framework you are using but I would guess that to setup two i2c busses at different frequencies you would need to create separate objects - so wire.begin() and wire2.begin()...

Yes keep 400kHz for touch, RTC and RFID then use your wire2 as a separate entity for your slave comms. There are examples of concurrent i2c buses included in the ESP32_Arduino package.

But i2c slave for the M5Dial is interesting. You wish to interrogate the dial (which is itself a i2c master of 3 devices) from an external processor?

Wires and breadboard have served me well up to and beyond 40MHz SPI so shouldn't be a problem for 400kHz i2c if the pullups are right.

At the end of the day, if you're wanting to know what your i2c bus looks like when you've got many devices attached then you need a scope.

nikthefix avatar Sep 16 '24 12:09 nikthefix

I see. Thanks @nikthefix! I'll check the Wire2.begin() vs Wire.begin(). Did you happen to know where I can find an example for the M5Dial? Might be very generic anyway..

beniroquai avatar Sep 17 '24 05:09 beniroquai

@beniroquai I don't know any specific M5Dial examples but initializing a second i2c bus with different parameters on esp32-s3 is well documented on-line and in the Espressif literature.

For Arduino IDE development checkout this tutorial:

https://randomnerdtutorials.com/esp32-i2c-communication-arduino-ide/

It's a great site for all sorts of solutions and I recon will show you how to do what you need in this case.

Wire2 was just an example name I made up for a hypothetical second i2c bus instance so it's not something to go looking for. You can declare and initialize your second i2c bus with any name you like.

nik

nikthefix avatar Sep 19 '24 11:09 nikthefix

Perfect. Thanks a lot!!:)

On Thu, 19 Sep 2024, 13:04 nikthefix @.***> wrote:

@beniroquai https://github.com/beniroquai I don't know any specific M5Dial examples but initializing a second i2c bus with different parameters on esp32-s3 is well documented on-line and in the Espressif literature.

For Arduino IDE development checkout this tutorial:

https://randomnerdtutorials.com/esp32-i2c-communication-arduino-ide/

It's a great site for all sorts of solutions and I recon will show you how to do what you need in this case.

nik

— Reply to this email directly, view it on GitHub https://github.com/m5stack/M5Dial/issues/17#issuecomment-2360680136, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBE5OAQ7DLFKUYPUPPTUXLZXKVSNAVCNFSM6AAAAABI2IPM76VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRQGY4DAMJTGY . You are receiving this because you were mentioned.Message ID: @.***>

beniroquai avatar Sep 19 '24 15:09 beniroquai