lab 12 : liquid crystal displays: slide 2 slide 3 slide 4 slide 5 slide 6 slide 7 dmd basics : slide...

12
Lab 12 : Liquid Crystal Displays : Slide 2 Slide 3 Slide 4 Slide 5 Slide 6 Slide 7 DMD Basics : Slide 8 Slide 9 Slide 10 Slide 11 Slide 12 Data Write the Character “A” : The “Shift Display” Command : Multiple Data Write Operations: Display “AB”: ROM Based Electronic Billboard System : ROM Based Electronic Billboard System Timing : Viewable DDRAM : Off-Screen DDRAM : DDRAM Cylinder Effect : DMD Sample Program : DMD Custom Characters :

Upload: jamir-morin

Post on 14-Dec-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Lab 12 : Liquid Crystal Displays:

Slide 2

Slide 3

Slide 4

Slide 5

Slide 6

Slide 7

DMD Basics :

Slide 8

Slide 9

Slide 10

Slide 11

Slide 12

Data Write the Character “A” :

The “Shift Display” Command:

Multiple Data Write Operations: Display “AB”:

ROM Based Electronic Billboard System :

ROM Based Electronic Billboard System Timing :

Viewable DDRAM :

Off-Screen DDRAM :

DDRAM Cylinder Effect :

DMD Sample Program :

DMD Custom Characters :

DMD Display

Command Register

ROM Data

Commands

DMD

H E L L O

Lab 12 : DMD Basics :Dot Matrix Displays with Hitachi HD44780 controller (or DMD) understand various commands and can easily be programmed to display scrolling messages. Many electronic products use this type of display as an electronic billboard to display messages.

W O R L D

H E L L O

W O R L D

H E L L O

W O R L D

H E L L

W O R L

H E L

W O R

H E

W O

H

W

Counter

ROM

The DMD display can be connected to a ROM. The ROM contains the DMD codes. The counter cycles the address bus to send the codes to the display.

H E L L 0

W 0 R L D

H E L L 0

W 0 R L D

H E L L

W 0 R L

H E L

W 0 R

H E

W 0

H

W

DMD Display

The DMD accepts 2 types of codes. Data codes (ASCII) and command codes (commands like “Shift Message”). The ROM stores a mix of data and commands which makes up the DMD message. Here is the HELLO WORLD sample program.

Initialize the display: Use top line : Auto move cursor.

H E L L O

W O R L D

Shift the message to the right

H E L L O

W O R L D

Shift the message to the right

H E L L O

W O R L D

Shift the message to the right

H E L L

W O R L

Shift the message to the right

H E L

W O R

Shift the message to the right

H E

W O

Shift the message to the right

H

W

Shift the message to the right Write next data on the bottom line :

Slide #2

S I

O1 O0

SZ

I0 I1

>Clk

>Clk

Command Register

Data Registers : Display Data RAM : DDRAM

Character Generator ROM : CGROM CGRAM

8 Bit Data Bus

8 Tri-State Buffers

8 Bit Mux/DeMux

00 0F

E RS R/W DB7 DB0

Lab 12: Data Write Operation: Character “A”:

Display the character “A”: Step 1: the computer sends the code 01000001 to the data bus (DB0…DB7).

0 1 0 0 0 0 0 1

Computer writes code for “A”

Step 2: the computer sets R/W (Read Write) to 0. This enables the input buffers and transfers the data bus to MUX.

Step 3: the computer sets RS (Register Select) to 1. This selects channel 1 of Mux/DeMux. The Mux passes the data bus to the CGROM.

0

HiZ

1

Step 4: The CGROM retrieves the pixel pattern for character A and gets ready to transfer it to DDRAM.Step 5: The computer provides a clock pulse to the E (enable) input. This clocks the DDRAM registers and completes the write operation.

A

A ROM can be used to send codes to the DMD. However, the DMD was designed to work with a computer system. Let’s look at the computer interface

A

Slide #3

Lab 12: Shift Display Command:

Shift Display Right :Step 1: the computer sends the code 00011100 to the data bus (DB0…DB7).

0 0 0 1 1 1 0 0

Computer writes “Shift Display Right”

command

Step 2: the computer sets R/W (Read Write) to 0. This enables the input buffers and transfers the data bus to MUX.

Step 3: the computer sets RS (Register Select) to 0. This selects channel 0 of Mux/DeMux. The Mux passes the data bus to the Command Register.

0

HiZ

0

Step 4: The computer provides a clock pulse to the E (enable) input. This clock the Command Register and transfers the command.

S I

O1 O0

SZ

I0 I1

>Clk

>Clk

Command Register

Data Registers : Display Data RAM : DDRAM

Character Generator ROM : CGROM CGRAM

8 Bit Data Bus

8 Tri-State Buffers

8 Bit Mux/DeMux

00 0F

E RS R/W DB7 DB0

A

Let’s assume that the character “A” has been written and is being displayed. We would like to shift the character one position to the right. The DMD has a “Shift Display Right” command.

0 0 0 1 1 1 0 0

Step 5: The DMD displays executes the shift command.

A

Slide #4

S I

O1 O0

SZ

I0 I1

>Clk

>Clk

Command Register

Data Registers : Display Data RAM : DDRAM

Character Generator ROM : CGROM CGRAM

8 Bit Data Bus

8 Tri-State Buffers

8 Bit Mux/DeMux

00 0F

E RS R/W DB7 DB0

Lab 12: Multiple Data Write Operations: Display “AB”:

Display the character “A”: Here are all the steps…

When a computer needs to display a message (more than one character) it must send several data characters one after the other. The computer must give the DMD display enough time to finish one data write operation before it can start another.

0 1 0 0 0 0 0 1

Computer writes code for “A”

0

HiZ

1

A

A

Display the character “B”: Before the “B” character can be displayed the computer must wait until the DMD finishes displaying the letter “A”. The computer must read the DMD Busy Flag (BF).

BF=1 means DMD is busy and not ready for a new data write operation.Here are all the steps…

0 1

HiZ

1 0 0 0 0 0 0 0

1 0 0 0 0 0 0 0

Computer reads the Busy Flag

BF

BF

A

IF BF=1 then the computer must repeat the BF read operation until it finds BF=0. At this time it can proceed with the data write operation of character “B”.

0 1 0 0 0 0 1 0

Computer writes code for “B”

0

HiZ

1

B

B

Slide #5

Counter

ROM

DMD Display

Lab 12: ROM Based Electronic Billboard System The DMD display was designed to be used with a computer system. The computer writes data/command codes and then reads the Busy Flag to see if the DMD is ready for the next write operation.

A ROM based system can write data and command codes but it cannot read the Busy Flag!

To make a ROM based system work it is necessary that the DMD be given enough time to complete a write operation before beginning the next write operation. According to the Hitachi data sheets the slowest write operation takes 1.64 milliseconds. Many other DMD operations execute in microseconds. The ROM based electronic billboard system uses a clock with a clock rate of 12 PPS (or a period of 83 milliseconds). This means that the ROM sends out the code for one write operation and then waits 83 milliseconds to send out the code for the next write operation. At this transfer rate it is NOT necessary to read the Busy Flag and the system works error free! The only disadvantage is that you cannot go any faster than 83 milliseconds per transfer. A computer, on the other hand, can speed up the transfers whenever necessary. This can be useful to give the illusion that an entire word (several characters) can appear on the display at once (instead of 1 character at a time). A computer has more control over the display than a ROM based electronic billboard system. A computer based electronic billboard system is like a car with a variable gas pedal in it. It can go fast or slow whenever necessary.

A B

83 milliseconds later

Slide #6

Lab 12: ROM Based Electronic Billboard System Timing:

ROM

Data

Command Register

DB0DB1DB2DB3DB4DB5DB6DB7

>Ck

>Ck

E RS

Command

RS=1

RS=0

R/W

256X9

Q8Q7Q6Q5Q4Q3Q2Q1Q0

A1A2A3A4A5A6A7

A0

Q20

Q21Q22Q23Q24Q25Q26Q27Q28Q29

Q32

Q19

Q0

>Clk

25.175 Meg PPS

Counter

R/W of DMD: The ROM cannot read the Busy Flag. The read mode is not required.Q8 of ROM: Q8=1 for data write and Q8=0 for command write. Q20 of Counter: DMD E requires a negative edge to complete a write operation.Q20 frequency =

25.175 Meg PPS/221 = 12.004 PPS

Q20 period=1/12.004 =83 milliSec.

Q20

Q21

Q22

Q28

Counter timing diagram.

The counter changes the address of the ROM at every negative edge of Q20

Old 8 bit address

New 8 bit address

New 8 bit address

The ROM also changes the data bus at each negative edge of Q20. When the data bus is changing you should NOT clock the DMD (input E). The inverter ensures the DMD is not clocked when the data bus is changing. Here is how it works…

NewOld The positive edge on Q20 passes through the inverter and becomes a negative edge which clocks the DMD. The DMD is clocked when address and data bus are stable (in the middle of the yellow zone).Slide #7

Lab 12: Viewable DDRAM :DDRAM (Display Data RAM) is the memory which stores the data that is viewed by the user of the DMD. It displays 2 lines of 16 characters. It also has 24 off-screen characters. The off-screen character will be explained later.

Data

Command Register

DB0DB1DB2DB3DB4DB5DB6DB7

>Ck

>Ck

E RS

Command

RS=1

RS=0

R/W

Each character position is assigned an address. Line 1 (top) addresses begin at 00HEX and ends at 27HEX. Line 2 (bottom) addresses begin at 40HEX and ends at 67HEX. The addresses are in hex and can easily be converted to binary if you remember: 1 hex numeral = 4 bit binary.

Viewable : 16 Characters Off-Screen : 24 Characters00 01 02 03 04 05 06 07 08 09 0

A0B

0C

0D

0E 0F 10 11 12 13 24 25 26 27

40 41 42 43 44 45 46 47 48 49 4A

4B

4C

4D

4E 4F 50 51 52 53 64 65 66 67

To display the word “Hello” in the middle of line 1 you would write the command “Set DDRAM address =05H” and then write the data characters “Hello”.

DDRAM Add=05

H e l l o

To display the word “World” in the middle of line 2 you would write the command “Set DDRAM address =45H” and then write the data characters “World”.

DDRAM Add=45

W o r l d

Slide #8

Viewable : 16 Characters00 01 02 03 04 05 06 07 08 09 0

A0B

0C

0D

0E 0F 10 11 12 13 14 15 16 17

40 41 42 43 44 45 46 47 48 49 4A

4B

4C

4D

4E 4F 50 51 52 53 54 55 56 57

Off-Screen :

Lab 12: Off-Screen DDRAM :The off-screen DDRAM characters can be used to store display data and then later scroll it into view. It is like a holding area for messages. While the user pauses to read the on-screen message the delay can be used to write off-screen.

Data

Command Register

DB0DB1DB2DB3DB4DB5DB6DB7

>Ck

>Ck

E RS

Command

RS=1

RS=0

R/W

DDRAM Add=00

H e l l o

DDRAM Add=40

o r l d

Write the message “Hello World” in the viewable area of the DMD display. Write the message “Good Day” off-screen.

DDRAM Add=10

G o o d

DDRAM Add=50

D a y

The user will see the message “Hello World” and it will seem like the system has paused. The pause is actually the time taken to write “Good Day” off-screen. The “Shift Display Left” command will be used to move the “Good Day” message into view while scrolling “Hello World” out of view.

Shift Display Left

W

Viewable : 16 Characters

Shift Display Left

Viewable : 16 Characters

Shift Display Left

Viewable : 16 Characters

Shift Display Left

Viewable : 16 Characters

Shift Display Left

Viewable : 16 Characters

Shift Display Left

Viewable : 16 Characters00 01 02 03 04 05 06 07 08 09 0

A0B

0C

0D

0E 0F 10 11 12 13 14 15 16 17

40 41 42 43 44 45 46 47 48 49 4A

4B

4C

4D

4E 4F 50 51 52 53 54 55 56 57

H e l l o

o r l d

G o o d

D a yW

Off-Screen Off-Screen

The “Shift Display Left” command moves the message left one character position. Five “Shift Display Left” commands are needed to move “Hello World” off screen. The “Shift Display Left” command moves the message to the left but actually moves the Viewable Window to the right. To make the message “Hello World” re-appear you would need to use 5 “Shift Display Right” commands.

Slide #9

01

02

03

04

05

06

07

08

09

41 4

243

44

45

46

47

48

49

02

03

04

05

06

07

08

09

42 4

344

45

46

47

48

49

0A

4A

0B

03

04

05

06

07

08

09

4B

43 4

445

46

47

48

49

0A

4A

0B

0C

04

05

06

07

08

09

4B

4C

44 4

546

47

48

49

0A

4A

Viewable : 16 Characters Off-Screen : 24 Characters00 01 02 03 04 05 06 07 08 09 0

A0B

0C

0D

0E 0F 10 11 12 13 24 25 26 27

40 41 42 43 44 45 46 47 48 49 4A

4B

4C

4D

4E 4F 50 51 52 53 64 65 66 67

Lab 12: DDRAM Cylinder Effect:DDRAM memory is laid out like a cylinder. Cut out the entire rectangle representing DDRAM and fold it back into a loop.

00

01

02

03

04

05

06

07

08

40 4

142

43

44

45

46

47

48

Spin the cylinder and you can see more DDRAM addresses.

00

01

02

03

04

05

06

07

08

40 4

142

43

44

45

46

47

48

0B

0C

04

05

06

07

08

09

4B

4C

44 4

546

47

48

49

0A

4A

Spin it more and eventually you reach the last address 27 and 67.

G o o dD a y

Go o d D a y

27 and 67 are actually next to 00 and 40 in memory. This means if you write a message off screen at the end of the first line it is next to a message written at address 00. The “Shift Display Right” command can bring both messages into view.

Viewable Characters!

03

04

24

25

26

27

00

01

43

44

64 6

566

67

40

41

02

42

Slide #10

ROM

Data

Command Register

DB0DB1DB2DB3DB4DB5DB6DB7

>Ck

>Ck

E RS

Command

RS=1

RS=0

R/W

Q8Q7Q6Q5Q4Q3Q2Q1Q0

A1A2A3A4A5A6A7

A0

Q20

Q21Q22Q23Q24Q25Q26Q27Q28Q29

Q32

Q19

Q0

>Clk

25.175 Meg PPS

Counter

Lab 12: DMD Sample Program :The ROM will be loaded with a “Sample Program”.

Sample Program

Address 0

Address 8

The counter will start at 0 and cycle forward. Each new count state generates a new address for the ROM and a new code is written to the DMD display.

From DMD command Summary Sheet in Chapter 12.

000000000

0001110000

0011 1000 (38)

Set Display Mode (Display Function)

DL sets the Data Bus size. N sets the number of lines to be used. F sets the Dot Matrix Font. (1st command)

0 0 10 **FNDL

0 0 0 1 1 1 0 0 0038

DL = 1 : Use an 8 bit Data Bus.N = 1 : Use 2 lines of the displayF =0 : 5x7 Dot Matrix Font.

100000000

0000000001

0000 0001 (01)

0 0 0 0 0 0 0 0 1001

Clear Display 0 0 00 10000 Clears display and returns cursor to home position (DDRAM address = 00H).

010000000

000000110

0000 0110 (06)

0 0 0 0 0 0 1 1 0006

Set the data write mode

0 0 0 0 0 0 1 I/D S I/D sets the CURSOR/DISPLAY move direction. The CURSOR/DISPLAY will automatically move to the next DDRAM/CGRAM address after each data write. S specifies to shift the display or to move the cursor.

I/D = 1 : Increment the DDRAM address S = 0 : Move the cursor after data write. Display Freeze

110000000

000001100

0000 1100 (0C)

0 0 0 0 0 1 1 0 000C

D = 1 : Turn the entire display ON. C = 0 : Turn the cursor OFF

Set Display/Cursor On/Off D sets display On/Off. C sets cursor On/Off. B enables the character at the cursor position to Blink/Not Blink.

0 0 00 BCD10

B= 0 :DO NOT Blink the character at the cursor position

001000000

011000000

1100 0000 (C0)

0 1 1 0 0 0 0 0 00C0

100 0000 = 40 Hex (Line 2, first position)

Set DDRAM Address

Sets the starting DDRAM address. The DDRAM ASCII/Jap/Custom characters are sent to this starting address after this setting.

0 1 ADD (7 bit address)

101000000

101010100

T

1 0 1 0 1 0 1 0 0154

0101 0100 = 54 Hex = “T” (see the CGROM table)

8 bit code for ASCII/JAP/Custom Characters

CGRAM/DDRAM Data Write

Writes data into DDRAM or CGRAM. Used after address has been set. The address pointer is inc/dec automatically.

1

011000000

101100101

T

1 0 1 1 0 0 1 0 1165

0110 0101 = 65 Hex = “e” (see the CGROM table)

8 bit code for ASCII/JAP/Custom Characters

CGRAM/DDRAM Data Write

Writes data into DDRAM or CGRAM. Used after address has been set. The address pointer is inc/dec automatically.

1

e

111000000

101110011

T

1 0 1 1 1 0 0 1 1173

0111 0011 = 73 Hex = “s” (see the CGROM table)

8 bit code for ASCII/JAP/Custom Characters

CGRAM/DDRAM Data Write

Writes data into DDRAM or CGRAM. Used after address has been set. The address pointer is inc/dec automatically.

1

e s

000100000

101110100

T

1 0 1 1 1 0 1 0 0174

0111 0100 = 74 Hex = “t” (see the CGROM table)

8 bit code for ASCII/JAP/Custom Characters

CGRAM/DDRAM Data Write

Writes data into DDRAM or CGRAM. Used after address has been set. The address pointer is inc/dec automatically.

1

e s t

03800100600C0C0154165173174

Command Register

The first 5 codes in ROM (begin with 0xx) are DMD commands they are needed to initialize the display. While these codes are being executed the user will see nothing appear on the display. This initialization sequence is necessary and must be done before the message can be displayed. The last four codes in ROM (begin with 1xx) are ASCII data. They spell out the test message.

Slide #11

Data

Command Register

DB0DB1DB2DB3DB4DB5DB6DB7

>Ck

>Ck

E RS

Command

RS=1

RS=0

R/W

CGRAM-3

DDRAM

1 0 0 0 0 0 0 0 0

5 Pixels

0 0 1 0 1 1 0 0 0

Lab 12: DMD Custom Characters :Custom characters are user defined. DMD displays have 8 custom characters. A custom character is initialized once and then accessed as many times as necessary. A happy face character will be created and displayed.

Step 1: The face will be saved into CGRAM-3. Use the “CGRAM Address Set” command to inform the DMD display that the next data transfers are pixel layouts that belong in CGRAM. This command prevents the DMD from transferring the data to DDRAM as ASCII data. CGRAM Address Set = 058 = 01 01 1000 (6 bit address is 18 hex for CG3).

01 01 1000 Set CGRAM-3

Step 2: Use data write operations to fill in the pixel layout of the happy face. Remember each row is made up of 5 dots(pixels). The character is made up of 7 rows (+ 1 cursor row) of 5 pixels. It will take 8 data write operations to define the face. Remember data writes now go to CGRAM. Logic 0 = pixel off Logic 1 = pixel on

1 0 0 0 0 1 0 1 01 0 0 0 0 0 0 0 0

Step 3: To access the character you must issue a DDRAM Address Set command. This will cause subsequent data transfers to be sent to DDRAM and stop data transfers to CGRAM. The face character can be accessed at address 03 (see chapter 12 for details). We will display it on the bottom line.

1 100 0000 DDRAM add. =40

1 0 0 0 0 0 0 1 11 0 0 0 0 0 1 0 01 0 0 0 1 0 0 0 11 0 0 0 0 1 1 1 01 0 0 0 0 0 0 0 01 0 0 0 0 0 0 0 0 Cursor row0 1 1 0 0 0 0 0 0

ROM

05810010A10010411110E1001000C0103

Slide #12