Problem with USBMSC_rom Example

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with USBMSC_rom Example

226 Views
lpcware
NXP Employee
NXP Employee
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
0 Kudos
2 Replies

199 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Sakphul on Tue May 31 07:48:25 MST 2011
Hello
thanks for the hint. changing the Block count to 16 solved My Problem. Now i can normally access the Mass Storage Device. Works Great!
0 Kudos

199 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Tue May 31 00:52:26 MST 2011
Windows 7 requires the mass storage device to have at least 16 sectors. If the physical number of sectors is smaller, report 16 sectors, ignore writes to "phantom" sectors and return zeros during read requests.
0 Kudos