STC8H Development (Ten): SPI driver Nokia5110 LCD (PCD8544)

Publisher:DreamyMoonLatest update time:2022-06-07 Source: eefocusKeywords:Nokia5110  LCD  PCD8544 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Nokia5110 LCD

I have a Nokia 5110 LCD that I bought a long time ago and it has been gathering dust in the cardboard box. Maybe it was given as a gift when I bought other accessories? It has been left there without any suitable use. Occasionally, when I see it, I always think about it when I have time.


This is what it looks like. In fact, there are several different versions of this module on the market. Another version has two rows of pins on the top and bottom to facilitate different PCB layouts, but the functions are the same.

Monochrome LCD, 84x48 pixels, with 4 blue LEDs as backlight. Display chip is Philips PCD8544.


Because it is the display screen of Nokia5110 mobile phone, it is generally called Nokia5110 LCD. In 2014, when large-screen mobile phones were not popular, this was a very good display output device. Compared with 1602 and 2004 LCD, it was small in size, high in resolution, cheap and sufficient in quantity.


Now there are 12864 LCD/OLED everywhere, and there are also color LCDs with higher resolutions to choose from, so few people use this module anymore.


PCD8544

Philips produces a single-chip low-power CMOS LCD driver controller chip, used to drive an 84x48 pixel LCD

Interface is SPI

Display memory = 6 banks x 84 segments x 8 bits = 4032 bits = 504 bytes

Each bank contains 84 columns/segments (from 0 to 83)

Each column can store 8 bits of data (from 0 to 7)

Pin

RST Reset

CE Chip Select, CS

DC Data/Command Select, D/C

DIN SPI data, MOSI

CLK SPI clock line

VCC power supply, this module is compatible with 3.3V and 5V, if there is no mark, it is recommended to use 3.3V

BL Backlight

GND Ground

Instruction Description

PCD8544 has very few instructions, even fewer than ST7567. The display mechanism is basically the same as ST7567.


Write data and write commands

Use D/C pin control, high level indicates write data, low level indicates write command


Function settings

Function set: 0x20, superimpose the following parameters


Power down control: 0x04 Power down mode

Entry mode: 0x02 addressing mode, after setting, it becomes vertical addressing, first down and then right; normal mode is first right and then down, generally use normal mode

Extended instruction set: Enable extended instructions. After enabling, you can modify temperature parameters, voltage reference offset, display voltage, and the last two are used to adjust the contrast of the LCD.

Display Control

Display control: 0x08, superimpose the following parameters


Display blank Display blank: 0x00

Normal mode Normal display: 0x04

All display segments on Display all: 0x01

Inverse video mode: 0x05

Coordinate positioning

Display structure of PCD8544

It can only locate to the byte, and write data after locating, and it will write down according to the set addressing mode


Set x coordinate: 0x80 superimposes values ​​between [0x00, 0x84)

Set the y coordinate: 0x40 superimposes values ​​between [0x00, 0x06)

Extension instructions

The following commands must be executed after enabling extended instructions to be effective


Temperature control Temperature factor, 0x04 Superposition value [0x00, 0x03]

Bias system voltage reference control, 0x10 superimposed value [0x00, 0x07]

Set Vop Display voltage control, 0x80 superimposed value [0x00, 0x7F]

These three instructions need to be explained. Improper settings may result in a completely black display or no display at all.


The temperature factor can be left unset, and the default value is used.

The larger the voltage reference is set, the higher the actual display voltage will be, and the darker the LCD display will be. If the screen does not display, you can try to adjust it to 0x07.

The displayed voltage is proportional to the set value. The higher the value, the higher the actual displayed voltage, and the darker the LCD display part.

Tested with STC8H

The following tests are performed using STC8H3K32 and FwLib_STC8


wiring

Before powering on, be sure to check whether VCC and GND are correct and whether the voltage is correct.


P37   -> RES, RESET

P36   -> DC, A0

P35   -> CE, Chip Select

P32   -> SCK, SCL, CLK, Clock

P12   -> BL, Backlight

P34 -> MOSI, Din

GND   -> GND

3.3V  -> VCC


Code

The code can be downloaded from GitHub or Gitee


GitHub: FwLib_STC8/tree/master/demo/spi/pcd8544_nokia5110_lcd

Gitee: FwLib_STC8/tree/master/demo/spi/pcd8544_nokia5110_lcd

initialization

// Reset

PCD8544_Reset();

// Set the contrast. If the display is too light or too dark, you need to adjust it yourself

PCD8544_SetContrast(0x06, 0x20);

// Set to normal display mode

PCD8544_SetDisplayNormal();


Turning the backlight on and off

// Turn on the backlight

PCD8544_SetBackLightState(HAL_State_ON);

// Turn off the backlight

PCD8544_SetBackLightState(HAL_State_OFF);


Qingping

PCD8544_Fill(0);

PCD8544_UpdateScreen();


Reverse

After turning on reverse display, you need to set it back to normal display mode to restore it. You cannot restore it by calling reverse display again.


PCD8544_SetDisplayInverted();


Line drawing

// Draw a line from (0,0) to (83,0)

PCD8544_DrawLine(0,   0,  83,  0, 1);

PCD8544_DrawLine(0,   0,   0, 47, 1);

PCD8544_DrawLine(83,  0,  83, 47, 1);

PCD8544_DrawLine(0,  47,  83, 47, 1);

PCD8544_UpdateScreen();


Display text

// Move the coordinates to (3,3)

PCD8544_GotoXY(3, 3);

// Use 5x7 font to display English

PCD8544_Puts("LCD:PCD8544", &Font_5x7, 1);

PCD8544_UpdateScreen();


Shutdown Mode

// Shutdown

PCD8544_SetPowerDownMode(HAL_State_ON);

// Power on

PCD8544_SetPowerDownMode(HAL_State_OFF);


Parameter Description

These three extended commands will affect the display. Improper settings will cause the display to be completely white or completely black.


#define PCD8544_SETTEMP             0x04 // Extended instruction set - Set temperature coefficient

#define PCD8544_SETBIAS             0x10 // Extended instruction set - Set bias system

#define PCD8544_SETVOP              0x80 // Extended instruction set - Write Vop to register


in


PCD8544_SETTEMP is the temperature factor, usually no need to set

PCD8544_SETBIAS is the bias level, usually set to a value between [3,7], the corresponding write is [0x13, 0x17]

PCD8544_SETVOP is the system voltage, which will be affected by the above two parameters

If there is no display or the display is completely black after initialization, you can adjust it according to the above range.


Demo

The video shows the contrast changes caused by adjusting the display voltage under different reference voltages.


https://www.bilibili.com/video/BV1eF411G7Y7


reference

https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library

https://lastminuteengineers.com/nokia-5110-lcd-arduino-tutorial/

Use Arduino UNO to drive Nokia5110 LCD https://www.youtube.com/watch?v=VtZvf5T98FI

Keywords:Nokia5110  LCD  PCD8544 Reference address:STC8H Development (Ten): SPI driver Nokia5110 LCD (PCD8544)

Previous article:STC8H Development (XI): GPIO single line driving multiple DS18B20 digital thermometers
Next article:Qinheng CH32V103C8T6 Development Environment Notes

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号