Go Down

Topic: ST7920 Interface Question (Read 13831 times) previous topic - next topic

smultron

Oliver:

I tried out ST7920 via the parallel 8-bit interface.

I think your library is wonderful, and its the closest thing to something I could really use. I've spent some time writing device headers for ST7920 for the glcd library, and got it to initialize and so, but the trouble is that the ST7920 memory mapping differs so much from the ks1080 that I would have to rewrite the WriteData function for glcd to get it to work.

This is why I would really like to see u8glib work for real with ST7920.

With my graphics module (from china) based on the ST7920 there is a problem with u8glib: u8glib cn only draw half the screen. The reason for this (quite common with ST7920 based 128x64 displays) is that the memory is mapped as shown in the following image.

I looked around u8glib but didn't want to start knifing around with no idea how its built. There are so many layers of abstraction.

Do you think there is a way to take this memory mapping model into account in u8glib ?


olikraus

Hi smultron

ST7920 SPI Interface:
With the initial author of this thread I currently try to get SPI mode working.
We just realized, that the SPI mode is completly different to what I have seen
from similar controllers. So, SPI mode is broken in the current u8glib and I have
fix this.

Library Software Architecture:
After writing dogm128 lib with many requests to support this or that device,
I decided to rewrite everything from scratch. Especially I wanted to introduce
a clear software architecture.

Starting from lowest level, there are:
- Communication interface: Does the physical transfer, abstracts SPI, Parallel
   Mode, maybe I2C in the future.
   Filenames: "u8g_com_..."
- Device/Controller level
   Contains display specific init sequence and data transfer.
   Connects to the com interface and defines the high level memory
   structure. Does (if required) the translation of the high level memory
   to controller level memory.
   So it does abstraction for parts of the memory architecture,
   init sequence and data transfer sequence.
   Filenames: "u8g_dev_..."
- High level memory management (Page Buffer, pb)
   Takes care on the sub frame buffer handling inside the AVR,
   writes pixel values to the AVR RAM.
   In prinziple it does an abstraction of the write pixel functionality.
   Filenames: "u8g_pb..."

Memory Architecture:
Your request only affects the data transfer itself, so only the Device
level is affected. The high level memory management will be the same.

In the device "u8g_dev_st7920_128x64" the current code is:
Code: [Select]

u8g_WriteByte(u8g, dev, 0x080 | y );      /* y pos  */
u8g_WriteByte(u8g, dev, 0x080  );      /* set x pos to 0*/

this must be changed to:
Code: [Select]

if ( y < 32 )
{
u8g_WriteByte(u8g, dev, 0x080 | y );      /* y pos  */
u8g_WriteByte(u8g, dev, 0x080  );      /* set x pos to 0*/
}
else
{
u8g_WriteByte(u8g, dev, 0x080 | (y-32) );      /* y pos  */
u8g_WriteByte(u8g, dev, 0x080 | 4);      /* set x pos to 64*/
}

well, i am not sure about the "4" here.
I will create an issue for this and add the code to u8glib.

Thanks for your input!

Oliver



dc42


Hello Oliver !

I can't get u8glib to work with my ST7920 display that is exactly similar to the DFRobot display.

I can't understand what is the correct pinout. In your wiki you give constructor as:

U8GLIB_ST7920_128X64(cs, a0 [, reset])

But in the lib examples (HelloWorld etc) it is given as:

U8GLIB_ST7920_128X64 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9

Also, to my understanding A0 = RS ... but RS is also CS in this module for serial mode. So how can the constructor require both CS and A0 ?

I've tried several ways of hooking up the display, but I only get datarubbish on the screen.

Could you please clarify the pinout and constructor for ST7920 ?



My ST7920 display uses 2 wires for serial interface, not 4. The pin marked E (Enable when using the parallel interface) becomes SCLK, and the R/W pin becomes SDATA or MOSI. RS has to be set high, the datasheet says this is the CS pin but also says that SCLK and SDATA should not be toggled when the chip is not enabled.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

olikraus

Hi dc42

Yes, i just saw the problem with SPI mode. It is completly broken. Parallel mode is almost fine (see my post before).
The SPI mode is totally different what i saw with other controllers from the same company. I had to change bigger parts of the software.

Thanks,
Oliver

dc42

I have code to drive the display in SPI mode if you need it.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

olikraus

I guess I have to send a sync byte and distribute 8 bit into two bytes. Next step for me is to implement this, and than try to do some testing.
Unfortunately my own display does not seem to support SPI mode (NHD-19232WG-BTMI-V#T). So maybe someone from the forum can do this.

Oliver

dc42

Pin 23 on the 7920 called PSB has to be tied to Vcc for parallel mode and to ground for serial mode. My display has this pin brought out to the edge connections. You might find that there is a movable jumper for this on the PCB of your display.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

olikraus

Such a pin is not listed for the connector of the NHD-19232WG-BTMI-V#T  :(

dc42

That's why I suggested looking for a jumper (or shorting link) on the PCB.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

olikraus

Ok, thanks, good point. I found a forum entry on the newhaven site of a similar display which describes the activision of the SPI mode. This could match...
Thanks,
Oliver

smultron

I wonder if its worth while to work with this ST7920

Has anyone had any luck getting more than 0.5 fps out of this LCD IC ?


dc42

AFAIR I got a refresh rate of between 10 and 20fps with my ST7920 display in SPI mode. I'll reconstruct the setup and measure it.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

olikraus

I have uploaded a new beta for u8glib (v0.11): http://code.google.com/p/u8glib/downloads/list
- updated memory model for the st7920 128x64 mode
- SPI transfer for st7920
I did not do any tests on it (hw not yet availabe). I only know that it compiles.
Also, i did not do any speed optimization.
Oliver


dc42

#28
Jan 24, 2012, 10:28 pm Last Edit: Jan 24, 2012, 10:29 pm by dc42 Reason: 1
So I got my ST7920 LCD display in serial mode working again. I'm drawing a couple of circles and a straight line on the display, and writing 6 lines of proportionally-spaced text to it, most of which cover almost the full width of the display. Each iteration (which includes a refresh of almost the entire display) along with a few calculations takes less than 57ms.

So the limiting FPS with my driver appears to be above 17.5 fps.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

olikraus

1) I managed to put my NHD-19232WG-BTMI-V#T into serial mode
2) U8glib is up and running in SPI and parallel mode for the ST7920
3) New download v0.12: Fixed memory mapping, improved speed for ST7920 SPI
4) Fixed an issue with the ST7920 128x64 memory mapping
5) Refresh rate: About 13 FPS (several lines, bitmaps and some text)
http://code.google.com/p/u8glib/downloads/list

Oliver



Go Up