LiquidCrystal & Shift Register

I’m currently testing this with the SPI mode of the Adafruit SPI/I2C LCD backpack… it basically makes the wiring easy. However you have to flip rewire the code for EN, D4-D7, as those are wired differently than the Fritzing diagram I made above.

That said, it wasn’t working at all. SPI looks like total crap on my scope, so at first I swiched to using shiftOut() which was much cleaner… but slow. Then I decided to roll my own shiftOut() using direct gpio manipulation, but the delays are questionable so I switched back to shiftOut()… even though it’s slow it should initially work.

And after a few more tweaks, got it working!

Then I turned to getting my faster version of shiftOut() working. Got it! About 3x faster. Just about as fast as the hardware SPI set to 4.5MHz :smile:

Imgur

Added on/off backlight control, and I need to clean up the library now. It’s SoftSPI so you can define any 3 digital pins to use instead of having to use the hardware SPI pins which are on the analog side of the :spark: Core. I’m going to redo the Fritzing diagram to use the same wiring that’s on Adafruit’s Backpack… so we don’t have to define multiple build types in the library.

FYI, you do have to adjust the contrast pot on the Adafruit I2C/SPI LCD Backpack (mostly clockwise) or you won’t see anything. I would have thought they’d at least jam this fully clockwise, but they expect you to probably read their tutorial. RTFM? Hell no!

Now to see what’s up with SPI… because I would like this to be even faster! (9MHz)

FYI: This is what I’m seeing on SPI… probably what’s making it fail on something like this 74HC595 where the SS pin controls the OUTPUT LATCH and does not gate the part like a normal chip select would. Otherwise it would ignore this garbage. @timb do you see this as well?

BTW this looks much faster than my SoftSPI, but there is a lot more delay between bytes transferred with the hardware SPI for some reason…

For comparison, here’s the SoftSPI I implemented.

2 Likes