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.

problem in removing usb(HOST) while writing in USB in tm4c129x.

Hi,

I am Facing an issue regarding 

USB host MSC for TIVA- behaviour during random device removal while writing into it.

That will result to struck the controller in infinite loop(USB APIS). unable to return me current USB Mode(Host/device/None). whick looks like that system is hanged however Interrupts in interrupt vector priority table above USBOTGInterruptHandler is working fine.

But i don't know the root cause y it get struck in USB APIs & can't be revive ever?

Please help me (Popups & Display information that DO'NOT REMOVE USB WHILE WRITING & READING kind of solutions are not accepted in our development because user can do anything.)

so, we have to take care of such conditions also.

  • Hello Vidushi,

    Where does the USB Host for MSC hang? You have not mentioned any level of debug done at your level.

    Regards
    Amit
  • Hi Amit,

    Complete system look like hanged. When i debug i came to know that it is in USBHostenum.c, usb.h kind of files.There is no particular point where it get struck always found in different files of Usb host apis and also came to know that all interrupts in startup_ccs.c file above USBOTGinterruptHandler is working but not USBOTG handler.

    Regards

    Vidushi

  • Hello Vidushi,

    Check the Forum. There is a tactical fix for usbhostenum.c for connect-disconnect hang issue.

    Regards
    Amit
  • Hi,

    Can you share me any link for that??
  • Hello Vidushi

    Search it my friend. The tittle should be "babble interrupt"

    Regards
    Amit
  • hi Amit,

    Ya i have checked on forum e2e.ti.com/.../393726 browse few similar issue but didnt get optimal solution can u tell me in short?

    if(g_sUSBHCD.ui32IntEvents & (INT_EVENT_DISCONNECT |
    INT_EVENT_VBUS_ERR |
    INT_EVENT_POWER_FAULT))
    {
    //
    // Set the pipe state to error.
    //
    g_sUSBHCD.psUSBOUTPipes[ui32PipeIdx].iState = ePipeError;

    //
    // Needs to be set to exit out of large while loop.
    //
    ui32RemainingBytes = 0;

    break;
    }

    Tried this Through this i can prevent hanging situation but after this return USBMode is Device always whether i have connect HOST/DEVICE/NONE.

    Can you please help me?

    Regards
    Vidushi
  • Hello Vidushi,

    I think the solution to this issue is to reset the USB Controller to and re-initialization. Also are you using OTG mode or using Force Host Mode?

    Regards
    Amit
  • Hi Amit,

    Thanks for your early response.

    I am using USB OTG mode. Is there any particular APIs of yours that i can use directly? or in a simple way PeripheralEnable ?

    Regards

    Vidushi

  • Hello Vidushi

    It is SysCtlPeripheralReset to reset the USB controller.

    Regards
    Amit
  • Hi Amit,

    Yaa same. Ok i'll try that on Monday.

    Regards
    Vidushi
  • Hi Amit 

    I tried that you suggest me in the last attaching section of code i patched in PipeRead

    if(g_sUSBHCD.ui32IntEvents & (INT_EVENT_DISCONNECT |
    INT_EVENT_VBUS_ERR |
    INT_EVENT_POWER_FAULT))
    {
    //
    // Set the pipe state to error.
    //
    g_sUSBHCD.psUSBINPipes[ui32PipeIdx].iState = ePipeError;

    //
    // Needs to be set to exit out of large while loop.
    // 
    ui32RemainingBytes = 0;                                                              //Patch
    SysCtlPeripheralDisable(SYSCTL_PERIPH_USB0);             //Patch
    SysCtlPeripheralReset(SYSCTL_PERIPH_USB0);                //Patch
    SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);              //Patch

    Init_USB_OTG();                                                                            //Reinitialize Port Pins Feature Set and all

    break;
    }

    Due to this patch i am able to detect right Mode of USB OTG but USB Downloading & uploading not working after inserting USB host again it got struck in USBHMSCDriveReady() function When trying for Enumeration_State.

    Can you suggest anything for this also.

    Regards

    Vidushi

  • Hello Vidushi,

    You should not modify the sequence in the library code, but in a higher priority task in the application layer.

    Regards
    Amit
  • Hi,

    Did/nt get your point Sir. Can you please elaborate more?

    Regards

    Vidushi

  • Hello Vidushi,

    I will exemplify using WDTimer. The WatchDog Timer can be set to a large value like a second. The Application must clear the WDTimer before the interrupt of the WDTimer gets asserted. that way the application can keep a track of the hang condition in software. As long as the application is working fine it will reload the WDTimer causing it never to fire an interrupt. However if it is stuck in a loop then it causes the CPU to go to the WDTimer Interrupt handler where it can disable-reset-enable-init the USB and then begin a new execution task.

    Regards
    Amit
  • Hi Amit,


    Actually When i don't know about babble interrupt at that time i did the same WTDog Timer Disable Rest & Enable with some reloading factor. But it is getting false interrupt even reloading with larger value.

    once I reload it before IntEnable & in second way i Reload it after IntEnable in bot case even after relaoding with 12000000 value it is getting Interrupt even if system is working fine.So thats the problem with watchdog in my case.


    Regards
    Vidushi
  • Hello Vidushi,

    That should not be the case. Which WDT are you using? Check the errata there is a problem with one of them. In the meantime (will take me some time) I will check the recovery mechanism

    Regards
    Amit
  • Hi Amit,

    I am using WDT0(Watchdog Timer 0).

    Regards

    Vidushi

  • Hi Amit,

    We can't use Complete Device Reset because our application is Protection based if Arm(Master) in our case get Reset then complete system has to do all facts figures calculations related to all protections again which is not acceptable in our case.

    If WDT allow Peripharal(USB0) Reset only that will be acceptable.so please tell the relevant solution.

    Regards
    Vidushi
  • Hello Vidushi

    WDT has the option to generate a NMI instead of a Reset. You can use the NMI feature

    Regards
    Amit
  • Hi Amit,

    Ok ill try that also but my main concern is after babble interrupt USB Detects But Unable to do Read write got struck in USBHMSCDriveReady function in USBhmsc.c API??

    Regards

    Vidushi

  • Hello Vidushi,

    That is why the reset of the USB and subsequent reinit will resolve the same.

    Regards
    Amit