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

Keil usb communication error

Hi friends.

My English is very limited.

I am sending data to a computer via USB and LPC2368. but the data comes back to me once, come back I want to stop. Would not help but do?

Thank you.

Link: www.4shared.com/.../USBHID.html

Parents Reply Children
  • Follow this thread
    http://www.keil.com/forum/docs/thread16862.asp

    Most of the essence that USB beginner should know is there.

    Ah, in above thread, the target MCU is AT91SAM7S256.
    The code for LPC2368 is almost similar. But minor difference is here.
    KEIL binds IN and OUT ISR into single USB_EndPointNN function (though I don't think this coding good). Then, you have to check "event" parameter in the EP ISR as follows.

     usbuser.c
    
    void USB_EndPoint1 (U32 event) {
      if (event == USB_EVT_IN) {
        //
        // IN endpoint ISR
        //
      } else if (event == USB_EVT_OUT) {
        //
        // OUT endpoint ISR
        //
      }
    }
    

    Tsuneo

  • Thank you.

    I've tried many methods but could not manage. I'm about to go crazy:)

    my sample code

    void USB_EndPoint1 (DWORD event) {

    switch (event) { case USB_EVT_IN: GetInReport(); fg_endpoints &= ~(Bit(1)<<16); //USB_WriteEP(0x81, InReport, sizeof(InReport)); OutReportBufCnt = USB_WriteEP(0x81, InReport, sizeof(OutReport)); break; case USB_EVT_OUT:

    OutReportBufCnt = USB_WriteEP(0x81, InReport, sizeof(OutReport)); // fg_endpoints &= ~(Bit(1)<<16); break; }
    }