11 1 1 ORG 0000 H LJMP MAIN
- Slides: 84
11. 1. 1 简易键盘接口的实现 示例代码如下: ORG 0000 H LJMP MAIN ORG 0003 H ; INT 0外部中断 0入口地址 LJMP KRD ORG 0100 H MAIN: MOV SP, #70 H SETB IT 0 ; 设置INT 0下降沿触发 SETB EX 0 ; 开放INT 0中断 SETB EA ; 开放总中断 … ; 其他初始化代码 MAINLOOP: ; 主循环 … LJMP MAINLOOP 10
404页C程序 [例11 -1] 编程实现矩阵键盘的按键扫描并在数码LED上显示。 #include "stc 15. h"LED显示电路参考292页例8 -7, 显示程序也可参340页例9 -3 #include <intrins. h> //_nop_()函数在此库文件中 unsigned char code t_display[]={ //标准字模库 // 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 x 3 F, 0 x 06, 0 x 5 B, 0 x 4 F, 0 x 66, 0 x 6 D, 0 x 7 D, 0 x 07, 0 x 7 F, 0 x 6 F, 0 x 77, 0 x 7 C, 0 x 39, 0 x 5 E, 0 x 79, 0 x 71, //black - H J K L N o P U t G Q r M y 0 x 00, 0 x 40, 0 x 76, 0 x 1 E, 0 x 70, 0 x 38, 0 x 37, 0 x 5 C, 0 x 73, 0 x 3 E, 0 x 78, 0 x 3 d, 0 x 67, 0 x 50, 0 x 37, 0 x 6 e, //0. 1. 2. 3. 4. 5. 6. 7. 8. 9. -1 0 x. BF, 0 x 86, 0 x. DB, 0 x. CF, 0 x. E 6, 0 x. ED, 0 x. FD, 0 x 87, 0 x. FF, 0 x. EF, 0 x 46}; unsigned char code T_COM[]={0 x 01, 0 x 02, 0 x 04, 0 x 08, 0 x 10, 0 x 20, 0 x 40, 0 x 80}; //位码 sbit HC 595_RCK = P 5^4; //74 HC 595的12脚控制(存储或锁存时钟) unsigned char display_index; //显示位索引(指示 8个LED管的其一显示) unsigned char LED 8[8]; //显示缓冲 LED 8的值是t_display字模库序号值 void Timer 0 Init(void); //定时 1毫秒 @11. 0592 MHz void Send_595(unsigned char spidata); void Display. Scan(void); 28/67
[例11 -1]显示数据发送 编程实现矩阵键盘的按键扫描并在数码LED上显示。 //---------void Send_595(unsigned char spidata) { unsigned char spi_status=0; SPDAT=spidata; while(spi_status==0) //等传输完毕 { spi_status=SPSTAT; spi_status=spi_status&0 x 80; } SPSTAT=0 xc 0; //写 1清SPIF标志位 } //----- 显示扫描函数 -----void Display. Scan(void) { Send_595(~T_COM[display_index]); //输出位码 Send_595(t_display[LED 8[display_index]]); //输出段码 HC 595_RCK = 1; HC 595_RCK = 0; //锁存输出数据 if(++display_index >= 8) display_index = 0; //8位结束回 0 } 33/67
[例11 -1] 编程实现矩阵键盘的按键扫描并在数码LED上显示。 void Timer 0 Init(void) { AUXR |= 0 x 80; TMOD &= 0 x. F 0; TL 0 = 0 xcd; TH 0 = 0 xd 4; TF 0 = 0; TR 0 = 1; } //1毫秒@11. 0592 MHz //T 0 作于1 T模式 //设置T 0模式 0 //设置定时初值 //清除TF 0标志 //T 0开始计时 //----- T 0 的1 ms中断函数 -----void T 0_ISR(void) interrupt T 0_VECTOR { Display. Scan(); //1 ms扫描显示一位 cnt 50 ms++; } 34/67
(5)光标或显示移位控制(指令代码为 10 H/14 H/18 H/1 CH) RW RS 0 0 D 7 0 D 6 0 D 5 0 D 4 D 3 D 2 1 S/C R/L D 1 X D 0 X 功能: 10 H/14 H:光标左/右移动,AC减/加 1 18 H/1 CH: 整体显示左/右移动, 光标跟随移动, AC值不变。 S/C 0 0 1 R/L Description AC Value 0 Cursor moves left by 1 AC=AC-1 1 Cursor moves right by 1 AC=AC+1 0 Display shift left by 1, cursor also follows to AC=AC shift. 1 1 Display shift right by 1, cursor also follows to AC=AC shift. 与“ (3)点设定”区别: 当设定了点设定的内容时, 写入的 每一个内容都会按照这个设定方式移动。而“ (5)光标 或显示移位控制” 只在写入一条命令时移动一次。 69
4、编程指令集 (8)设定DDRAM地址(指令代码为 80 H-9 FH) RW 0 RS 0 D 7 D 6 D 5 D 4 D 3 D 2 D 1 1 AC 6 AC 5 AC 4 AC 3 AC 2 AC 1 应为 0 D 0 AC 0 功能:设定DDRAM地址到地址计数器(AC) 模块内部显示数据RAM(DDRAM)提供 64× 2个字节的空 间, 最多可控制 4行× 16字(64个字)的中文字型显示 。 液晶显示(32个字)位置地址: 第 1行 第 3行 First line AC range is: 80 H, . . . , 87 H, 88 H, . . . , 8 FH 第 2行 第 4行 Second line AC range is: 90 H, . . . , 97 H, 98 H, . . . , 9 FH Third line AC range is: A 0 H , . . . , AFH 液晶只显示 Fourth line AC range is: B 0 H , . . . , BFH 4行× 8字 note: only 2 lines can be display at a time. (32个字) 72
4、编程指令集 (17)设定卷动地址(指令代码为 40 H~7 FH) RW RS D 7 D 6 0 0 0 1 D 5 D 4 D 3 D 2 D 1 D 0 AC 5 AC 4 AC 3 AC 2 AC 1 AC 0 功能:SR=1:AC 5~AC 0为垂直卷动地址; SR=0:AC 3~AC 0写ICON RAM地址。 (18)设定绘图RAM地址(指令代码为 80 H~FFH) RW RS D 7 0 0 1 D 6 D 5 D 4 D 3 D 2 D 1 AC 6 AC 5 AC 4 AC 3 AC 2 AC 1 AC 0 功能:设定GDRAM地址到地址计数器(AC)。 79 D 0
[例11 -2] LCD模块使用方法: 示例程序如下: #include"stc 15. h" typedef unsigned char BYTE; //用BYTE 代替unsigned char sbit BLED=P 2^2; //背光控制 void spi_init(void); //SPI初始化(2版含在main函数中) void delay(unsigned int us 10); //延时子程序 void sendspi(BYTE spidata, BYTE RS_FLAG); //显示数据发送子程序 void lcd_init_usual(void); //液晶初始化子程序 void set_position(BYTE position); //确定光标位置子程序 void char_disp (BYTE chartodisp); //显示单个字符子程序 void string_disp(BYTE *stringtodisp); //显示字符串子程序 91
[例11 -2] LCD模块使用方法: 示例程序如下: void set_position(BYTE position) //确定光标位置子程序 { sendspi(position, 0); //如set_position(0 x 82) //起始命令(fa)11111, RW(0), RS(0), 0 设置地址寄存器AC } void char_disp(BYTE chartodisp) //显示单个字符子程序 即写数据到显示寄存器(DDRAM) { sendspi(chartodisp, 1); } //起始命令(fa)11111, RW(0), RS(1), 0 void string_disp(BYTE *stringtodisp) //显示汉字字符串子程 { for(stringtodisp; * stringtodisp!=0; stringtodisp ++) sendspi (chartodisp, 1); 即写数据到显示寄存器(DDRAM) } 98 (8)设定DDRAM地址(指令代码为 80 H-9 FH) RW RS D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 0 0 1 AC 6 AC 5 AC 4 AC 3 AC 2 AC 1 AC 0 0
- 0,000 0,000 0,000
- Interuupt
- Xchd instruction in 8051 example
- Llll 0000
- Bcd addition of 184 and 576
- Anamnesi ostetrica para 0000
- Cat rabbit dog weight puzzle answer
- Pne 33 000-1
- 0000 1100
- Cor #0000
- 952 203-0000
- 0101 0101 0000 0001
- University xxx
- 0900 zulu time
- 0000 0001 0010
- 1-000-000-0000
- 0000 0001 0010
- Ochsner irb
- Cambridge mls
- Future will
- What is the central idea of this passage?
- Void main int main
- Aflcmc org chart
- Http://www.greatachievements.org/
- Uk.wikipedia.org
- Doctrine org
- Isaaa
- Mycil.org illinois
- Www.opengl.org
- Www.iso.org
- Www jmps org in
- Keva acai juice
- Http www mbon org 10
- Www.ofm.org
- Oasis-open.org
- Dcode org
- Iucn org
- Www.fcl.org
- Asm microbelibrary.org
- Safer sys org
- Www.iso.org
- Cdrh org chart
- Https://www.footprintcalculator.org
- Animal behaviour notes
- Ppbe navy
- Beta seis
- Careerpilot.org.uk
- Massive open online course
- Ibri.org
- Hyperfish org chart
- Www.uml.org
- Echolink.org
- Http://www.blueplanetbiomes.org/world_biomes.htm
- Http://www.careeronestop.org/
- Okcollegestart.org
- Who was the first state advisor of georgia nha
- Board of certification in professional ergonomics
- Nathan withers
- Www.mathsbox.org.uk skills check answers
- Lesson 11 code.org
- Fors-online.org.uk
- Bnl org chart
- Ganzoni formülü
- Ccclib catalog
- Nchc.org.tw
- Dian anita org
- Hics level 1
- Diya pakistan scholarship
- Studymafia.org
- Classify.oclc.org
- Grouppolicydsc
- Unanimes.org
- Foodafactoflife
- Pearland isd.org
- Ebiblioteca.org novedades
- Casas test practice
- My bcbe org website
- Ussocom org chart
- Commons.wikimedia.org wiki
- Ungm
- Globaliia
- Iso org
- Freecodecamp.org
- Fred langford
- Https://media.hhmi.org/biointeractive/click/cellcycle/