?? ezbulk.a51
字號:
;--------------------------------------------------------------
; ezbulk.A51 6-17-98 LTH
;
; A Simple bulk transfer. Updated and corrected version of the
; example code on page 81 of the EZ-USB TRM v1.0. Use this to study bulk transfers
; between the EZ-USB Development Board and the Anchor Control Panel.
;
; 1. Fills the EP2IN buffer with a decrementing count from 64 to 1.
; 2. Maintains counts of number of IN and OUT transfers to EP2.
; 3. Does nothing with the data received over EP2OUT.
; 4. Updates the first two bytes of the EP2IN buffer with the number
; of EP2IN transfers (byte 0) and the number of OUT transfers (byte 1).
;
; To exercise with the Anchor control panel:
; 1. Download the code, either from the Keil environment or by clicking the
; 'Download' button and selecting ezbulk.hex.
; 2. Set Interface 0, alternate setting 1. This establishes the EP2 endpoints
; with MaxPacketSizes of 64.
; 3. Select Endpoint 2 IN in the Bulk Transfer button bar.
; 4. Click the Blk Trans button. You should see the 64 bytes decrementing from
; 64 to 1.
; 5. Click Blk Trans button again to perform another EP2IN transfer. The pattern
; should now be the same except for byte 0, which indicates 1 IN transfer has
; previously happened. Each click of BlkTrans button with EP2IN selected transfers
; another 64 bytes with the first byte incrementing.
; 6. Select Endpoint 2 OUT in the Bulk Transfer button bar.
; 7. Click BlkTrans. This sends 64 bytes to EP2OUT. The data is ignored.
; 8. Select Endpoint 2 IN, click BlkTrans. The second byte should now be 1, indicating
; that one EP2OUT transfer has previously happened.
;
; This code polls the endpoint busy bits. A more advanced example would use the vectored
; interrupts.
;--------------------------------------------------------------
$NOMOD51 ; disable predefined 8051 registers
$nolist
$include (..\..\..\target\inc\ezregs.inc) ; EZ-USB register assignments
$list
;
NAME ezbulk
;
ISEG AT 60H ; stack (this app doesn't use it)
stack: ds 20
;
CSEG AT 0
ljmp start
; -------------------------------------------------
org 200h
; -------------------------------------------------
start: mov SP,#STACK-1 ; set stack
mov dptr,#IN2BUF
mov r7,#64 ; fill EP2IN buffer with 64 bytes
fill: mov a,r7
movx @dptr,a
inc dptr
djnz r7,fill ; load decrementing counter starting w. 64
;
mov r1,#0 ; count the IN transfers
mov r2,#0 ; count the OUT transfers
mov dptr,#IN2BC ; load the IN2 Byte Count register
mov a,#64 ; 64 bytes
movx @dptr,a ; arm the IN transfer
;
loop: mov dptr,#IN2CS ; EP2IN Control & Status register
movx a,@dptr
jnb acc.1,service_IN2 ; check the busy bit, service if LOW
mov dptr,#OUT2CS ; EP2OUT Control & Status reg
movx a,@dptr
jb acc.1,loop ; busy-keep checking
;
service_OUT2: inc r2 ; OUT packet counter
mov dptr,#IN2BUF+1 ; load OUT packet count into second IN2BUF byte
mov a,r2
movx @dptr,a
mov dptr,#OUT2BC ; load anything to byte count to re-arm
mov a,#1 ; any value
movx @dptr,a
sjmp loop
;
service_IN2: inc r1 ; IN packet countr
mov dptr,#IN2BUF
mov a,r1 ; load IN packet count into first IN2BUF byte
movx @dptr,a
mov dptr,#IN2BC ; load the EP2IN byte count to re-arm IN transfer
mov a,#64 ; 64 byte payload
movx @dptr,a
sjmp loop
;
END
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -