LH7A404 USB Device initialization processing when reset from USB HOST

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LH7A404 USB Device initialization processing when reset from USB HOST

510 Views
okuda
Contributor III

I'm having trouble handling the LH7A404 USB Device when resetting from the USB HOST.

1.About the process when resetting from the USB HOST
 The attached user's guide has the following two descriptions.

Description-1
Upon power up, a USB Host Controller must first send a RESET command to the LH7A404
USB Device to automatically reset the USB Device I/O side and create an interrupt to the
CPU. The LH7A404 then resets the USB registers. Both resets are asynchronous.
Care must be taken when responding to a reset however.
Figure 19-3 shows the connection of the USBDCP (pin U17) signal. An external 1.5 kΩ pullup
resistor is connected to USBDCP. At reset, the input to the internal transistor is 1, keeping
the transistor off.
Software must write a 0 to the PMR:DCP_CTRL bit to turn this transistor on and pull the
USBDP pin HIGH. Upon detecting the USBDP HIGH, the USB Host becomes aware of the
LH7A404 USB Device. The Host sends a reset and in response, the LH7A404 sets an
internal bit to signal that it has been recognized by the host. If at this point the LH7A404 is
programmed to issue a reset, the bit will be cleared and the USB Device controller no
longer recognizes that it is connected to a Host.
To avoid this situation, software must follow these steps in response to receiving a reset
from the Host:
1. Program PMR:DCP_CTRL to 1 to disable the pullup.
2. Issue a reset.
3. Program PMR:DCP_CTRL to 0, connecting the pullup.
The USB Device will now communicate normally with the USB Host.

Description-2
19.1.3.1 Initializing the USB
Upon power up, the USB Host sends a RESET to EP0. Upon receipt of that RESET, the
LH7A404 must:
• Disable the USB
• Reset the APB and I/O sides of the USB
• Set the INDEX register to 0 (EP0)
– Set the required MAXP value
• Set the INDEX register to 1 (EP1)
– Set the required MAXP value
– If using DMA for transmitting data, set USB_DMA_EN and AUTO_SET
• Set the INDEX register to 2 (EP2)
– Set the required MAXP value
– If using DMA for receiving data, set USB_DMA_EN and AUTO_CLR
• Set the INDEX register to 3 (EP3)
– Set the required MAXP value
• Enable the RESET interrupt
• Enable the SUSPEND interrupt (this also enables the RESUME interrupt)
• Set the ENABLE_SUSPEND bit
• Enable the USB.
The USB Device is now ready to communicate with a USB Host.

At what timing in description 2 should PMR: DCP_CTRL in description 1 be controlled?

2.About the reset register
 The attached user's guide has descriptions about the reset register.

7.2.2.7 USB Device Reset Register (USBDRESET)
This register puts the processor in control of resetting the USB Device controller. Because
a USB host controller can send a reset command to the USB peripheral, the LH7A404
must also be able to reset the APB registers in response.
The register is defined in Table 7-22 and Table 7-23.
Table 7-22. USBDRESET Register Description
BIT 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
FIELD ///
RESET 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TYPE RO RO RO RO RO RO RO RO RO RO RO RO RO RO RO RO
BIT 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FIELD ///
APRESETREG
IORESETREG
RESET 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TYPE RO RO RO RO RO RO RO RO RO RO RO RO RO RO RW RW
ADDR 0x8000.044C
Table 7-23. USBDRESET Fields
BITS NAME DESCRIPTION
31:2 /// Reserved Reading returns 0. Write the reset value.
1 APBRESETREG
APB Reset Register
1 = Reset the USB Device control side.
0 = No reset.
0 IORESETREG
I/O Reset Register
1 = Reset the USB Device I/O side.
0 = No Reset.

When actually performing APB Bus reset and I/O reset, how should I control the two registers?
Is it necessary to wait until each bit is set to 1 and set back to 0?
If we need to wait, how much wait do we need?
If you have a sample source code for resetting the USB HOST, please provide it.

 

0 Kudos
0 Replies