Thursday, September 8, 2011

All about the LPC1343 USB Bootloader

So, you want to use the USB bootloader function built into the LPC1343? Personally, I think this is one of the coolest built in functions. Why? A lot of chips have serial bootloaders. In fact, all of the NXP LPC series chip have a built in bootloader. Why is the USB bootloader so cool?

Why is the USB bootloader so cool?

Who has a serial port?

Serial bootloaders are great if you don't want to buy an expensive JTAG or programmer. However, they have some shortcomings. First, you need a serial port. In the past 10 years, serial ports have slowly disappeared from computers. Often, you need a USB to Serial converter or level shifter, which defeats the purpose of not having a JTAG or programmer.

Speed is everything

Serial is slow. If you are lucky, you get 115200 baud to work on the LPC bootloader. Usually, I'm stuck at 57600. Regardless, USB is fast. 12Mbit. Programming the device happens in the blink of an eye.

Built in goodies

Guess what? That USB bootloader implements a lot of code. Code that you can use. The LPC1343 bootloader resides in ROM and contains all the code necessary for a USB Mass Storage Device. All you have to do is fill out the necessary USB device info, call an init function, and then a connect function. The ROM saves you around 8K memory space, and a lot of headaches (if you know some stuff about it).

Great! How do I use it?

If you want to implement the USB bootloader functionality into a new design using the LPC1343, you need to know the following.

Crystal/Oscillator selection

The USB bootloader code expects a 12Mhz external clock source. Why does this matter? The bootloader must set up the USB PLL in order to generate the 48MHz clock used in USB. The PLL settings are hard coded into the ROM. Any other frequency other than 12MHz will cause the the bootloader to crash and not function.

Soft Connect

It took some digging to figure out what 'Soft Connect' does. In short, the Soft Connect feature allows you to control when the host device detects that a new end device becomes available. It does this by connecting a 1.5K pull-up resistor to 3.3V. What does that mean for you? The device now can control when it must respond to host commands, allowing it to execute any initiation code without time constraints. Additionally, you can disconnect and reconnect the device without physically removing the device.

Most reference designs use a PNP BJT. A P-channel FET works just as well, reduces current consumption, and is available in ridiculously tiny packages.

Here is my reference design which is known to work

Saturday, September 3, 2011

Getting Started with Android Development, Modifying the Snake Example for Touch Input

Google has done a good job with the Android SDK, especially including documentation. The only problem is, however, that the excess of documentation can be overwhelming. An inexperienced developer may find it difficult to pick out simple items in the wealth of information. Consider this the first of my 'Getting Started with Android Development' posts.
Recently I purchased a newer model Android device, only to find the example games used the keyboard exclusively. Wouldn't you know, my phone doesn't have a keyboard! Let's modify the Snake example to work with touch events.
Implementing touch events can be broken into three pieces,
  1. Create an input listener
  2. Register your listener
  3. Implement your input handling function

The difficult thing is to pick a way to do this. Check here for an overview on the 3 ways to do this. I chose method 2, implementing the event listener in the View.

Creating an Input Listener

For this tutorial, I assume you are able to load the Snake example program. In the /src folder find the SnakeView.java file and open it. First, we must tell the the SnakeView that it will be handling the touch events. Change

...

/**
 * SnakeView: implementation of a simple game of Snake
 * 
 * 
 */
public class SnakeView extends TileView {

...

Youtube Channel

Loading...