LPC2148 Hardware Design Overview
An overview of some of the hardware design decisions made for our LPC2148 Reference Design.
While the LPC2148 is a relatively easy chip to work with, if you are new at building schematics and laying out your own PCBs there are certain principles that may be new to you or worth repeating even if you've perhaps come across them before.
Even when working with relatively simple chips and designs, there are always choices and compromises to be made. Our reference board was no exception. Which pins should we break out, what functionality should we include on the core board to balance physical size, assembly complexity, parts cost, etc.? To give a bit of insight into some of the decisions we made, we've put together this simple 'Design Overview' of some of the major parts of our LPC2148 Reference Design. It isn't exhaustive, but most of the main parts of the schematic are described below, and it should get you off to a good start understanding why we connected everything up the way that we did.
You may also want to consult the LPC2103 Hardware Design Overview
, since these two chips share a number of common features and certain hardware was added on one board that isn't present on the other.
We've already written a brief tutorial on Voltage Regulation, and since our reference board follows the suggestions there fairly closely that's probably the best place to start if you don't understand why we've used the above design to regulate the power supply to a stable 3.3V. The only item worth noting is the jumper in the upper-left-hand corner. Since you can power the reference board from either USB (5V) or by using the DC Barrel (VCC), we had to provide a means to chose between these two power supplies. By connecting the common pin in the middle of the jumper (pin 2) to the LM1117's voltage IN pin, you can easily switch to either USB or DC power simply by moving the jumper one position to the left or right.
We've chosen to use the LM1117 simply because it's inexpensive, readily available, and both the USB and DC power supplies are high enough that the 1.4V forward-voltage drop on the LM1117 (3.3V) won't cause any problems (if you don't know what forward-voltage drop is, see the tutorial mentionned above on voltage regulation). If you were using a battery power supply that was only slightly above 3.3V -- a lithium polymer battery that generally runs between 3.7 and 4.2V, for example -- you would need to choose a voltage regulator with a lower forward-voltage drop. Some possible alternatives in that case would be the 150mA ADP121 from Analog Devices with a very low 90mA forward-voltage dropout, or the 300mA ADP1712 with 170mA dropout if you need more power.
A simple power indicator LED is provided (LED1) to indicate if power is currently available or not, along with a 150 ohm current limiting resistor (R9). (For information on current limiting resistors, see our tutorial on Ohm's Law, which also has a simple calculator to determine which resistor you should be using for your own LEDs.)
You should note that in this design we are using a fixed voltage
version of the LM1117 (3.3V output), whereas in the Voltage Regulation
tutorial we use an adjustable output version that requires the use of two resistors to set the output voltage. The adjustable version is more flexible if you work with multiple voltages and only want to stock on component, but it's also slightly more expensive than the fixed-voltage models. In general, you should always opt for the simplest 'reasonable' solution available, since unnecessary complexity only introduces greater potential for component or device failure.
In order to do anything useful, your microcontroller requires a precise, external clock signal referred to as XTAL. This signal most often comes from a crystal that resonates at a specific, tightly-regulated frequency, and is connect to XTAL1 and XTAL2 on the LPC2148. It provides the pulse or 'heartbeat' of your device, and determines how fast it is able to run. Without it the device wouldn't be able to measure anything since it would have no known frame of reference to compare any passage of time against.
We've chosen to use a 12MHz crystal on our reference board since this is a very conveninent value for the LPC2148. It can easily be multiplied by four to generate the 48MHz clock required for USB, and can be multiplied by five to arrive at the LPC2148's maximum clock speed of 60MHz (or 60,000,000 'ticks' per second). Unless you have a specific reason to use a different value, we recommend sticking with 12MHz for ease of use and maximum flexibility in terms of controlling the operating speed of your mcu.
While you could simply hook a crystal directly up to XTAL1/XTAL2 and it would most likely work, it's generally good practice to add a 22pF capacitor on both lines to help jump-start the device as a safety precaution, as you can see in the above schematic.
The LPC2148 also requires a second 32.768KHz crystal if you wish to use the RTC (Real Time Clock) to keep track of the date and time. The layout is identical to XTAL, except that the two pins are connected to RTXC1 and RTXC2.
The reset circuit serves two purposes: it provides a means for the user to manually reset the devices by simply pressing a button (B1), and it provides a failsafe supervisor chip (the MCP130T) that will constantly monitor the voltage level on the board and put the LPC2148 into a reset state if the voltage ever drops below 3.15V. (This is to avoid any potential damage to the device or peripherals if there is an unforeseen problem with the power supply.)
The 10K resistor (R20) simply serves to keep the reset line 'high' unless B1 is pressed, at which point reset will switch to low since GND has less resistance than 3.3V thanks to the 10K resistor. This is called a 'pull-up' resistor, since it pulls the line high until a stronger force or something with less resistance is available to pull the line low. As you can see by looking at the line above the RST label on the MCP130T, the supervisor also pulls the RST line high until the voltage drops below 3.15V at which point it will set the RST line low and cause the LPC2148 to go into reset mode.
There are two common methods of programming the LPC2148: You can use the JTAG port to deploy your compiled software (which requires a hardware JTAG device), or you can use ISP (In System Programming) to copy your compiled HEX files to the device using the free Flash Magic software and a simple USB to RS232/serial adapter. In order to enable ISP mode on the LPC2148, you simply need to pull the ISP line (P0.14) high and reset the device. If the LPC2148 detects that P0.14 is high after a reset, it will boot into ISP mode, at which point you can update the device using Flash Magic, then remove the ISP jumper and reset the device again to boot with the newly updated firmware.
While you can also program the LPC2148 using the JTAG interface, JTAG is intended for debugging your firmware (stepping through the code line-by-line, etc.) and you probably won't want to include it on a production device. As such, it may be a good idea to include ISP functionality on your release boards if you aren't providing another means to update the firmware in the field.
If you don't already have one, you can pick up an inexpensive USB to RS232/Serial Breakout Board in our online store. This will allow you to easily communicate with the LPC2148 board using the UART0 header pins and a simple USB connection on your PC (which is useful since most PCs no longer ship with DB9 serial ports).
Since we are (optionally) powering our board from USB, but may not want USB enabled as soon as we plug the USB cable in, we have based our USB design on the following recommendations from Keil: http://www.keil.com/support/docs/3141.htm. This allows you to use VBUS to power your device (almost everyone has easy access to USB making it an ideal supply), while still retaining control of when USB functionality on the LPC2148 is turned on or off. Even if you're device ONLY uses USB power, we would still recommend this design since it provides you with the most control over USB with your embedded device.
This is a standard JTAG interface for ARM7 devices. The only point that you really need to pay attention to is the RTCK pin which must be pulled low on some chips (like the LPC2148) but should be pulled high on others (like the LPC2103). It isn't always obvious from the datasheets which way to pull RTCK, but you can try searching for "RTCK" or "Reset state of multiplexed pins" in most LPC2100 user manuals for more information. (It's on page 317 for the LPC2148 User Manual, for reference sake.) You also can enable or disable the debug interface with this layout by changing the position of JP3.