20151117稳定按键输入显示与功能键_基础_EQUBIT.doc.doc

20151117稳定按键输入显示与功能键_基础_EQUBIT.doc.doc

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
20151117稳定按键输入显示与功能键_基础_EQUBIT.doc.doc

穩定按鍵輸入顯示與功能鍵_基礎_EQUBIT,YZU-EE, Yung-Sheng Chen,P2Addr EQU 0A0h P3Addr EQU 0B0h P4Addr EQU 0E8h accBit4 BIT 0E4h ledBuf EQU 40h ; LED0 ledBuf1 EQU 41h ; LED1 ledBuf2 EQU 42h ; LED2 ledBuf3 EQU 43h ; LED3 ;------------------------------------------- org 0000h ;程式開始 ;------------------------------------------- mov a, #0FFh mov P2Addr, a ; 將 P2 視為輸入埠 mov a, #0FFh mov P3Addr, a ; 將 P3 視為輸入埠 mov ledBuf, #1 ; (Buffer) = 1 mov ledBuf1, #2 ; (Buffer + 1) = 2 mov ledBuf2, #3 ; (Buffer + 2) = 3 mov ledBuf3, #4 ; (Buffer + 3) = 4 mov 44h, #0ffh ; key code buffer (0-7) from P2 mov 45h, #0ffh ; key code buffer (8, 9, A-F) from P3 mov 46h, #0ffh ; final key code buffer (0-15) mov 47h, #0ffh ; temp final key code buffer for checking mov 48h, #0 ; debouncing counter mov dptr, #led_table ; 字型表 起始指標(pointer) mov r0, #40h ; Data RAM 指標(pointer) mov a, #0FEh ; 用來 Enable 個別之 7-segment LED loop: mov P4Addr, A ; P4 = A acall covled ;呼叫 7-led 轉換 acall inputkeycode ;讀取 key code, (44h)←P2, (45h)←P3 Acall delaykeydebounce ; delay key debounce inc r0 RL A jb accBit4, loop ; 檢查 P4.4 = 1 ? 若否,恢復原先設定 mov r0, #40h mov a, #0FEh sjmp loop ;------------------------------------------- ;Subroutine ; 讀取 key code, (44h)←p2, (45h)←p3, (46h) ←r2 the final key code ;------------------------------------------- inputkeycode: push 0e0h ; push a mov a, p2 ; input from p2 mov 44h, a ; save to 44h for code (0-7) mov a, p3 ; input from p3 mov 45h, a ; save to 45h for code (8, 9, a-f) ;============================= mov a, 45h cjne a, #0ffh, nextcode0 mov a, 44h mov r2, #0 nextcode1: jnb 0e0h, gotkeycode inc r2 rr a cjne r2, #8, nextcode1 sjmp exitinputkeycode nextcode0: mov a, 45h mov r2, #8 nextcode2: jnb 0e0h, gotkeycode inc r2 rr a cjne r2, #16, nextcode2 sjmp exitinputkeycode gotkeycode: mov 46h, r2 ; save the

文档评论(0)

170****0532 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8015033021000003

1亿VIP精品文档

相关文档