lpcware

Problem with USBMSC_rom Example

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Sakphul on Mon May 30 13:47:53 MST 2011
Hello
I am trying to use the USB On-Chip Driver for MSC. I am using the example code from the example bundle:
http://ics.nxp.com/support/documents/microcontrollers/?scope=LPC1343

After I build the code and plug in the USB cable the PC (Windows 7 x86) recognises a new Mass storage Device. The new Mass Storage Device is now listed in the Windows Explorer and the device manager. But i cannot open the Mass Storage Device. Windows Explorer tells me that is has a Size of 0 Bytes. It looks like the FAT area in the disimage.c example is broken. In My Project it looks like:

const unsigned char DiskImage[MSC_ImageSize] = {
0xEB,0x3C,0x90,0x4D,0x53,0x44,0x4F,0x53,0x35,0x2E,0x30,0x00,0x02,0x01,0x01,0x00,
...
};
Within Main this Data is moved from Flash to RAM:

for (n = 0; n < (1024*3); n++) {     /* Copy Initial Disk Image */
      Memory[n] = DiskImage[n];               /*   from Flash to RAM     */
    }

  MscDevInfo.idVendor = USB_VENDOR_ID;
  MscDevInfo.idProduct = USB_PROD_ID;
  MscDevInfo.bcdDevice = USB_DEVICE;
  MscDevInfo.StrDescPtr = (uint32_t)&USB_StringDescriptor[0];
  MscDevInfo.MSCInquiryStr = (uint32_t)&InquiryStr[0];
  MscDevInfo.BlockSize = MSC_BlockSize;
  MscDevInfo.BlockCount = MSC_BlockCount;
  MscDevInfo.MemorySize = (1024*8);
  MscDevInfo.MSC_Read = MSC_MemoryRead;
  MscDevInfo.MSC_Write = MSC_MemoryWrite;

  DeviceInfo.DevType = USB_DEVICE_CLASS_STORAGE;
  DeviceInfo.DevDetailPtr = (uint32_t)&MscDevInfo;

  /* Enable Timer32_1, IOCON, and USBREG blocks */
  LPC_SYSCON->SYSAHBCLKCTRL |= (EN_TIMER32_1 | EN_IOCON | EN_USBREG);

  (*rom)->pUSBD->init_clk_pins();   /* Use pll and pin init function in rom */

  /* insert a delay between clk init and usb init */
  for (n = 0; n < 75; n++) {
  }

  (*rom)->pUSBD->init(&DeviceInfo);  /* USB Initialization */
  init_msdstate();                     /* Initialize Storage state machine */
  (*rom)->pUSBD->connect(TRUE);      /* USB Connect */

  while (1)
      __WFI();                                /* Loop forever */
}

#if defined(__IAR_SYSTEMS_ICC__)
void USBIRQ_IRQHandler(void)
#else
void USB_IRQHandler(void)
#endif
{
  (*rom)->pUSBD->isr();
}
Has anyone run this example code successfully on his LPCxpresso Board? I would appreciate any help to solve this Problem.

Greetings
Sakphul

Outcomes