11 years, 10 months ago.

Bizarre failure of mbed code on Target PCB, or LPCXpresso, USB MSC

Use mbed cloud compiler to get binary from the (unmodified) library version of the USB Host Mass Storage Example:

http://mbed.org/users/igorsk/code/MSCUsbHost/

the binary works perfectly with an mbed module, and I tested it for many hours of use in my application.

If you move to a target board, or an LPCXpresso (with the LPCLink attached, or removed):

- it never works if you flash the binary using ISP (LPC21ISP in binary mode) - it works if you flash with the JTAG/SWD interface using LPCLink, and you can RESET it many times and it still works. BUT if you power off, it stops working no matter how many RESETs you try! and it fails until you re-flash using SWD/JTAG.

when it fails, the USB enumeration still reports the USB stick correctly, but can't open a directory, or a file.

This is so very strange.

I have checked:

Power supply 3.3V logic, 5V USB. The capacitance of the USB lines is OK (30pF measured), and the scope shows good waveforms. The D+/D- lines correctly measure 15K to GND on each.

In desperation, I am adding the missing pullups to the JTAG inputs (watch out for these missing parts on LPCX) but still no USB.

What is it about power-ON and OFF cycles that breaks this code? and why is the mbed module unaffected???

binary here: /media/uploads/RodColeman/msd2.bin

1 Answer

11 years, 10 months ago.

AFAIR there was an issue with the __WFI calls that I inserted in the loop which waits for flag changes - it works on mbed because there's an interrupt from the interface chip, but on bare device it gets stuck waiting for interrupt which never arrives. Try replacing all __WFI() in Host_EnumDev() with an empty statement.

Accepted Answer

Igor, Perfect! Works right away!

Change: in usbhost_lpc17xx.cpp

lines 374, 379, 624: WFI(); replaced with Host_DelayMS(20);

I really appreciate your time and consideration. THANK YOU, Igor!

Rod

posted by Rod Coleman 22 Jan 2013