Connecting To and Programming the LPC2148 Blue Board We have two primary methods of programming the LPC2148 Blue Board. We can use the supplied bootloader with ISP (In-System Programming) or JTAG (better and supports live debugging!) Method 1 ISP (In-System Programming) w/ Flash Magic You will require: USB -> RS232 Serial Adapter Cable Flash Magic from http://www.flashmagictool.com/ Already pre-programmed in the LPC2148 is a bootloader which can download your program through the serial port. In order to access this bootloader we need to control the RESET and the ISP button. We are going to set up Flash Magic to automatically do this for us. Step 1: Set the Board to use Auto ISP mode Set the Jumper/Shunt on J26 to short position 2 and 3
Step 2: Plug in the USB -> RS232 Serial Adapter Cable to UART0 and also plug in the USB cable supplied. The USB cable supplied is being used for power only. You can also program through the USB cable alone, but that is a little longer process and you can read about it in the LPC2148 Blue Board User Manual. You can also power the board through the power jack using a 6-9v power supply. If using a power supply, normally we would care about whether the jack was center positive or negative (polarity). If you look at the schematic for the board, you will notice that we have been conveniently provided a full-wave bridge rectifier to accept either polarity for our power supply jack (this is worth mentioning as I found it to be rather clever). Step 3: Configure Flash Magic. 1. Make sure to select LPC2148 2. Set the COM port to that of your USB - >Serial adapter. In my case it was COM 1. If you have having trouble finding it, go to the Windows Device Manager, watch the window and unplug/plug in the cable and watch for the change. 3. Baud Rate can be anything at 38400 bps or lower 4. Make sure Erase blocks used by Hex File and Verify after programming are
Next: Go to Options -> Advanced Options and set the following. Remember I mentioned earlier that we are using Auto ISP Mode. This means that we will allow Flash Magic to toggle reset and the bootloader. Now we can browse to select our Hex File and press Start. Once programming is complete we can press the reset button on our board and our program should run. If your program isn t running by this point, you may have to unplug the serial cable and press reset again.
Method 2 JTAG debugger and Keil uvision Let the Fun Begin! You will require: JTAG Adapter compatible with Keil uvision (ULINK2) search ebay for ULINK2 (~$20 and ships from china, so order 2 weeks before you need it!) JTAG Programming and Debugging truly is the best thing since sliced bread! We can program the LPC2148 flash memory directly from the Keil uvision IDE (Integrated development Environment). We can also run our code without having to reset or toggle switches. However, the best thing is that we can perform live debugging with the hardware. In other words we can set a breakpoint, single step and watch all of the Registers and SFRs (Special Function Registers) change in real-time on our hardware as it interacts with the real world! Step 1: Ensure J11 is shorted with a jumper/shunt. J11 enables the JTAG debug feature on our LPC2148 BlueBoard Step 2: Plug in the ULINK2 JTAG Debugger to J12 and your computer through the USB cable. Don t bother installing any drivers which may have been supplied as Keil should already have installed these on your system. Also make sure you have power to the board.
Step 3: Now we must configure Keil uvision to use the ULINK2 JTAG. Right-Click on Target1 and go to Options. From here select ULINK2. Keil will probably ask you to upgrade the firmware on the ULINK2, go ahead and upgrade by selecting yes. Once the upgrade has completed, you should see a confirmation in the build output window at the bottom. Now click on Settings next to the ULINK2 that you selected in the Debug tab under options. Make sure you check Download to Flash as shown below. These are the settings I used.
Step 4: Once your settings are properly set. Go ahead and select OK and go back to your project. For this project I used the unchanged default Startup.s for test purposes. I then added a small loop program at the bottom of the code to test everything. Once your code is written and you are ready to program, click on debug, the same way we did on the simulator. This will download your program directly to the LPC2148 and will stop you at the beginning of Startup. From here you can set a breakpoint at your loop and look at the registers. Pressing Run will step you through each iteration of the loop. From here you can watch RO in real-time get decremented on your processor. Also, notice the lights on the ULINK2 each time you press Run. The debugger of Keil is instructing the ULINK2 to cause the LPC2148 to run to the next breakpoint. If you want to just run non-stop and uninterrupted, just don t set a breakpoint and hit run. If instead while running, you encounter a bug in your code, you can stop the execution, inspect the current state of the LPC2148 and single-step to find your problem. This is how most production embedded systems are developed and how we will develop our projects.