I am trying to run USB on controller pic24fj256da210 but it's getting hang

Status
Not open for further replies.

kushal nandanwar

Full Member level 3
Joined
Jun 9, 2013
Messages
177
Helped
6
Reputation
12
Reaction score
6
Trophy points
18
Activity points
1,258
I am trying to run USB on controller pic24fj256da210 but it's getting hang at a part of USB code.

Code:
 if(USBHostMSDSCSIMediaDetect())

Full code

Code:
 while(1)
    {
        //USB stack process function
        USBTasks();

        //if thumbdrive is plugged in
        if(USBHostMSDSCSIMediaDetect())
        {LATDbits.LATD10 = 1;
            deviceAttached = TRUE;
    
            //now a device is attached
            //See if the device is attached and in the right format
            if(FSInit())
            {
                //Opening a file in mode "w" will create the file if it doesn't
                //  exist.  If the file does exist it will delete the old file
                //  and create a new one that is blank.
                myFile = FSfopen("test.txt","w");

                //Write some data to the new file.
                FSfwrite("This is a test.",1,15,myFile);
              

                //Always make sure to close the file so that the data gets
                //  written to the drive.
                FSfclose(myFile);

                //Just sit here until the device is removed.
                while(deviceAttached == TRUE)
                {
                    USBTasks();
                }
            }
        }
    }
    return 0;
}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…