Welcome! Log In Create A New Profile

Advanced

There maybe a problem for ST7920 initial in ultralcd_st7920_u8glib_rrd.h

Posted by Chincheng 
There maybe a problem for ST7920 initial in ultralcd_st7920_u8glib_rrd.h
February 17, 2017 04:16AM
Dear sir,
I had tried a new LCD module which use other one LCD controller that compatible to ST7920.
I got a problem about the initial code @ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) :
ST7920_CS();
u8g_Delay(90); //initial delay for boot up
ST7920_SET_CMD();
ST7920_WRITE_BYTE(0x08); //display off, cursor+blink off
ST7920_WRITE_BYTE(0x01); //clear CGRAM ram
u8g_Delay(10); //delay for cgram clear
ST7920_WRITE_BYTE(0x3E); //extended mode + gdram active
....................

According to the datasheet (ST7920 V4.0) page 24 command --> extended function set
"IN SAME INSTRUCTION CANNOT ALTER DL RE AND G AT ONCE, MAKE SURE THAT CHANGE DL AND G FIRST AND THEN RE.
That is,the command ST7920_WRITE_BYTE(0x3E); is not a good way to change to extended mode and turn on graphic on.
if you try to stop program at this command then you will see the STN LCD abnormal, the ST7920 dose not work well (Maybe this a bug of ST7920 controller).
the best way should be:
ST7920_WRITE_BYTE(0x34); // change from basic mode to extended mode
ST7920_WRITE_BYTE(0x36); // turn on graphic

The 2nd problem is:
According to the datasheet page 16, turn on display command should be executed at basic mode, should not at extended mode(Maybe this a bug of ST7920 controller)
if it in extended mode, it should change back to basic mode, then turn on display,
ex:
ST7920_WRITE_BYTE(0x32); // back to basic mode
ST7920_WRITE_BYTE(0x0c); // turn on display

The 3rd problem is:
The display on command should has high priority then graphic on. that is:
If display off, then the LCD should has no display, even graphic on command is on.
If display on, then the character display is on, graphic is depend on graphic on/off command.
=======================================================================
so I thought the code should be:
ST7920_CS();
u8g_Delay(90); //initial delay for boot up
ST7920_SET_CMD();
ST7920_WRITE_BYTE(0x08); //display off, cursor+blink off
ST7920_WRITE_BYTE(0x01); //clear CGRAM ram
u8g_Delay(10); //delay for cgram clear
ST7920_WRITE_BYTE(0x34); //extended mode, graphic off
for(y=0;yEdited 2 time(s). Last edit at 02/17/2017 04:24AM by Chincheng.
Sorry, only registered users may post in this forum.

Click here to login