Greetings,
I am trying to drive a ST7920 LCD with MCP23017. Almost every google result points to Nick Gammon page and his work.
He has done a fantastic job for KS0108 LCD. I was wondering if someone has used his code for ST7920 LCD?
I have spend a couple of days tinkering around with the code but no luck. Nick Gammon driver displays a pattern as shows in the attached picture.
I am using Arduino UNO, with following LCD and driver board,
https://robotdyn.com/catalog/graphics/lcd_graphic_128x64_display/
https://robotdyn.com/catalog/adapters/i2c_graphic_128x64_lcd_adapter/
Any suggestions?
Yes, I can see the attraction of using a MCP23017 if you already have other devices on the I2C bus. Zero extra pins required.
You can use the ST7920 in its native SPI mode if you already have other devices on the SPI bus. One extra pin required.
Bear in mind that the MCP23017 will be appallingly SLOW. The ST7920 in SPI or parallel mode works quite fast.
There are sewveral libraries that will drive the ST7920 in either SPI or parallel.
In theory you could use PCF9574 or 74HC195 to drive ST7920 in 4-bit mode. I could try both of these. I don't have a MCP23017 or MCP23S17 to try 8-bit mode. Note that there will be no speed advantage in using 8-bit mode.
Your idea is possible but not very practical.
David.
I have the same issue trying to connect ST7920 with MCP23017 to an esp8266 .
I don't understand why is't so easy with arduino and not with esp8266
The ST7920 is a hardware SPI device. ESP8266 is able to drive many SPI slaves. It only costs one /CS pin per extra device.
It is fairly complicated to bit-bang the ST7920 via a slow MCP23017. Ok, the MCP23017 is an I2C device. The ESP8266 can drive multiple I2C Slaves. It costs nothing per extra I2C device.
I suggest that you sit down with a nice cup of tea and draw up the pin budget for your project.
Seriously, if you only have a ST7920, you need 2 pins for the MCP23017 but 3 pins for a ST7920.
I suppose it is an intellectual exercise to bit-bang the ST7920 in parallel mode via port expander.
It would only be a worthwhile task for a KS0108 or similar elderly GLCD chip because that chip does not have an SPI interface. (or even 4-bit parallel)
David.
I have an error avr #include <avr/pgmspace.h>
thank you very much David for your advise but i did not find any shema for pinout ST7920 on a esp8266
IF i am right you want me to put my ST7920 in spi mode
ok
so i would have to pin out like this:
1 GND GND
2 VCC 5V
4 RS - [5v-to-3.3v] - GPIO-4 (D2)
5 R / W - [5v-to-3.3v] - GPIO-13 (D7) [MOSI]
6 - [5v-to-3.3v] - GPIO-14 (D5) [SCK]
17 RST - [5v-to-3.3v] - GPIO-5 (D1)
can you give me a link for library for spi mode for esp8266
U8g2lib should work on AVR, Zero, Due, STM32, ESP8266, ESP32, ...
No, I have not tried a ST7920 module on ESP8266. But I see no difficulties. The logic signals from ESP8266 are 3.3V. The ST7920 should be perfectly happy with 3.3V input signals. Connect VCC to 5V or 3.3V as required by your module.
The general advice is to select Software SPI first. This should not care which GPIO pins are used.
When this works ok, ensure that you connect the HardWare SCK, MOSI pins. Then try the HW SPI constructor.
David.
Thank you i going to do this but before i have to desoldering the MCP23017 quite a hard job
max_esp8266:
I don't understand why is't so easy with arduino and not with esp8266
This is likely because the code you have is not really portable Arduino code. - Even though is being called "Arduino" code.
If it is using code that is outside Arduino core functions by using AVR specific header files and/or avr-gcc avr specific avr libC functions then it will fail to compile on non AVR systems.
This is quite common.
Depending on the code, it may or may not be difficult to fix.
Likely in this case, the library is attempting to use the AVR specific PROGMEM hacks provided by the AVR libC tools.
progmem is AVR specific. While some of these capabilities have been implemented in other cores to allow code that attempts to use this AVR specific progmem hacks to work. Not all cores have done this.
--- bill
I just tried my ST7920 with U8g2lib on an ESP8266.
It works fine with the SW_SPI constructor. Not with HW_SPI.
David.