I have a problem when run USBMem Keil Example for LPC2888. I got "device descriptor read/all, error -71". And sometimes with 10 trials, the device will run for 1 or two times, but fail most of the time. I know from NXP that with old version of LPC2888 can't run at high speed, so I just bought new version of LPC2888 and try for high speed again. My LPC2888 part number is lpc2888fet180 /01, and I want to know can it run at high speed?
I fixed the problem by changing to shorter usb cable from 3 feets to 1 foot and by turn on the optimization of c/c+ of Keil Development to level 1.
Where both changes required?
If the code does not survive on higher optimization levels, then the code is either buggy, or the compiler is.
Correctly written code should produce the same result with or without optimizations, and if timing is critical, then the code should take that into account - or at least specifically document that it may not be compiled at high optimizations. This later alternative is however quite bad, since it would form a dangerous trap for the users to fall into.
Both changes are required. With 3 feets usb cable and using the given firmware Memory.axf in LPC2888/USBMem example for version 3.40. It gives error and usb can not run.
When change it to 1 feet usb cable, there is no error and usb works.
When recompile the source code of LPC2888/USBMem with optimization level 0. There is error and usb does not work.
When recompile the source code of LPC2888/USBMem with optimization level 1 to 3. There is no error and usb work.
"With 3 feets usb cable and using the given firmware Memory.axf in LPC2888/USBMem example for version 3.40. It gives error and usb can not run.
When change it to 1 feet usb cable, there is no error and usb works."
This symptom suggests noise problem, which should be handled with circuit design and board layout. For Hi-speed, more careful design is required than full-speed. With proper design, 3m cable will work.
a) Shield - GND connection The shield pin(s) of USB connector is connected to GND plane over a resistor in parallel with a capacitor.
These Cypress appnote shows a typical connection. "AN1196: EZ-USB FX2 PCB Design Recommendation" on Cypress " on Cypress Termination Resistors, USB Peninsula, and Crystal
c) VBUS line filter For bus-powered device, attach a VBUS line filter of a ferrite bead (or a choke coil) and a capacitor (1 - 10 micro-F, ceramic).
This USB ECN recommends capacitor larger than 1 micro-F on VBUS
USB 2.0 Specification www.usb.org/.../usb_20_122208.zip Device Capacitance ECN.pdf
Tsuneo
In this case, it wasn't a decrease but an increase in optimization levels that was needed? That is a lot better than the reverse, since a higher optimization level may be required to make critical sections fast enough.
Had it been the reverse, i.e. it fails at higher optimization levels, then I would not have liked the code and/or compiler.
A thing to think about. If optimization 0->1 is required, you may not have much safety margin so own changes to the code may push it to failure even at optimization level 1.