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

論壇索引


Board index » All Posts




請大家幫我看一下,這程式那裡錯了
新會員
新會員


這是一個用pic16f84去模擬鍵盤傳送按鍵值的程式(空白鍵連點)

我本來不想寫的,可是我朋友一直拿鍵盤來叫我幫他改空白鍵連點

(他們在玩奇蹟online遊戲一個報一個,改到我都快手軟了)

逼不得已才想說用這個變通的方法試看看

我是照一個老美的程式下去改的,組譯ok可是run不起來

原始網頁在這
http://panda.cs.ndsu.nodak.edu/%7Each ... icro/code/ps2/Device.html



;---------------------------------------------------------------------;------------------------
; HEADER:
;---------------------------------------------------------------------------------------------
TITLE "KEYBOARD PLUG"
SUBTITLE "By paul tseng"
LIST P=16F84A
INCLUDE "p16f84A.inc"
RADIX DEC
ERRORLEVEL -224, 1
__CONFIG _CP_OFF & _WDT_OFF & _RC_OSC


;---------------------------------------------------------------------------------------------
; DEFINES:
;---------------------------------------------------------------------------------------------
#DEFINE DATA PORTB, 3
#DEFINE CLOCK PORTB, 2
#DEFINE KEY PORTB, 1
#DEFINE LED PORTB, 0

;---------------------------------------------------------------------------------------------
; RAM ALLOCATION:
;---------------------------------------------------------------------------------------------
cblock 0x0c
TEMP0
RECEIVE
PARITY
COUNTER

endc

org 0x000
goto START
;--------------------------------------------------------------------------------
;Required Routines & Macros:
;---------------------------------------------------------------------------------------------
; MACROS:
;---------------------------------------------------------------------------------------------
delay macro Time ;Delay "Cycles" instruction cycles
if (Time==1)
nop
exitm
endif
if (Time==2)
goto $ + 1
exitm
endif
if (Time==3)
nop
goto $ + 1
exitm
endif
if (Time==4)
goto $ + 1
goto $ + 1
exitm
endif
if (Time==5)
goto $ + 1
goto $ + 1
nop
exitm
endif
if (Time==6)
goto $ + 1
goto $ + 1
goto $ + 1
exitm
endif
if (Time==7)
goto $ + 1
goto $ + 1
goto $ + 1
nop
exitm
endif
if (Time%4==0)
movlw (Time-4)/4
call Delay_Routine
exitm
endif
if (Time%4==1)
movlw (Time-5)/4
call Delay_Routine
nop
exitm
endif
if (Time%4==2)
movlw (Time-6)/4
call Delay_Routine
goto $ + 1
exitm
endif
if (Time%4==3)
movlw (Time-7)/4
call Delay_Routine
goto $ + 1
nop
exitm
endif
endm

;---------------------------------------------------------------------------------------------
; DELAY:
;---------------------------------------------------------------------------------------------
;Delays 4w+4 cycles (including call,return, and movlw) (0=256)
Delay_Routine addlw -1 ;Precise delays used in I/O
btfss STATUS, Z
goto Delay_Routine
return
;---------------------------------------------------------------------------------------------
; START:
;---------------------------------------------------------------------------------------------
START bcf STATUS,RP0
clrf PORTB
bsf STATUS,RP0
movlw 0xF2 ;定義I/O
movwf TRISB
bsf LED ;flash LED
delay 300
bcf LED
goto CHECK_KEY


CHECK_KEY btfsc KEY
goto CHECK_KEY
delay 100
goto SINGAL_OUT


SINGAL_OUT delay 1000 ;delay 1 sec
movlw 0x29 ;空白鍵scan code
call BYTEOUT
delay 100 ;delay 100 u sec
movlw 0xF0 ;空白鍵brake code
call BYTEOUT
movlw 0x29 ;空白鍵brake code
call BYTEOUT
goto LIGHT_ON


LIGHT_ON bsf LED
delay 200
bcf LED
goto STOP_SEND


STOP_SEND btfsc KEY
goto SINGAL_OUT
delay 100
goto CHECK_KEY



;--------------------------------------------------------------------------------
;ByteOut:
;Sends a byte in w to the host. Returns 0xFE if inhibited during transmission.
;Returns 0xFF if host interrupts to send its own data.
;Returns 0x00 if byte sent successfully.
;---------------------------------------------------------------------------------------------
; OUTPUT ONE BYTE: - TIMING IS CRITICAL!!!
;---------------------------------------------------------------------------------------------
BYTEOUT movwf TEMP0
InhibitLoop btfss CLOCK ;Test for inhibit
goto InhibitLoop
delay 50
btfss CLOCK
goto InhibitLoop
btfss DATA ;Check for request-to-send
retlw 0xFF
clrf PARITY
movlw 0x08
movwf COUNTER
movlw 0x00
call BitOut ;Start bit (0)
btfss CLOCK ;Test for inhibit
goto ByteOutEnd
delay 4
ByteOutLoop movf TEMP0, w
xorwf PARITY, f
call BitOut ;Data bits
btfss CLOCK ;Test for inhibit
goto ByteOutEnd
rrf TEMP0, f
decfsz COUNTER, f
goto ByteOutLoop
delay 2
comf PARITY, w
call BitOut ;Parity bit
btfss CLOCK ;Test for inhibit
goto ByteOutEnd
delay 5
movlw 0xFF
call BitOut ;Stop bit (1)
delay 48
retlw 0x00

ByteOutEnd bsf STATUS, RP0
bsf DATA
bsf CLOCK
bcf STATUS, RP0
retlw 0xFE

BitOut bsf STATUS, RP0
andlw 0x01
btfss STATUS, Z
bsf DATA
btfsc STATUS, Z
bcf DATA
delay 21
bcf CLOCK
delay 45
bsf CLOCK
bcf STATUS, RP0
delay 5
return

end

發表於: 2005/1/4 17:44
頂部


PICDEM Z 2.4 GHz 台灣有賣嗎
新會員
新會員


Dear Sir :
I want to buy PICDEM Z 2.4 GHz Demonstration Kit, can you give me some information.
Ted Chen

發表於: 2005/1/4 14:18
頂部


Re: dsPIC和一般解碼IC比較如何??
中級會員
中級會員


我想你說的沒錯,內建 QEI 介面的 Solution 是比較便宜。

我找到的這ㄧ顆型號是 HCTL2020,看他的說明功能似乎是ㄧ模ㄧ樣 !!


請問在使用 dsPIC 的 QEI 介面時,應該是獨立執行(不佔用其它控制程序的時間),僅需要在取樣時間到時去讀值吧??

發表於: 2005/1/4 13:30
頂部


Re: 很高兴认识这里的朋友,问个bootloader功能问题!
新會員
新會員


我不是要版主写bootloader程序,想要版主写一个利用bootloader下载到单片机的例子!呵呵,盼望快点研究出来!我在网上看到好多bootloader程序,就是没有找到怎么用的例子!

發表於: 2005/1/4 12:50
頂部


Re: ADC的參考電壓?!
高級會員
高級會員


請問一下...
ADC轉換後的腳位位準...
多少會被判斷為HI....
多少會被判斷為LOW...
多少會無法辨識...
我量測HI的電壓竟高達VDD...(5V)
這樣是正確的嗎?!

發表於: 2005/1/4 11:28
頂部


Re: LCD顯示
資深會員
資深會員


參照:

xfsmart 寫道:
謝謝指點先!請問是不是使用CCS 的 C 就可以不必自己寫程式將float數轉換成為ascii碼啊?


YES, 這是標準的 C 語言的 printf 指令的功能。
玩過 C 語言嗎?
玩過 PC 用的 Turbo-C 嗎?

發表於: 2005/1/4 11:25
頂部


Re: LCD顯示
初級會員
初級會員


謝謝指點先!請問是不是使用CCS 的 C 就可以不必自己寫程式將float數轉換成為ascii碼啊?

發表於: 2005/1/4 11:06
頂部


Re: PIC18F86xx 的Demo Board
新會員
新會員


版主,請問有聯絡的WINDOW 嗎?
我要 ICD2,demo board 及 轉接板,如果有 1,2 顆 Samples 會更好!

發表於: 2005/1/4 10:51
頂部


Re: ADC的參考電壓?!
版主
版主


Data Sheet 找不到,這是 AD 轉換的基本公式。

若輸入為2.1V,VrefH=5V , VrefL= Gnd :

(2.1v-0v/5v-0v) x 1024 - 1 = 429 = 0x1AD

發表於: 2005/1/4 10:40
頂部


Re: PIC18F86xx 的Demo Board
版主
版主


你要找的版子 Part Number : DM183020
名稱為 PIC18F8720 64/80L TQFP DEMO BOARD
電路圖、程式都放在網站上:

http://www.microchip.com/stellent/idc ... Id=1406&dDocName=en010058

可以向代理商買這塊 Demo Board.

或可以向 Microchip Taiwan 索取 80pin/64-pin 轉接用的PCB 及 PIC18F8720 的 PCB,但要自己焊。

發表於: 2005/1/4 10:35
頂部



« 1 ... 7287 7288 7289 (7290) 7291 7292 7293 ... 7522 »



:::

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... ]

教育訓練中心

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