This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM7: LPC2148 & USB communication

I want to develop mass storage device using LPC2148.I am just referring code from Keil for USBMem. My problem is -
I get Get_descriptor command from PC to which I respond with device descriptor. On receiving 8th byte it generates Reset.
Then I get Set_address command. On response to it, I execute Set Address command in protocol engine.
Then again I get Get_descriptor command (It should actually have index field of 18 but I receive with 64).
Again after 8th byte it generates Reset and again gives Set_address command instead of Get_descriptor command for Configuration descriptor.
What can be the problem?

Parents
  • > Reset is occurring but I am paying attention to Set_address command only.

    If your device gets bus reset after Set_Address, it suggests that the firmware fails to respond to the STATUS stage of Set_Address request.

    > I just send zero-length packet for acknowledgment to host and then execute Set Address command in protocol engine.

    The order is reversed.
    The USB engine of LPC family is aware of control transfer sequence, as follows

    UM10139 LPC214x User Manual
    ics.nxp.com/.../user.manual.lpc2141.lpc2142.lpc2144.lpc2146.lpc2148.pdf

    9.1 Set Address (Command: 0xD0, Data: write 1 byte)
    The address set in the device will take effect after the status phase of the setup token.
    (Alternately, issuing the Set Address command twice will set the address in the device immediately).

    Then, the order of Set_Address process is,
    1) execute Set Address command in protocol engine
    2) send zero-length packet for acknowledgment to host (STATUS stage)

    If you do it in reversed order, your device misses next request after Set_Address



    > Can it be timing problem?

    USB spec defines timeout for request process in details as follows.
    The shortest timeout (50 ms) applies to Set_Address and Set_Configuration on enumeration.
    If the firmware put debug output in 9600 baud, 48 characters of debug output causes 50 ms timeout.

    9.2.6.3 Set Address Processing (usb_20.pdf p246)
    After the reset/resume recovery interval, if a device receives a SetAddress() request, the device must be able to complete processing of the request and be able to successfully complete the Status stage of the request within 50 ms. In the case of the SetAddress() request, the Status stage successfully completes when the device sends the zero-length Status packet or when the device sees the ACK in response to the Status stage data packet.

    9.2.6.4 Standard Device Requests
    For standard device requests that require no Data stage, a device must be able to complete the request and be able to successfully complete the Status stage of the request within 50 ms of receipt of the request. This limitation applies to requests to the device, interface, or endpoint.

    For standard device requests that require data stage transfer to the host, the device must be able to return the first data packet to the host within 500 ms of receipt of the request. For subsequent data packets, if any, the device must be able to return them within 500 ms of successful completion of the transmission of the previous packet. The device must then be able to successfully complete the status stage within 50 ms after returning the last data packet.

    For standard device requests that require a data stage transfer to the device, the 5-second limit applies. This means that the device must be capable of accepting all data packets from the host and successfully completing the Status stage if the host provides the data at the maximum rate at which the device can accept it. Delays between packets introduced by the host add to the time allowed for the device to complete the request.

    Tsuneo

Reply
  • > Reset is occurring but I am paying attention to Set_address command only.

    If your device gets bus reset after Set_Address, it suggests that the firmware fails to respond to the STATUS stage of Set_Address request.

    > I just send zero-length packet for acknowledgment to host and then execute Set Address command in protocol engine.

    The order is reversed.
    The USB engine of LPC family is aware of control transfer sequence, as follows

    UM10139 LPC214x User Manual
    ics.nxp.com/.../user.manual.lpc2141.lpc2142.lpc2144.lpc2146.lpc2148.pdf

    9.1 Set Address (Command: 0xD0, Data: write 1 byte)
    The address set in the device will take effect after the status phase of the setup token.
    (Alternately, issuing the Set Address command twice will set the address in the device immediately).

    Then, the order of Set_Address process is,
    1) execute Set Address command in protocol engine
    2) send zero-length packet for acknowledgment to host (STATUS stage)

    If you do it in reversed order, your device misses next request after Set_Address



    > Can it be timing problem?

    USB spec defines timeout for request process in details as follows.
    The shortest timeout (50 ms) applies to Set_Address and Set_Configuration on enumeration.
    If the firmware put debug output in 9600 baud, 48 characters of debug output causes 50 ms timeout.

    9.2.6.3 Set Address Processing (usb_20.pdf p246)
    After the reset/resume recovery interval, if a device receives a SetAddress() request, the device must be able to complete processing of the request and be able to successfully complete the Status stage of the request within 50 ms. In the case of the SetAddress() request, the Status stage successfully completes when the device sends the zero-length Status packet or when the device sees the ACK in response to the Status stage data packet.

    9.2.6.4 Standard Device Requests
    For standard device requests that require no Data stage, a device must be able to complete the request and be able to successfully complete the Status stage of the request within 50 ms of receipt of the request. This limitation applies to requests to the device, interface, or endpoint.

    For standard device requests that require data stage transfer to the host, the device must be able to return the first data packet to the host within 500 ms of receipt of the request. For subsequent data packets, if any, the device must be able to return them within 500 ms of successful completion of the transmission of the previous packet. The device must then be able to successfully complete the status stage within 50 ms after returning the last data packet.

    For standard device requests that require a data stage transfer to the device, the 5-second limit applies. This means that the device must be capable of accepting all data packets from the host and successfully completing the Status stage if the host provides the data at the maximum rate at which the device can accept it. Delays between packets introduced by the host add to the time allowed for the device to complete the request.

    Tsuneo

Children