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 connected to TM4C1294NCPDT

My requirement is to check, if the USB is connected to my device or not. 

I have implemented the following code from example drivers;

USBMSCHFatFs_Handle usbmschfatfsHandle;
	USBMSCHFatFs_Params usbmschfatfsParams;
	USBMSCHFatFs_Params_init(&usbmschfatfsParams);
	usbmschfatfsHandle = USBMSCHFatFs_open(Board_USBMSCHFatFs0,USB_DRIVE_NUM,&usbmschfatfsParams);
	    if (!usbmschfatfsHandle)
	    {
	        sprintf(txBuffer,"Error starting the USB Drive\n");
	        UART_write(uart,txBuffer,strlen(txBuffer));
	    }
	    else
	    {
	        sprintf(txBuffer,"\t\t\tDrive %u is mounted\n", USB_DRIVE_NUM);
	        UART_write(uart,txBuffer,strlen(txBuffer));
	        USBMSCHFatFs_close(usbmschfatfsHandle);
	    }

But when I remove, the USB drive, also it is showing Drive is mounted. Help needed

  • Hello CHAITANYA,

    Does the original example code have the sample issue? If not, please check the changes you made for your project?

    Regards,
    QJ
  • Hi Chaitanyam,
    Please note that "USBMSCHFatFs_open()" will only open the USB driver but will not check whether an USB thumb drive is connected physically to the system. Use function "USBMSCHFatFs_waitForConnect(usbmschfatfsHandle, waitTimeOut)" for checking whether physically an USB drive is connected or NOT!! Large capacity thumb drives of the order of 32 GB or 16 GB may require more time to get detected, hence put sufficient value in waitTimeOut variable to facilitate a smooth USB drive detection. Usually 10 seconds in waitTimeOut should be fine.
    -
    Regards
    Soumyajit
  • Done that and error has been rectified
    usbmschfatfsParams.servicePriority = 3;//Given a service priority
    ret=USBMSCHFatFs_waitForConnect(usbmschfatfsHandle, 10000);// Induced a delay of ten seconds
    Vola! it worked.
    Thanks Soumyajit Sir.