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.

RTOS/EVMK2H: ISR registered for USB in device mode getting invoked continuously

Part Number: EVMK2H

Tool/software: TI-RTOS

Hi,

I  am having one K2EVM-HK and using TI RTOS on it. I am working on USB driver in device mode. The board uses dwc3 USB controller.

I have registered one ISR for USB_INT00 (USB Event Ring 0 interrupt). The ISR gets triggered when I connect the board to a host and get proper events. Once all the events are processed, the ISR is getting invoked continuously even though there are no events.

I read IRQ_STATUS_MAIN register and get the value as 0 indicating no event pending. I also checked GEVNTCOUNT register where again I see the value as 0 meaning there are no events.

Following is the code flow of my ISR

/* disable interrupt */

HW_WR_REG32(IRQ_ENABLE_CLR_MAIN(0), 0x1U);

/* read the value of main interrupt status */
uint32_t regVal = HW_RD_REG32(IRQ_STATUS_MAIN(0x0U));

/* Call device interrupt handler */
USBDwcDcdIntrHandler();

/* Clear the interrupt which occured */
HW_WR_REG32(IRQ_STATUS_MAIN(0x0U), regVal);

/* enable IRQ again */
HW_WR_REG32(IRQ_ENABLE_SET_MAIN(0), 0x1U);

/* end of IRQ */
HW_WR_REG32(IRQ_EOI_MAIN, 0x1U);

I have verified this behavior on K2G board as well where the USB driver comes as a part of PDK.

  • Hi,

    Which version of the RTOS SDK is this?

    Best Regards,
    Yordan
  • Hi Yordan,

    My RTOS version is 6.46.05.55, PDK version for K2G is 1.0.7 and PDK version for K2H is 4.0.7

    Regards,
    Krishna
  • Hi,

    Can you clarify your USB RTOS driver, we only have it on K2G device, how do you get it and test on K2H?

    Regards, Eric
  • Hi Eric,

    I am trying to port it for K2H. But I have observed the same issue on K2G.

    Regards,

    Krishna

  • Hi,

    If the issue is seen on K2G, can you provide the details? E.g., what K2G test example and steps how to reproduce?

    Regards, Eric
  • Hi Eric,

    I am running USB Mass Storage in device mode example (USB_DevMsc_evmK2G_armExampleProject) on K2G board.

    Following are the steps to reproduce the issue:

    • Launch the program using CCS.
    • Connect the device to a host and let the enumeration complete.
    • Pause the program and put a break point on the interrupt handler.
    • It is observed that event count is zero and ISR returns without doing anything.
    • This process keeps on repeating.

    Regards,

    Krishna

  • Hi Eric,

    You may even disconnect the board from the host after a while and still the ISR will be invoked continuously with no events to process.

    Regards,
    Krishna
  • Hi,

    Sorry for the late! Do you mean usbCoreIntrHandler ---->usbDwcDcdCoreIntrHandler is called continously, which event count is zero? For the K2G, do you have MSC device enumerated by the host PC or it is a unknown USB device?

    Regards, Eric
  • Hi Eric,

    Yes, exactly. usbCoreIntrHandler ---->usbDwcDcdCoreIntrHandler is called continuously  even if the event count is zero. I am using host as my Windows 10 Desktop.

    Regards,

    Krishna

  • Hi,

    Thanks for confirming this! I opened a ticket for this and will let you know when fixed.

    Regards, Eric
  • Hi Krishna,

    Thanks for writing us this problem.

    We have reproduced the problem and found a fix for this issue. Could you try replace the content of the function usbDwcDcdCoreIntrHandler() to the following:

    /* main entry point for DWC core interrupt handler with USB Wrapper setup */
    void usbDwcDcdCoreIntrHandler(uint32_t intrId, uint32_t cpuId, void* pUserParam)
    {
        usbDwcDcdDevice_t* dwc3;

        dwc3 = (usbDwcDcdDevice_t*)pUserParam;

        /* disable interrupt */
        HW_WR_REG32(dwc3->wrapperAddr + CSL_USB3SS_IRQ_ENABLE_CLR_MAIN(0), 0x1U);

        /* read the value of main interrupt status
         * IRQ_STATUS_MAIN is cleared if ENABLE_CLR_MAIN is set
         */
        uint32_t regVal = HW_RD_REG32(dwc3->wrapperAddr + CSL_USB3SS_IRQ_STATUS_RAW_MAIN(0x0U));

        /*
         * Clear the interrupt which occured
         *    This has to be done before the DWC core interrupt handler
         *
         * Kepler/Lamarr/Edision/Galileo DWC interrupt is a level interrupt in device mode
         * but pulse interrupt in host mode.
         *
         * For K2 devices in device mode we must write to IRQ_STATUS_MAIN before
         * clearing the DWC interrupts (gEventCount)
         *
         */
        HW_WR_REG32(dwc3->wrapperAddr + CSL_USB3SS_IRQ_STATUS_MAIN(0x0U), regVal);

        /* Call DWC device mode interrupt handler */
        USBDwcDcdIntrHandler((usbDwcDcdDevice_t *)pUserParam);

        /* enable IRQ again */
        HW_WR_REG32(dwc3->wrapperAddr + CSL_USB3SS_IRQ_ENABLE_SET_MAIN(0), 0x1U);

        /* end of IRQ */
        HW_WR_REG32(dwc3->wrapperAddr + CSL_USB3SS_IRQ_EOI_MAIN, 0x1U);
    }

     

    Basically the fix is to read the IRQ_STATUS_RAW and write the value to IRQ_STATUS BEFORE calling the DWC interrupt handler.

     

    Please let us know if this fixes your problem

     

    Best regards

    Thanh