Combining examples keil_usbmem and sdcard_poll on lpc3131

Hi,

I'm trying to develop an usb mass storage memory key by combining two examples : one from NXP (keil_usbmem) and one from embedded artists (sdcard_poll).

Each examples taken separately works well. However if I try to combine them, the usb memory example do not work anymore.

In function MSC_MemoryRead I do the following :

mci_read_blocks(g_mcidev, BlockDevBuff, Offset, Offset);
USB_WriteEP(MSC_EP_IN, &Memory[Offset], n);

So I perform a read on my MMC card (that is well acquired with mci_open and so on), but I discard the data from my MMC and I put the RAM image content instead (just like the original keil_usbmem code).

If I remove the mci_read_blocks function everything works again.

In order to discard an USB timeout problem,I tried also to put a (very) long blocking timer instead of mci_read_blocks. Even with this long timer the code works well.

So I think that something is incompatible in the MCI and USB codes. Maybe, a timer or a memory region, is mistakenly shared between those codes. I search for such ''bug'' in the code but I don't succeed.

Do you have any idea ?

Best regards

More questions in this forum