This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

USB ISR for VC5505

Other Parts Discussed in Thread: TMS320VC5505

Hello TI Gurus:

I am working on USB communication with a TMS320VC5505 EVM. I have been using some of the CSL examples as well as the 5509A Spectrum Digital code (http://c5000.spectrumdigital.com/evm5509a/files/usbexample/example_usb.html) for my implementation. Thus far I have implemented the basic handler routines (contained in the 5509A code as well as the Audio Class for the 5505).

The end goal is to have an ISO IN and ISO OUT endpoint to transfer some A/D data back and forth from the computer with a high frequency - due to the speed I think that polling for the interrupts is out. Additionally, I would think that it is more robust to have very little code in the ISR (unlike the 5505 USB intc example). Therefore, the audio class code (Full Speed ISO) seems most appealing.

However, the ISR portion of the Full Speed example for the 5505 greatly confuse me. In the 5509A examples, the USB_isr() only contains USB_evDispatch(). I know that this function does not exist in the Low Power CSL, but is there something equivalent? Do I really need to implement the majority of the code in the example to get the usb events to my endpoint event handlers?

Are there some examples out there with ISO endpoints that are a little simpler than the this example (and don't contain all of the Audio Class specialty code)? Weeks of google searches says no...but perhaps I missed something.

Many thanks for all of your time - it is greatly appeciated.

  • Hi David,

    First of all, C5505 Low Power CSL and C55059A CSL are two different code bases. There is no USB_evDispatch() in C5505 Low Power CSL. SInce you want to use the interrupt mode, you will have to write your own USB ISR. As you mentioned in your post, we want to keep the ISR short and quick. What we did in the USB example 5 is to keep the USB ISR very simple. It just post a message (CSL_USB_MSG_USB_INT) to the MainTask. All the USB ISR related processing is done in  HandleUSBInterrupt() which uses the functions implemented and defined in csl_usb.c and csl_usb.h (USB core driver) and csl_usb_ac.c and csl_usb_ac.h (USB Audio Class driver). USB example 5 is the only example shows how the USB ISO mode is working. If you interested in the USB Bulk mode, you may want to take a lokk at USB example 4 (USB MSC example).

    Best regards,

    Ming

  • Hi Ming -

    Thanks for your helpful response.

    I had previously implemented the majority of the ISR "subsystem" from Example 5 (Full Speed ISO). As you suggested, the ISR posted a message to the main task which subsequently handles the interrupts for the various endpoints. However, I consistently run into a couple of issues

    1. My event handlers gets called and post transactions (the most common is a post of the device descriptor). However the message is never sent. I am not sure why since immediately after posting the message and requesting an ack back, the "handle interrupts" portion of the code should set the appropriate registers to transmit the messages. Yet, I always a receive a timeout error on the host computer.
    2. Often times the whole device stalls (I'm not sure if that is the correct word) during the check in the EP0 interrupt handler function, eg

        /* Check if STALLed or SetupEnd -- error condition */
        if (
            ( (usbRegisters -> PERI_CSR0_INDX & CSL_USB_PERI_CSR0_INDX_SENTSTALL_MASK) ==
                CSL_USB_PERI_CSR0_INDX_SENTSTALL_MASK ) ||
            ( (usbRegisters -> PERI_CSR0_INDX & CSL_USB_PERI_CSR0_INDX_SETUPEND_MASK) ==
                CSL_USB_PERI_CSR0_INDX_SETUPEND_MASK)
            )
        {
            pContext -> ep0State = CSL_USB_EP0_IDLE;
            return; /* ERROR */
        }

    I will reimplement the the ISR subsystem from scratch again and see what comes of it.

    Many thanks for all of your assistance,

    David

  • Hi David,

    Since all the USB ISR work is down at MainTask, the following segment (in MainTask) is very important to clear the interrupts:

        case CSL_USB_MSG_USB_INT:
                    if(pContext->fMUSBIsReady)
         {
          pContext->dwIntSourceL = usbRegisters->INTMASKEDR1;
          pContext->dwIntSourceH = usbRegisters->INTMASKEDR2;

          usbRegisters->INTCLRR1 = pContext->dwIntSourceL;
          usbRegisters->INTCLRR2 = pContext->dwIntSourceH;

          /* Handle the interrupts */
            if(!HandleUSBInterrupt(pContext))
           fExitMainTaskOnUSBError = TRUE;
         }
         break;

    SInce the USB interrupts are aggregated together, without proper interrupt clear, the next interrupt will not happen.

    Best regards,

     

    Ming

  • Hi Ming,

    Thanks to your help, we appear to have resolved some of our ISR issues. The problem that we are having currently seems to be related to some other posts (http://e2e.ti.com/support/dsp/tms320c5000_power-efficient_dsps/f/109/t/41212.aspx and http://e2e.ti.com/support/dsp/tms320c5000_power-efficient_dsps/f/109/t/42102.aspx), which seem to be unresolved.

    Our current problem with the USB code appears to be the handling of the USB events. As I understand it, the code should flow as follows:
    1) Interrupt occurs (post to the main task's mailbox)
    2) The main task "realizes" there is an interrupt by checking the mailbox.
    3) We determine that the interrupt occurred for endpoint 0 (control)
    4) We get the USB setup packet and parse the request
    5) We "post" an event to wUSBEvents (eg, peps->wUSBEvents |= CSL_USB_EVENT_SETUP;)
    6) The event handler for EP0 is called (entering the event hander) - I assume this is done automatically, I don't have to explicitly call the event handler
    7) A "response" message is posted via post_Transaction
    8) We leave the event handler and return to the interrupt service code from (5).
    9) We tell the USB to actually send the posted data.

    Right now, all of the code that services the interrupt appears to work, but we never enter the event handler (from step 6). Therefore, we immediately go from step 5 to step 9, resulting in USB send of a packet with zero data.

    The logical place to look for this issue is in our initialization code, where we initialize our endpoint objects. Right now we are performing:

    eventMask = (CSL_USB_EVENT_RESET | CSL_USB_EVENT_SETUP | CSL_USB_EVENT_SUSPEND |
                        CSL_USB_EVENT_RESUME | CSL_USB_EVENT_RESET | CSL_USB_EVENT_EOT);
        status = USB_initEndptObj(CSL_USB0, hEpObjArray[0], CSL_USB_OUT_EP0, CSL_USB_CTRL, CSL_USB_EP0_PACKET_SIZE, eventMask, usb_handle_ctrl_wrapper);

    However, usb_handle_ctrl_wrapper never gets called.

    I would be happy to post our full source code if that would make it easier to address these issues.

     

    As always, thanks for your help - it is greatly appreciated.

    David

  • David,

    Please go ahead and post the full source code.

    Thanks.

  • Hi David,

    The step #6 is not called automatically. It is done in the MSCTask in USB example 5. It is called in the MSCTask(). (*peps->hEventHandler)(). The content of the hEventHandler is set in the USB_initEndptObj().

    Step #5 only setup the event flag wUSBEvents which is used by the MSC_Ctrl() (the EP0 eventHandler in example 5).

    Here are the steps:

    USBIsr --> USB_MUSB_Isr --> MBX_post(&MBX_musb ...) [CSL_USB_MSG_USB_INT] --> MainTask [MBX_pend(&MBX_musb ...)] --> HandleUSBInterrupt --> MUSB_Handle_EP0_Inter --> DeviceNotification [CSL_USB_EVENT_SETUP] --> MBX_post(&MBX_msc, ...) [CSL_USB_MSG_ISO_IN] --> MSCTask [MBX_post(&MBX_msc, ..)] --> (*peps->hEventHandler)().

    If you still having problem, please post your source code to the forum or send it to me (mwei@ti.com). I can debug it for you.

    Best regards,

    Ming

  • Hi Ming & Dave:

    Thank you for the helpful response - I did not realize the MSC was that significant. I will implement this functionality later today and report back if I have any issues.

    David