Graphic LCDs Chapter 18 Sepehr Naimi www Nicer

  • Slides: 19
Download presentation
Graphic LCDs Chapter 18 Sepehr Naimi www. Nicer. Land. com

Graphic LCDs Chapter 18 Sepehr Naimi www. Nicer. Land. com

Graphic LCDs n The screen of graphic LCDs is made of pixels. 2

Graphic LCDs n The screen of graphic LCDs is made of pixels. 2

Graphic LCD characteristics Monochrome vs. colored n Monochrome n n Pixels are either ON

Graphic LCD characteristics Monochrome vs. colored n Monochrome n n Pixels are either ON or OFF Colored 3

Graphic LCD Characteristics Dot pitch and Dot size n GDM 12864 128 x 64

Graphic LCD Characteristics Dot pitch and Dot size n GDM 12864 128 x 64 mono-colored LCD 4

Graphic LCD Characteristics image diagonal size vs. advertised diagonal size n n n (image

Graphic LCD Characteristics image diagonal size vs. advertised diagonal size n n n (image diagonal size)2 = (number of horizontal pixels × dot pitch)2+ (number of vertical pixels × dot pitch)2 (image diagonal size)2 = (1024 × 0. 28 mm)2 + (768 × 0. 28 mm)2 = 358. 4 mm Image diagonal size (inches) = 358. 4 mm × 0. 039 inch per mm = 13. 98 inches 5

LCD Controller and Frame Buffer 6

LCD Controller and Frame Buffer 6

Buffer size Buffer memory size (in byte) = Horizontal Pixels × Vertical Pixels ×

Buffer size Buffer memory size (in byte) = Horizontal Pixels × Vertical Pixels × BPP 8 n Buffer size in a 640 x 480 256 -color LCD is: n n 28 = 256 BPP = 8 bits (640 * 480 * 8) / 8 = 307200 bytes = 300 KB 7

Storing pixels in the memory 8

Storing pixels in the memory 8

Defining Font and displaying texts 9

Defining Font and displaying texts 9

Font 10

Font 10

Horizontal vs. Vertical n Horizontal n Vertical 11

Horizontal vs. Vertical n Horizontal n Vertical 11

PCD 8544 LCD (Nokia 5110) 12

PCD 8544 LCD (Nokia 5110) 12

Specifications n n 84 x 48 Monochrome 13

Specifications n n 84 x 48 Monochrome 13

PCD 8544 LCD (Nokia 5110) n n n Power Pins: VCC (VDD) and GND

PCD 8544 LCD (Nokia 5110) n n n Power Pins: VCC (VDD) and GND (VSS) BL (Backlight) SPI pins: CE (SS), DIN (MOSI), and SCLK D/C# (Data/Command#) Reset# 14

Storing 84 x 48 pixels in the DDRAM 15

Storing 84 x 48 pixels in the DDRAM 15

Commands n n n Function set D/C 0 D 7 0 Bit H V

Commands n n n Function set D/C 0 D 7 0 Bit H V Usage Extended/Basic Vertical/Horizontal PD Power Down/Active D 6 0 D 5 1 D 4 0 D 3 0 D 2 PD D 1 V D 0 H Description 0: Basic, 1: Extended The bit chooses the direction of moving the address counting when auto increments. For common uses it is 0. (0: Horizontal, 1: Vertical) 0: Active, 1: Power down Extended Commands Instruction D/C D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 Set Temperature Coefficient 0 0 0 1 TC 0 Set Bias 0 0 1 0 BS 2 BS 1 BS 0 Set VOP 0 1 VOP 6 VOP 5 VOP 4 VOP 3 VOP 2 VOP 1 VOP 0 Basic Commands Instruction D/C D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 Display Configuration 0 0 0 1 D 0 E Set Y address of RAM 0 0 1 0 0 0 Y 2 Y 1 Y 0 Set X address of RAM 0 1 X 6 X 5 X 4 X 3 X 2 X 1 X 0 D 0 0 1 1 E 0 1 Display Mode Display blank All display segments on Normal mode Inverse video mode 16

PCD 8544 Initialization void glcd_init() { RCC->APB 2 ENR |= 0 x. FC|(1<<12); /*

PCD 8544 Initialization void glcd_init() { RCC->APB 2 ENR |= 0 x. FC|(1<<12); /* enable clocks for GPIO and SPI 1 */ /* MOSI (PA 7) and SCK(PA 5): alt. func. out, PA 4: output for CS */ GPIOA->CRL = 0 x. B 4 B 33344; SPI 1 ->CR 1 = 0 x 35 C; /* SPE = 1, BR = 3, FFD = 0, SSI and SSM = 1 */ GPIOA->BSRR = (1<<GLCD_CS)|(1<<GLCD_RESET); /* make CS and RESET pins high */ delay_ms(10); GPIOA->BRR = (1<<GLCD_RESET); /* reset the LCD (RESET = 0) */ delay_ms(70); GPIOA->BSRR = (1<<GLCD_RESET); /* release the RESET pin */ glcd_cmd(0 x 21); /* switch to extended command mode */ glcd_cmd(0 x 06); /* set temp. coefficient 2 */ glcd_cmd(0 x 13); /* set LCD bias mode 1: 48 */ glcd_cmd(0 x. C 2); /* set VOP to 7 V (VOP = 66) */ glcd_cmd(0 x 20); /* switch to basic mode */ glcd_cmd(0 x 0 C); /* set lcd display to normal mode */ } 17

Displaying Characters using Font const char font_table[][5] = { 0 x 7 e, 0

Displaying Characters using Font const char font_table[][5] = { 0 x 7 e, 0 x 11, { 0 x 7 f, 0 x 49, { 0 x 3 e, 0 x 41, { 0 x 7 f, 0 x 49, { 0 x 7 f, 0 x 09, { 0 x 3 e, 0 x 41, 0 x 49, . . . }; { 0 x 11, 0 x 49, 0 x 41, 0 x 22, 0 x 49, 0 x 09, 0 x 49, 0 x 7 e 0 x 36 0 x 22 0 x 1 c 0 x 41 0 x 01 0 x 7 a }, }, /* /* A B C D E F G */ */ void glcd_putchar(char c) { uint 8_t i; if((c < 'A')||(c > 'Z')) return; for (i = 0; i < 5; i++) glcd_data(font_table[c-'A'][i]); glcd_data(0); /* an empty column between chars */ } 18

Displaying “HELLO” on the LCD void glcd_set. Cursor(uint 8_t x, uint 8_t y) {

Displaying “HELLO” on the LCD void glcd_set. Cursor(uint 8_t x, uint 8_t y) { glcd_cmd(0 x 80 | x); /* set x */ glcd_cmd(0 x 40 | y); /* set y (bank) */ } int main() { glcd_init(); /* initialize the lcd */ glcd_clear(); glcd_set. Cursor(20, 2); /* move cursor to 20, 2 */ glcd_putchar('H'); glcd_putchar('E'); glcd_putchar('L'); glcd_putchar('O'); while(1) {} } 19