Pages: 1 [2] 3 4   Go Down
Author Topic: ST7920 Interface Question  (Read 12341 times)
0 Members and 1 Guest are viewing this topic.
Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?

Logged

Germany
Offline Offline
Edison Member
*
Karma: 136
Posts: 1479
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
u8g_WriteByte(u8g, dev, 0x080 | y );      /* y pos  */
u8g_WriteByte(u8g, dev, 0x080  );      /* set x pos to 0*/
this must be changed to:
Code:
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


Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Germany
Offline Offline
Edison Member
*
Karma: 136
Posts: 1479
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have code to drive the display in SPI mode if you need it.
Logged

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.

Germany
Offline Offline
Edison Member
*
Karma: 136
Posts: 1479
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Germany
Offline Offline
Edison Member
*
Karma: 136
Posts: 1479
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Such a pin is not listed for the connector of the NHD-19232WG-BTMI-V#T  smiley-sad
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That's why I suggested looking for a jumper (or shorting link) on the PCB.
Logged

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.

Germany
Offline Offline
Edison Member
*
Karma: 136
Posts: 1479
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Finland
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?

Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Germany
Offline Offline
Edison Member
*
Karma: 136
Posts: 1479
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 24, 2012, 04:29:33 pm by dc42 » Logged

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.

Germany
Offline Offline
Edison Member
*
Karma: 136
Posts: 1479
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Logged

Pages: 1 [2] 3 4   Go Up
Jump to: