用C#操作IO端口2-控制液晶/荧光显示器-2

来源:互联网 发布:网店美工教程 编辑:程序博客网 时间:2024/04/30 03:38
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

作者: Levent S。  翻译:Aweay

编码

在你开始编码前,你需要了解基本的HD44780控制器指令。下表是来自日立网站上的介绍,为了好理解,我加入了一些额外的信息。

InstructIOn

Code

DescriptIOn

ExecutIOn time**

RS

R/W

DB7

DB6

DB5

DB4

DB3

DB2

DB1

DB0

Clear display

0

0

0

0

0

0

0

0

0

1

Clears display and returns cursor to the home positIOn (address 0)。

1。64mS

Cursor home

0

0

0

0

0

0

0

0

1

*

Returns cursor to home positIOn (address 0)。 Also returns display being shifted to the original positIOn。 DDRAM contents remains unchanged。

1。64mS

Entry mode set

0

0

0

0

0

0

0

1

I/D

S

Sets cursor move directIOn (I/D), specifies to shift the display (S)。 These operatIOns are performed during data read/write。 I/D = 0 --> cursor is in decrement positIOn。 I/D = 1 --> cursor is in increment positIOn。 S = 0 --> Shift is invisible。 S = 1 --> Shift is visible

40uS

Display On/Off control

0

0

0

0

0

0

1

D

C

B

Sets On/Off of all display (D), cursor On/Off (C) and blink of cursor positIOn character (B)。 D = 0 --> Display off。 D = 1 --> Displan on。 C = 0 --> Cursor off。 C = 1 --> Cursor on。 B = 0 --> Cursor blink off。 B = 1 --> Cursor blink on。

40uS

Cursor/display shift

0

0

0

0

0

1

S/C

R/L

*

*

Sets cursor-move or display-shift (S/C), shift directIOn (R/L)。 DDRAM contents remains unchanged。 S/C = 0 --> Move cursor。 S/C = 1 --> Shift display。 R/L = 0 --> Shift left。 R/L = 1 --> Shift right

40uS

FunctIOn set

0

0

0

0

1

DL

N

F

*

*

Sets interface data length (DL), number of display line (N) and character font(F)。 DL = 0 --> 4 bit interface。 DL = 1 --> 8 bit interface。 N = 0 --> 1/8 or 1/11 Duty (1 line)。 N = 1 --> 1/16 Duty (2 lines)。 F = 0 --> 5x7 dots。 F = 1 --> 5x10 dots。

40uS

Set CGRAM address

0

0

0

1

CGRAM address

Sets the CGRAM address。 CGRAM data is sent and received after this setting。

40uS

Set DDRAM address

0

0

1

DDRAM address

Sets the DDRAM address。 DDRAM data is sent and received after this setting。

40uS

Read busy-flag and address counter

0

1

BF

CGRAM / DDRAM address

Reads Busy-flag (BF) indicating internal operatIOn is being performed and reads CGRAM or DDRAM address counter contents (depending on prevIOus instructIOn)。 I used some delay functIOns in my code which are ThreadSleep if you don't want to use these you can check the Busy Flag and make your LCD speedy。 BF = 0 --> Can accept instructIOn。 BF = 1 --> Internal operatIOn in progress no additIOnal operatIOn can be accepted。

0uS

Write to CGRAM or DDRAM

1

0

write data

Writes data to CGRAM or DDRAM。

40uS

Read from CGRAM or DDRAM

1

1

read data

Reads data from CGRAM or DDRAM。

40uS

* = Not important, Can be "1" or "0"
** = ExecutIOn Time is a time needed which the LCD needs for the operatIOn。

CGRAM is character generator RAM, this ram can hold user defined graphic characters。 This capability gains these modules popularity because of this you can make bargraphs and your own language's special characters(Maybe Chinese, Korean, Turkish, Greek, etc。)。

DDRAM is the Display Data RAM for these modules which represents the hexadecimal Display data adresses。 See below:

Char。  

Line 1

Line 2

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

80

81

82

83

84

85

86

87

88

89

8A

8B

8C

8D

8E

8F

 

C0

C1

C2

C3

C4

C5

C6

C7

C8

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

原创粉丝点击