I am trying to implement USB host in LPC1768 and have written a code which initiliazes a mass storage device and creates a file in the same.Unfortunately,the code doesn't works and am not able to decode the issues with it.
#include <stdio.h> #include "lpc17xx.h" #include "rl_fs.h" #include "cmsis_os.h" #include "rl_usb.h" #include "USBH_MSC.h" int main (void) { usbStatus usb_status; int32_t msc_status; FILE *f; uint8_t con = 0U; usb_status = USBH_Initialize (0U); // Initialize USB Host 0 if (usb_status != usbOK) { for (;;) { LPC_GPIO2->FIOPIN=0XFFFFFFFF; } } for (;;) { msc_status = USBH_MSC_DriveGetMediaStatus ("U0:"); LPC_GPIO2->FIOPIN=0XFFFFFFFF; if (msc_status == USBH_MSC_OK) { if (con == 0U) { con = 1U; msc_status = USBH_MSC_DriveMount ("U0:"); if (msc_status != USBH_MSC_OK) { continue; } f = fopen ("Test.txt", "w"); if (f == NULL) { continue; } fprintf (f, "USB Host Mass Storage!\n"); fclose (f); msc_status = USBH_MSC_DriveUnmount ("U0:"); if (msc_status != USBH_MSC_OK) { continue; } } } else { if (con == 1U) { con = 0U; } osDelay(100U); } }
Did you figure how to run this example?
Try the USB Host MSC example from Pack Installer
Thanks much for the reply and apologies for the bad description :) It is not able to initialize the Usb stick connected with controller.I have written the code to make Port2 pins HIGH after initialiazing the device. I have checked the configuration of USB host middleware properly but still the pins are not getting HIGH. What else you need to know?
"Unfortunately,the code doesn't works [...]"
Unfortunately, your error description is like a car owner that hands over the keys to their car with the only comment "it doesn't work". How easy do you think it would be for a repair shop if they don't get any description of what "it doesn't work" actually means? Engine doesn't start? Or vibrations over 100km/h? Or the seat heater stays cold?
It is _your_ task to collect evidence what is happening/not happening. You have the code. You have the hardware. How come your post does not contain the information?
View all questions in Keil forum