pleriche
Posts: 90
Joined: Mon Oct 14, 2013 8:44 am

i2c problem on PiZero v1.2

Fri May 25, 2018 9:30 pm

Some 5 years ago I built an intelligent midi interface using a PIC16F1823 8 bit microcontroller, which interfaces with the Pi using i2c. (The PIC is working as an i2c slave.) I use this fairly regularly with one of my original Pi Model B's, still running Wheezy. At one stage I tried replacing the Pi with an original v1.2 PiZero but reverted to the B as it kept dropping WiFi. (Both used the same nano WiFi adapter.)

I've just fulfilled a long standing intention to rebuild it to allow extra functionality, but for the moment it's using exactly the same PIC code except for reassignment of pins to accommodate a PIC16F1829 instead of the 18F23 (same core, same speed, but more memory and pins), and testing it on the PiZero, now reinstalled with Stretch.

Sending to the midi interface works fine, but on receiving (recording a tune being played live on a midi keyboard) gives completely garbled data. Roughly the expected number of bytes are received but bearing no obvious resemblance to what they should be.

But if I connect it to the Model B it works exactly like my original build.

I wondered whether maybe the Zero couldn't supply the power it requires from the 3.3v rail, but I measured its consumption as less than 15mA, so that seems unlikely.

Ideas, anyone?

Regards - Philip
PS The other difference is that the new implementation includes a socket for a DS12307 RTC. I discounted that as it made no difference whether it was plugged in or not, but I did have it configured in /boot/config.txt. I've just commented that out and rebooted, and the problem persists. But I do ask myself whether Device Tree affects userland i2c access. The driver on the Pi is a Python program. Bit 7 should be set in the first byte of each midi packet and the first byte of multibyte times, but none of the data has bit 7 set. But the data still doesn't make sense if you assume bit 7 might just have been consistently squashed.

PPS My PIC code (written in assembler) doesn't use clock stretching. I was aware when I wrote it 5 years ago that the Pi doesn't support this - and still doesn't - which is a pain, but one I coded around from the start.

pleriche
Posts: 90
Joined: Mon Oct 14, 2013 8:44 am

Re: i2c problem on PiZero v1.2

Sun May 27, 2018 10:02 pm

I've now tried various combinations of old/new interface on different Pis and different OS's and the results are as follows:
Original Pi Model B: Wheezy: Both old and new interfaces work

PiZeroV1.2:
- Stretch:
- - Old interface worked maybe a couple of years ago
- - New interface now doesn't work
- Jessie:
- - Neither old nor new interfaces work
Pi 3:
- Stretch:
- - New interface works
PiZeroW:
- Stretch:
- - New interface works

A thread viewtopic.php?t=192958 indicates there has been a problem with i2c multiple byte reads.

My interface uses 2 i2c addresses. Typically, the host reads the number of bytes of midi data available from the status address, then uses the data address to read that number of bytes. The data read appears to return garbage. This sounds a bit like the problem described in the above thread. Is there an outstanding problem with the original PiZero?

Regards - Philip

Return to “Troubleshooting”