English
Language : 

EZ-USB Datasheet, PDF (117/334 Pages) Cypress Semiconductor – The EZ-USB USB Integrated Circuit
OUT2BC is used as a loop counter in R7 to transfer the exact number of bytes that were
received over endpoint 2-OUT.
When the transfer is complete, the program loads the endpoint 2-IN byte count register
IN2BC with the number of loaded bytes (from R6) to arm the next endpoint 2-IN transfer
in lines 29-31. Finally, the 8051 loads any value into the endpoint 2 OUT byte count reg-
ister OUT2BC to arm the next OUT transfer in lines 35-36. Then the program loops back
to check for more endpoint 2-OUT data.
5. Initialize the endpoints and enable the interrupts.
start: mov SP,#STACK-1
; set stack
;
; Enable USB interrupts and Autovector
;
mov dptr,#USBBAV
; enable Autovector
movx a,@dptr,a
setb acc.0
; AVEN bit is bit 0
movx @dptr,a
;
mov dptr,#OUT07IEN ; ‘EP0-7 OUT int enables’ register
;
mov a,#01000000b
; set bit 6 for EP2OUT interrupt enable
movx @dptr,a
; enable EP2OUT interrupt
;
; Enable INT2 and 8051 global interrupts
;
setb ex2
; enable int2 (USB interrupt)
setb EA
; enable 8051 interrupts
clr got_EP2_data
; clear my flag
Figure 6-11. Initialization Routine
The initialization routine sets the stack pointer, and enables the EZ-USB Autovector by
setting USBBAV.0 to 1. Then it enables the endpoint 2-OUT interrupt, all USB interrupts
(INT2), and the 8051 global interrupt (EA) and finally clears the flag indicating that end-
point 2-OUT requires service.
Once this structure is put into place, it is quite easy to service any or all of the bulk end-
points. To add service for endpoint 2-IN, for example, simply write an endpoint 2-IN
interrupt service routine with starting address EP2IN_ISR (to match the address in the
jump table in step 1), and add its valid and interrupt enable bits to the “init” routine.
Page 6-20
Chapter 6. EZ-USB CPU
EZ-USB TRM v1.9