I’m new to the Duo. I ported some i2c LCD code to it, and it sort of works, but it’s glitchy and the LCD restarts often. It seems like it’s i2c speed related. What speed does the Duo write at? I don’t see any way in wiringx to change it, but as long as I can set the LCD to receive at that speed I think it’ll work better.
I think I found my answer in the Peripheral Driver Operation Guide, in the I2C Operation Guide section. It looks like it’s operating at Full Speed (400 kbit/s), and isn’t easily changeable unless someone writes a program to do it on the fly.
Anyway, I’ve tested every baud rate my SparkFun LCD can do and nothing helps. Still glitchy. I’ve done a bunch of hardware and software tinkering to try to make it work right. Nothing helps. The display works rock solid stable on a PIC (the code I ported to Duo).
Maybe it’s noise? Guess I should drag out the logic analyzer and have a look at the data stream.
Logic analyzer says it isn’t noise. It’ll be writing the correct things and the LCD is sending ACKs and then suddenly it’s sending NACKs, or there’ll be a long empty section where the LCD restarts and then a ton of NACKs and then it gets going again until it breaks again. WTF? No obvious reasons for the problem.
I’ve tested my software by putting printf’s in a few spots to see if it’s getting messed up. But it’s still sending the correct numbers even as the LCD breaks.
I’m still thinking (maybe incorrectly) that maybe the Duo is just sending way too fast for the LCD to keep up? But I don’t know how to read the analyzer to figure out the speed.
I have some good working PIC bitbang i2c code that I wrote. I think I’ll port it over and see how it goes with that.
Spent quite a while chasing down a stupid mistake bug in my ported code, but just now found and stomped it. What a foolish mistake. My bitbang i2c Milk-V Duo display code now works flawlessly. You can find it on ghmicro.com if you want to look.
My guess on the cause of the trouble I was having with hardware i2c is either, as I said before, it might be sending way too fast for the display (though display has settings for 460800bps, 921600bps, and 1000000bps, all of which I tried), or maybe a bug in the library i2c code, though it looked fine in the logic analyzer.
Thank you very much for your feedback, and your project is fantastic.
For the latest firmware:
I2C0 is configured by default with pins 1 and 2, operating at a speed of 400K.
I2C1 is configured by default with pins 14 and 15, operating at a speed of 100K.
Thank you Carbon.
Add another line for 20+ characters.