Re: 按鍵掃描的問題
|
||||
---|---|---|---|---|
新會員
|
其实也不一定要中断的呀,可以用定时器呀,主程序运行一遍5MS,有键记数次为有键,置键按下标志,处理按键,回来判键是否弹起已弹起就清标志.
發表於: 2004/11/24 14:33
|
|||
|
Re: 按鍵掃描的問題
|
||||
---|---|---|---|---|
版主
|
打電話到 Microchip 來討論交流,02-2500-6610 分機 : 803
發表於: 2004/8/23 13:31
|
|||
|
Re: 按鍵掃描的問題
|
||||
---|---|---|---|---|
新會員
|
謝謝你的建議 不過對中斷使用還不是很清楚 我會試看看
謝謝囉
發表於: 2004/8/23 12:24
|
|||
|
按鍵掃描的問題
|
||||
---|---|---|---|---|
新會員
|
下面這段是我寫的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
|
|||
|