SN8P2200 Series
USB 1.1 Low-Speed 8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 98
Version 1.7
9.3
USB INTERRUPT
The USB function will accept the USB host command and generate the relative interrupts, and the program counter will
go to 0x08 vector. Firmware is required to check the USB status bit to realize what request comes from the USB host.
The USB function interrupt is generated when:
‧
The endpoint 0 is set to accept a SETUP token.
‧
The device receives an ACK handshake after a successful read transaction (IN) from the host.
‧
If the endpoint is in ACK OUT modes, an interrupt is generated when data is received.
‧
The USB host send USB suspend request to the device.
‧
USB bus reset event occurs.
‧
The USB endpoints interrupt after a USB transaction complete is on the bus.
‧
The USB resume when the USB bus is placed in the suspend state.
The following examples show how to avoid the error of reading or writing the endpoint FIFOs and to do the right USB
request routine according to the flag.
Example: Save the UDP0, UDP1, ACC and Status flag when interrupt request occurs. To avoid the error when
read or write data in the endpoints FIFOs.
ORG 0x8
PUSH ;
Save
ACC
and
status
flag
mov a, UDP0
; Save the UDP0 register value to UDP0_TEMP
mov
UDP0_TEMP,
a
mov a, UDP1
; Save the UDP1 register value to UDP1_TEMP
mov
UDP1_TEMP,
…
…
mov
a,
UDP0_TEMP
mov UDP0, a
; Load the UDP0_TEMP register value to UDP0
mov
a,
UDP1_TEMP
mov UDP1, a
; Load the UDP1_TEMP register value to UDP1
POP
;
Load
the
ACC
and
status
flag
RETI
Example: Defining USB Interrupt Request. The interrupt service routine is following ORG 8.
ORG 0x8
b0bts0
UStatus.6
;
check
Device
suspend
jmp USB_Suspend
; USB suspend occurs, jump to USB_Suspend routine
b0bts0
UStatus.5
;
check
Bus
Reset
jmp Bus_Reset
; Jump to Bus_Reset routine
b0bts1
UE0R.5
;
check
EP0_In_Token
jmp EP0_In
; Jump to EP0 In Token routine.
b0bts0
UE0R.6
; check EP0_Out_Token or Setup token
jmp EP0_Setup
; Jump to Setup routine.
b0bclr
UE0R.5 ; Clear out token flag
RETI