Close

Third time's the charm (he says hopefully)

A project log for weeBell - personal central office for POTS phones

weeBell brings the goodness of old telephones into the modern age in a portable package that speaks GUI, Bluetooth and Wifi

dan-julioDan Julio 05/29/2023 at 15:163 Comments

Oh I2C...you difficult child, you

I received the Rev 2 boards and ES8388 codec chips last week and got a board built up.  It took a day more to finish the codec driver port and then I could start debugging.  After working through the initial compile errors, I was immediately greeted by I2C errors communicating with the ES8388.  Lots of them.  Sometimes the chip simply wouldn't respond and other times it would respond to an address but not let go of SDA at the end of a cycle leading to a timeout.  At least it wasn't f*cking up transactions to the other chips like the SGTL5000 did but I was seriously bummed.

Scope traces looked fine but clearly something was wrong.  Things got slightly better when I removed the second set of pull-ups on the board (leaving only gCore's 10k pull-ups).  I could at least get through the codec initialization sometimes.  Then I would see failures when I2S was running (2.048 MHz MCLK) and the chip was accessed to change volume (but no errors when I2S wasn't running).  I could see some apparently slight indications of cross-talk, but at least on my 200 MHz BW scope, they didn't appear to violate the VIH and VIL levels in the ES8388 spec sheet.  Perhaps, though, the ES8388 was seeing  some ultra-fast glitches as additional clock pulses.

Should have followed through with more research

Then I remembered seeing something on the schematic for the AI-Thinker A1S ESP32 module which has the ES8388 built-in (I used their dev board to play around with the HF demos originally). 

There is what looks like an RC filter on the I2C signals going to the ES8388.  I originally dismissed this circuit when I laid out my board thinking the designers must have been over cautious but in the light of my own failures I had the realization that circuit was probably there for a reason.  Doh'

Some quick digging turned up Espressif's Lyra T dev board schematic complete with a note...

Oh crap.  I shouldn't have been so quick to dismiss what I'd seen.

A quick hack later and my board had a similar filter on the I2C lines.

Look at the top left corner of the image.  You can see 2 15k pull-ups tombstone style and 100 ohm resistors soldered to the cut traces.  22 pF caps are where R1 and R2 used to go completing the filter. 

It worked.  I2C errors were now a thing of the past.  So a note to anyone thinking of using the ES8388 ... remember to include a filter!

I could now finish debugging the ES8388 driver which mostly meant adjusting various gains so the audio sounded right although I included a bit of black magic I found in the Espressif ADF driver that accesses undocumented registers with the comment that it's to make 8 kHz sampling work (which is what I use).

One more round of boards

Let's hope the third time's the charm.  At least the modified Rev 2 board seems fully functional and I am planning to take my proto to visit a friend who collects antique phones for an afternoon of calls making sure this works with a variety of phones.

R1-R4, C1, C2 are the I2C pull-ups and filter.  Rev 3 also got some more warnings and notes.

Discussions

Robert Manzke wrote 12/11/2023 at 20:59 point

Hi Dan, Thanks for getting back! It's weird when using 44.1kHz sampling rate it only works reasonably with an MCLK multiple of  384, which brings the MCLK to 44.1kHz*384=16.9344MHz. It occasionally looses sync, which sounds like occasional digital noise spikes in the audio. In the user guide for the ES8388 there are 22pF to ground at all the I2S clocks, I will try that in my next design. I was ignoring all of that just like you for the I2C... Will post here what comes out of it.

  Are you sure? yes | no

Dan Julio wrote 12/01/2023 at 16:16 point

Hi Robert.  I haven't seen it lose sync.  But  I'm running it fairly slowly for 8 kHz audio and I only use it when there is audio which generally only lasts as long as there is a phone call (it's reset at the beginning of each audio session).  Probably you've already done this but have you looked at the signal quality and made sure setup/hold times are valid?

  Are you sure? yes | no

Robert Manzke wrote 12/01/2023 at 09:49 point

Hi, I use the ES8388 as well in combination with an ESP32-S3. Strangely it sometimes looses synchronization with the I2S clock provided by the ESP. That results in weird noise glitches occasionally in the audio. Have you had similar issues? Thx.

  Are you sure? yes | no