Hi Thomas.
“TF” == thomas fernando <thos_fernando@yahoo.co.in> writes:
TF> Ok I have designed my LPC2148 board which is the same as the
TF> one you posted here:
TF> viewtopic.php?t=2342
TF> except that R17 is 2k on my board.
That schematic is actually just the Olimex LPC2148 header board. But
the circuitry is the same on their development board too, and both
work OK for me.
R17 is the resistor USB uses to detect the speed of a device that’s
connected. Per the USB-2.0 spec:
7.1.5.1 Low-/Full-speed Device Speed Identification
The USB is terminated at the hub and function ends as shown in
Figure 7-20 and Figure 7-21. Full-speed and low-speed devices are
differentiated by the position of the pull-up resistor on the
downstream end of the cable:
- Full-speed devices are terminated as shown in Figure 7-20 with
the pull-up resistor on the D+ line.
- Low-speed devices are terminated as shown in Figure 7-21 with
the pull-up resistor on the D- line.
- The pull-down terminators on downstream facing ports are
resistors of 15 kΩ ±5% connected to ground.
The design of the pull-up resistor must ensure that the signal
levels satisfy the requirements specified in Table 7-2. In order
to facilitate bus state evaluation that may be performed at the
end of a reset, the design must be able to pull-up D+ or D- from 0
V to VIH (min) within the minimum reset relaxation time of 2.5
μs. A device that has a detachable cable must use a 1.5 kΩ ±5%
resistor tied to a voltage source between 3.0 V and 3.6 V …
There are some sample schematics there too. 2K is out of spec, but I
think it’s probably close enough, since you’re having success with the
HID example.
TF> I use WinARM.
I only use GCC on Linux; I probably tried a Windows development
package years ago, but I’m only really familiar with GCC.
TF> To have a preliminary test : I have loaded the IAR , HID
TF> example , which works perfectly 100/100.I am able to scroll
TF> the mouse etc.
Sounds like your hardware is fine. One thing I do when I’m having
trouble with a uC design is flash and run the simplest “Blink” code
after 5-6 failures with new code. That sort of resets the clock, so I
don’t waste time trying to debug a program, when the problem really is
that I haven’t been downloading successfully.
TF> I do not have the IAR compiler,so I just tried with the hex
TF> file. I then tried the JC Wren code , for CDC , serial port ,
TF> which worked a couple of times and does not do so now.This
TF> code had too many features , so I parked it.
JCWren’s code is very useful for reference, but I think the USB
section is based on a slightly old version of Bertrik’s code. And
Bertrik’s code is also a little hard to follow, although I use the
serial/CDC version successfully in one of my projects.
TF> I am now using the Sparkfun USB boot loader example ,which I
TF> am able to compile and try out on my board. The entire
TF> episode is on :
TF> viewtopic.php?t=13079
I tried the Sparkfun USB boot loader, but I never got it to work, and
it didn’t do what I wanted anyway. I wrote a different boot loader,
based on Bertrik’s code, that works like this:
- After reboot, wait several seconds for USB host to connect. If
connected:
% Identify as serial port
% Read simple commands from host over serial port
% If the host sends an Intel HEX file, program it into Flash
% If the host sends a “reset” command, start executing as below
- If no connection from host for a few seconds:
% Look in a special location (I don’t remember exactly where, maybe
@0x2000?) for a valid vector table
% If vector table is present, copy it to RAM and remap the vector
table pointer
% Transfer control to that reset vector.
So, you can plug in the board and (quickly) do "copy Program.hex
/dev/ttyUSB" and it’ll program the Flash. Reset the board and wait a
few seconds, and the bootloader will start the new code.
It’s handy for me because the LPC2148 header board doesn’t have an
RS232 port, so I can’t use the Philips ISP.
This code is all available on the Yahoo LPC2000 group site at:
http://tech.groups.yahoo.com/group/lpc2 … es/USBoot/
There’s also a HEX image that you could install if you can’t compile
the source.
One thing I thought of while looking at your SparkFun post: the
infinite loop
while (IOPIN0 & (1<<23))
{
USBHwISR();
}
is running the USB code in polled mode, instead of real interrupt
mode. If you’re not polling fast enough, it won’t work reliably.
Make sure you set the PLL on the chip as fast as it’ll go (60MHz). I
think you can probably use USB with the main oscillator going as slow
as 24MHz or maybe 48MHz, but only if you use good interrupt code.
Anyway, if the HID example works reliably, your hardware is probably
OK. If you’re having enumeration problems (the host doesn’t detect
the device type properly) then it’s likely logic or timing issues with
the code running the 2148 USB peripheral. Also, since it sounds like
you’re using various different people’s USB code, I think you’re going
to have a tough time debugging. USB is so complicated, that if you
don’t understand everything that’s supposed to happen, you won’t be
able to find the spot in the code that needs fixing.
I was pretty lucky that Bertrik’s code worked the way I wanted for my
boot loader. I haven’t been able to get it to do what I want for my
next project, so I’m trying to write my own stack so I understand it
well enough to make big changes.
Good luck.
d.