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 28069U disconnect USB stick while file access



Hello,

I'm doing first steps with USB using the controlCard with the 28069U (iso). The example usb_host_msc provided works perfect to read some files on my USB stick.

The only thing I did see is that the program hangs in the loop shown below if I disconnect the USB stick while I do access a file.

while(g_sUSBHCD.USBOUTPipes[ulPipeIdx].eState == PIPE_WRITING)

tested like this:

  1. in terminal enter the command: cat file.ext (file.ext is a really big file which is now displayed on the terminal)
  2. disconnect USB stick while the file access is running
  3. --> The porogram hangs.

Now my question: How do I best handle this use case? How do you handle this?

Thank you for sharing your ideas!

Best Regards,

Roger

  • Hi,

    --> The program hangs.

    So in short you mean to say that with small files USB stick is responding well but with big files its not?

    Regards,

    Gautam

  • Thank you Gautam for your answer and sorry for not being clearer!

    The file access works perfect, with small and with large files, this is not the problem.

    But if I do manually remove the USB stick while a file is accessed the program hangs.

    Or in other words:

    1. I do start a file access
    2. I do not wait for the end of this file access and I do manually remove the USB stick
    3. The program hangs

    My question is: How to best detect and react on this. (I would prefer to display an error instead of hanging...)

    Roger

  • Thanks for the clarification; you can use the MSCCallback function for detecting and acting for that.

     

    //*****************************************************************************
    //
    // This is the callback from the MSC driver.
    //
    // \param ulInstance is the driver instance which is needed when communicating
    // with the driver.
    // \param ulEvent is one of the events defined by the driver.
    // \param pvData is a pointer to data passed into the initial call to register
    // the callback.
    //
    // This function handles callback events from the MSC driver. The only events
    // currently handled are the MSC_EVENT_OPEN and MSC_EVENT_CLOSE. This allows
    // the main routine to know when an MSC device has been detected and
    // enumerated and when an MSC device has been removed from the system.
    //
    // \return Returns \e true on success or \e false on failure.
    //
    //*****************************************************************************

    Regards,

    Gautam

  • Thank you, yes this should be the place I think too.

    But this is (at least in the example) called by a function. So the state is evaluated by polling. And if the function for reading the file never returns, the new state will never be reached...

    Other words:

    1. I place a breakpoint in MSCCallback()
    2. let the application run
    3. start the file access
    4. disconnect the USB stick

    --> the breakpoint will not be hit, because the the program is stucked in

    while(g_sUSBHCD.USBOUTPipes[ulPipeIdx].eState == PIPE_WRITING)
    {}

    So far this is what I see, the question is, how other developers do handle this? Some kind of watchdog? Some interrupts to detect connection loss? I'm looking for a hint to a "best practice" or just any idea.

    Thank you very much for your time and have a nice weekend!

    Roger

  • Hi,

    Configuring Watchdog timer can be a good solution. Did you try implementing it?

    Regards,

    Gautam 

  • Hi Roger,

         I was also trying to interface usb with 28069 devlopment kit. But i was unable to do that with the given sample code. When i have test the sample code at that time i am getting  "unknown device connetted " erro.. Can you please help me on this??Or can you provide me your running code??? please see the following for my error..3250.0880.usb_terminal (2).ppt

  • Hi Trupti,

    I did not have any problems using the sample code provided by TI. I did not change any line of code to let it run. Just load in CCS, compile and debug. The memory stick was identified as MSC.

    I tried different sticks. One stick was not identified at all (not even a unknown device error, nothing). But this stick was formatted with NTFS, so I thought that that was the reason. I will do some tests with more memory sticks.

    My test setup varys a bit because I do have to make some tests about a galvanic isolation of the USB. So I do not have the USB stick directly connected to the USB micro connector on the TI eval board, but I did connect the D+ and D- signals to another evaluation board of a analog device USB isolator (ADuM4160). So I did only connect these 2 pins of the USB.

    The controlCard I'm using is TMDXCNCD28069ISO with a F28069U

    Be sure to not use this: TMDXCNCD28069 (this one has no USB, no 'U' in serial number).

    The debugger is connected to the USB next to the FTDI chip on the control card

    Through this USB connection also a virtual com port is provided by the FTDI, that's where I let Hterm (terminal program) run.

    As you see this was really straightforward for me

    1. One USB connection to PC for debugger and terminal
    2. power supply of board, power supply of my eval board of ADuM4160
    3. 2 wires for D+ and D-.
    4. Run the Sample code provided (usb_host_msc)
    5. connect a USB stick and browse filesystem in terminal

    Perhaps you'll find a hint in this, good luck!

    Roger

  • Hi Roger,

         thanks....

         here i am discussing in detail whatever i have done...

      1.    I have downloaded usb_host_msc sample code only. After downloading directly even i was unable to get communication on hyperterminal. At that time i have to  do changes in systemctrlinit function as follow,

    SysCtrlRegs.PLLCR.bit.DIV = 4;

    SysCtrlRegs.PLL2MULT.bit.PLL2MULT = 6;

    After that serial was ok...

    2. After that i have formatted by pendrive with fat command. But one sample text file in that for reading purpose..

    3. Give separate external  3.3v suppy usb with making ground of external supply connetced to devolpment board. After doing this i was able to see the data which i have already send you..i.e. unknown device connected. And i am stuck over here.

    But what you have told me above,..

    1.......The controlCard I'm using is TMDXCNCD28069ISO with a F28069U

    Be sure to not use this: TMDXCNCD28069 (this one has no USB, no 'U' in serial number).

    I am using TMX320F28069PZA STICK( F28069 CONTROLCAD RELEASE 1.1)....As you said it should be U..Will it support???

    Shall i have to go for other stick???which one??

    2....My test setup varys a bit because I do have to make some tests about a galvanic isolation of the USB. So I do not have the USB stick directly connected to the USB micro connector on the TI eval board, but I did connect the D+ and D- signals to another evaluation board of a analog device USB isolator (ADuM4160). So I did only connect these 2 pins of the USB.

    Can you share your circuit connection for this??? hown you done it???

    Regards,

    trupti


  • Hi Trupi,

    It is important that your controller does have the 'U' in the serial. Check the printed serial number on the controller itself. On mine is 320F28069UPZPA.

    The 'U' in this serial indicates that this chip has USB.

    If your chip does not have any 'U' in the serial, your chip has no USB!

    That is why I bought the TMDXCNCD28069ISO controlCard. This was the only I found in the TI store with clear information that the controller on it is a 28069U... Other products I saw do not have precise information.

    I think you will have to search in the TI store or ask TI staff for this (if you really need another board).

    Connection:

    • GPIO26 wire to UD- of my eval board of ADUM4160
    • GPIO27 wire to UD+ of my eval board of ADUM4160
    • The ADUM4160 eval board gets the 3.3V and GND from the supply connectors on the TI docking station where the control card is plugged.
    • The ADUM4160 eval board has on the secondary side (as I said it is a USB isolator) another 5V power supply and a USB connector where I can connect the memory stick directly. For the secondary 5V I have another 5V power supply not related to TI board.

    Regards,

    Roger

  • Hi Roger,

        Thanks for the reply.

     Without using the  ADUM4160 and by interchanging the IC in the control card can I interface usb with devlopment board??

     

  • This is for Gautam... Or someone else...

    Sorry Trupi I do not know.

    Roger