• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: 按鍵掃描的問題
#5
新會員
新會員


查看用戶資訊
其实也不一定要中断的呀,可以用定时器呀,主程序运行一遍5MS,有键记数次为有键,置键按下标志,处理按键,回来判键是否弹起已弹起就清标志.

發表於: 2004/11/24 14:33
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 按鍵掃描的問題
#4
版主
版主


查看用戶資訊
打電話到 Microchip 來討論交流,02-2500-6610 分機 : 803

發表於: 2004/8/23 13:31
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 按鍵掃描的問題
#3
新會員
新會員


查看用戶資訊
謝謝你的建議 不過對中斷使用還不是很清楚 我會試看看
謝謝囉

發表於: 2004/8/23 12:24
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 按鍵掃描的問題
#2
版主
版主


查看用戶資訊
給個建議:
1. 鍵盤的掃描最好是用Timer的中斷一起配合來進行掃描,並進行所謂的按鍵彈跳處理。
2. 例如: Timer的中斷時間為2.5mS,每2.5mS掃描一行,進行該行按鍵是否按下,如有就處理按鍵編碼並設定旗號已通知主程式有按鍵需處理,在此你必須啟動彈跳的處理機制。
3. 最重要的還是要處理按鍵的彈跳問題,彈跳時間的長短與按鍵的好壞有很大的關係,一般而言設定在60mS ~ 100mS應該就可以了。以就是說必須連續檢查按鍵24次(60mS/2.5mS)確定按鍵持續放開後才可以進入下一個按鍵掃描的步驟。
4. 以上動作,建議在中斷(Timer)裡完成這樣對主程式就不會有影響了。

發表於: 2004/8/23 12:12
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


按鍵掃描的問題
#1
新會員
新會員


查看用戶資訊
下面這段是我寫的4*4的按鍵掃描程式,可是按鍵ㄅ靈敏,請各位高
手指教一下哪裡出問題了
ScanKey:
bcf STATUS,RP0

movlw 20h ;Scan channel-4(7~F)
movwf PORTA
movlw 08h
movwf KeyPort ;紀錄 Channel
bsf STATUS,C
goto Check_Key
ScanLoop:
clrf PORTA

movf PORTE,w
xorlw 04h
btfsc STATUS,Z ;檢查掃描是否結束,Z=1表示結束
goto ScanOver

rlf PORTE ;Scan channel-1~3
(4~E)
movf PORTE,w
movwf KeyPort ;紀錄 Channel
Check_Key:
call Delay2ms
movf PORTA,w ;檢查有無按鍵
andlw 0fh ;
btfsc STATUS,Z ;
goto ScanLoop ;Z=1表示無按鍵,繼續掃描

call D05S

movf PORTA,w
movwf KeyTmp
Wait_Key:
movf PORTA,w ;檢查按鍵
andlw 0fh ;Z=1,按鍵放開,取按鍵值
btfsc STATUS,Z ;Z=0,按鍵按住,繼續等待
goto GetKey
goto Wait_Key
GetKey:
movlw 04h
movwf KeyIP
btfsc KeyPort,0 ;KeyPort=1,4~D
goto Get_Num1

movlw 08h
movwf KeyIP
btfsc KeyPort,1 ;KeyPort=2,1~C
goto Get_Num1

movlw 0ch
movwf KeyIP
btfsc KeyPort,2 ;KeyPort=3,A~E
goto Get_Num1

movlw 00h
movwf KeyIP
btfsc KeyPort,3 ;KeyPort=4,7~F
goto Get_Num1
goto ScanOver
;===================================
再請一問一下 做按鍵掃描時 是要先
令i/o為high 然後送low訊號去偵測按鍵ㄇ 若是相反過來會
造成哪些影響呢

發表於: 2004/8/23 10:08
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------