Tag Archives: LPC2148

Keeping the USB connected – LPC2148

So I just spent about a week debugging a USB problem on a project using a LPC2148.  I was finding that the USB would randomly connect and disconnect when plugged into the PC.  Sometimes it would stay connected for 10 seconds before disconnecting, sometimes it would stay connected for hours with no problem. I spent several days looking for firmware bugs and checking the USB signal quality, but everything looked good. With the disconnect time being random I assumed it had to be a hardware problem. It turned out to be a problem with both hardware and software. Apart from the D+ and D- pins, the LPC2148 has two other IO pins associated with the USB peripheral:  Connect (PO.31) and Vbus (P0.23). Connect is an output that is used to turn on the pullup to start enumeration. Vbus in an input to detect if USB power is present. On my PCB, the Vbus pin was not connected to anything (that was the hardware problem), but was configured as Vbus instead of P0.23 (that was the firmware problem). It looks like the chip is hardwired so that if you have the “Vbus” pin enabled, the logic level on that pin controls the “Connect” pin. So in my case the floating Vbus pin was randomly going high and low causing the USB to connect and disconnect. Configuring the Vbus pin as a GPIO pin instead fixed the problem.

What kind of bugs me about this is that this behavour isn’t really documented in the user manual. Oh well. It is fixed and the solution was simple. I just wish it didn’t take me so long to find.

LPC2148 RTC bug?

I’ve been having a problem with the RTC and power down mode on a project using the LPC2148.  I am using EINT3/INTWAKE and the RTC alarm as sources to wake the processor from power down and I find that occasionally, when I’m in power down mode,  the RTC peripheral seems to lock up and neither the alarm or EINT3 are able to wake the processor .  The only way to recover is to do a hard reset.
Searching for a solution, I found this post
http://www.embeddedrelated.com/groups/lpc2000/show/20665.php
that said to setup the PREINT and PREFRAC even if you are using an external RTC crystal.

PREINT = ( int )( ( 60000000UL / 32768UL ) – 1 ) & ( ( 1 << 14 ) – 1 );
PREFRAC = ( int )( 60000000UL – ( ( ( unsigned long )PREINT + 1UL ) * 32768UL ) );

I’ve just tried this on a few pieces of hardware that were consistently locking up in power down and it seems to be working so far. When I switch back and forth between firmware with and without those two lines it seems to follow that if I don’t set up PREINT and PREFRAC it locks up. If this is in fact the solution I would really like to know why this works since it makes no sense.