?? st7920.lst
字號:
C51 COMPILER V7.06 ST7920 07/16/2010 10:05:25 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE ST7920
OBJECT MODULE PLACED IN .\obj\ST7920.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE ST7920.c BROWSE DEBUG OBJECTEXTEND PRINT(.\obj\ST7920.lst) OBJECT(.\obj\ST7
-920.obj)
stmt level source
1 /*-----------------------------------------------
2 名稱:st7920字庫液晶顯示
3 論壇:www.doflye.net
4 編寫:shifang
5 日期:2009.5
6 修改:無
7 內容:通過顯示字符、數字、漢字和圖片測試液晶基本功能
8 ------------------------------------------------*/
9 #include <reg52.h>
10 #include <intrins.h>
11 #include "delay.h"
12 #include "ST7920.h"
13
14 sbit RS = P2^4;
15 sbit RW = P2^5;
16 sbit E = P2^6;
17 sbit RES = P2^3;
18 sbit PSB = P2^1;
19 sbit PAUSE = P3^0;
20
21 #define DataPort P0 //MCU P0<------> LCM
22
23 /*------------------------------------------------
24 檢測忙位
25 ------------------------------------------------*/
26 void Check_Busy()
27 {
28 1 RS=0;
29 1 RW=1;
30 1 E=1;
31 1 DataPort=0xff;
32 1 while((DataPort&0x80)==0x80);//忙則等待
33 1 E=0;
34 1 }
35 /*------------------------------------------------
36 寫命令
37 ------------------------------------------------*/
38 void Write_Cmd(unsigned char Cmd)
39 {
40 1 Check_Busy();
41 1 RS=0;
42 1 RW=0;
43 1 E=1;
44 1 DataPort=Cmd;
45 1 DelayUs2x(5);
46 1 E=0;
47 1 DelayUs2x(5);
48 1 }
49 /*------------------------------------------------
50 寫數據
51 ------------------------------------------------*/
52 void Write_Data(unsigned char Data)
53 {
54 1 Check_Busy();
C51 COMPILER V7.06 ST7920 07/16/2010 10:05:25 PAGE 2
55 1 RS=1;
56 1 RW=0;
57 1 E=1;
58 1 DataPort=Data;
59 1 DelayUs2x(5);
60 1 E=0;
61 1 DelayUs2x(5);
62 1 }
63 /*------------------------------------------------
64 液晶屏初始化
65 ------------------------------------------------*/
66 void Init_ST7920()
67 {
68 1 DelayMs(40); //大于40MS的延時程序
69 1 PSB=1; //設置為8BIT并口工作模式
70 1 DelayMs(1); //延時
71 1 RES=0; //復位
72 1 DelayMs(1); //延時
73 1 RES=1; //復位置高
74 1 DelayMs(10);
75 1 Write_Cmd(0x30); //選擇基本指令集
76 1 DelayUs2x(50); //延時大于100us
77 1 Write_Cmd(0x30); //選擇8bit數據流
78 1 DelayUs2x(20); //延時大于37us
79 1 Write_Cmd(0x0c); //開顯示(無游標、不反白)
80 1 DelayUs2x(50); //延時大于100us
81 1 Write_Cmd(0x01); //清除顯示,并且設定地址指針為00H
82 1 DelayMs(15); //延時大于10ms
83 1 Write_Cmd(0x06); //指定在資料的讀取及寫入時,設定游標的移動方向及指定顯示的移位,光標從右向左加1
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -