LPC2148 ARM7 Microcontroller
LPC2148 ARM7 Microcontroller
LPC2148 ARM7 Microcontroller
net
Features
32-bit ARM7TDMI-S microcontroller 40 kB of on-chip static RAM and 32 kB to 512 kB of on-chip flash memory In-System Programming/In-Application Programming (ISP/IAP) 8 kB of on-chip RAM accessible to USB by DMA Two 10-bit ADCs provide a total of 14 analog inputs 10-bit DAC provides variable analog output Two 32-bit timers/external event counters (with four capture and four compare channels each)
PWM unit (six outputs) watchdog timer Real-Time Clock (RTC) with independent power Multiple serial interfaces including -- two UARTs, -- Two Fast I2C-bus (400 kbit/s), -- SPI and SSP with buffering and variable data length capabilities Vectored Interrupt Controller (VIC) with configurable priorities and vector addresses 45 general purpose I/O pins 21 external interrupt pins available On-chip integrated oscillator operates with an external crystal from 1 MHz to 25 MHz
Block Diagram
On chip Flash Program Memory 512 kB Flash memory system This memory may be used for both code and data storage. Programming of the flash memory may be accomplished in several ways(ISP/IAP). On chip Static RAM On-chip static RAM may be used for code and/or data storage. The SRAM may be accessed as 8-bit, 16-bit, and 32-bit. An 8 kB SRAM block intended to be utilized mainly by the USB
Interrupt Controller The Vectored Interrupt Controller (VIC) accepts all of the interrupt request inputs and categorizes them as Fast Interrupt Request (FIQ), vectored Interrupt Request (IRQ), and non-vectored IRQ as defined by programmable settings.
Analog to Digital Converter contain two analog to digital converters. Total number of available ADC inputs is 14 10 bit successive approximation analog to digital converter. Measurement range of 0 V to VREF Global Start command for both converters. Digital to Analog Converter The DAC enables to generate a variable analog output. The maximum DAC output voltage is the VREF voltage. 10-bit DAC. Buffered output. Power-down mode available.
USB 2.0 Device Controller The USB is a 4-wire serial bus that supports communication between a host and a number (127 max) of peripherals Enables 12 Mbit/s data exchange with a USB host controller A DMA controller (available only in LPC2146/48) can transfer data between an endpoint buffer and the USB RAM. UARTs contain two UARTs. In addition to standard transmit and receive data lines, the LPC2148 UART1 also provides a full modem control handshake interface. 16 byte Receive and Transmit FIFOs. Built-in fractional baud rate generator covering wide range of baud rates without a need for external crystals of particular values.
I2C Interface
Is a bidirectional Is a multi-master bus, it can be controlled by more
than one bus master connected to it. It supports bit rates up to 400 kbit/s Bidirectional data transfer between masters and slaves. Serial clock synchronization allows devices with different bit rates to communicate via one serial bus. Serial clock synchronization can be used as a handshake mechanism to suspend and resume serial transfer.
SPI serial I/O control Is a full duplex serial interface, designed to handle multiple masters and slaves connected to a given bus. Synchronous, Serial, Full Duplex Communication. SSP serial I/O control Supports full duplex transfers Data frames of 4 bits to 16 bits of data flowing from the master to the slave and from the slave to the master. Synchronous serial communication. Master or slave operation. 8-frame FIFOs for both transmit and receive. Four bits to 16 bits per frame
Timers
A 32-bit timer/counter with a programmable 32-bit prescaler External event counter Four 32-bit capture channels per timer/counter that can take a snapshot of the timer value when an input signal transitions. A capture event may also optionally generate an interrupt. Four 32-bit match registers that allow: Continuous operation with optional interrupt generation on match. Stop timer on match with optional interrupt generation. Reset timer on match with optional interrupt generation. Four external outputs per timer/counter corresponding to match registers, with the following capabilities: Set LOW on match. Set HIGH on match. Toggle on match. Do nothing on match.
Watchdog Timer
Internally resets chip if not periodically reloaded. Debug mode. Enabled by software but requires a hardware reset or a watchdog reset/interrupt to be disabled. Incorrect/Incomplete feed sequence causes reset/interrupt if enabled. Flag to indicate watchdog reset. Programmable 32-bit timer with internal pre-scaler.
Crystal Oscillator
On-chip integrated oscillator operates with external crystal in range of 1
MHz to 25 MHz
Pin Diagram
PWM1 Reserve d
P0.0
PLL
10 to 25 MHz input clock frequency Output frequency from 10 MHz up to the maximum CPU rate (currently 60MHz) Programmable frequency multiplication PLL bypassed on reset PLL lock indicator can be used as an interrupt to connect the PLL once it is locked PLL programming requires a special feed sequence (similar to the watchdog) for safety
CCLK
VPB divider
PLL Details
PLLCON PLLC
Connect Connect
PLLE
Enable
Multiplier/Divider Values
PLLCFG
FEED SEQUENCE
Enable
PLLFEED
PLOCK
PLLSTAT
Pin 11
OSCILLATOR
Pin 12
PLL
10 60 MHz
(CCLK)
10-25 MHz
GPIO Details
SFRs
IOPIN
The current state of the port pins are read from this register
IOSET
IOCLR
Writing ones sets pins low and clears corresponding bits in IOSET
IODIR
PINSEL0/1
GPIO
Pins available for GPIO:
46 on LPC2148/2119/2124/2129 (64-pin package) 76 on LPC2210/2290 (144-pin package but no on-chip Flash) 112 on LPC2292/2294 (144-pin package using on-chip Flash)
Shared with alternate functions of all peripherals Direction control of individual bits Separate set and clear registers Pin value and output register can be read separately Slew rate controlled outputs (10 ns)
Registers:
PINSEL0
PINSEL1
PINSEL2
IODIR GPIO Port Direction control register. This register individually controls the direction of each port pin.
Registers:
GPIO port 0 Direction register GPIO port 1 Direction register Fast GPIO port 0 Direction register Fast GPIO port 1 Direction register
IOPIN
(Used while performing digital functions)
GPIO Port Pin value register. The current state of the GPIO configured port pins can
This register provides the value of port pins that are configured to perform only digital functions
Registers GPIO port 0 Pin value register GPIO port 1 Pin value register Fast GPIO port 0 Pin value register Fast GPIO port 1 Pin value register
IOSET
GPIO Port Output Set register. This register controls the state of output pins. Writing ones produces highs at the corresponding port pins. Writing zero's has no effect.
Registers GPIO port 0 output Set register GPIO port 1 output Set register Fast GPIO port 0 output Set register Fast GPIO port 1 output Set register
IOCLR
GPIO Port Output Clear register. This register controls the state of output pins. Writing ones produces lows at the corresponding port pins and clears the corresponding bits in the IOSET register. Writing zero's has no effect.
Registers
GPIO port 0 output Clear register 0 GPIO port 1 output Clear register 1 Fast GPIO port 0 output Clear register 0 Fast GPIO port 1 output Clear register 1
: NOTES :
IOPIN-->To read the current state of the GPIO pin IODIR-->Individually control the state of each pin (writing 0 makes particular pin acts as input,
writing 1 makes particular pin as output)
1010010110110110
UART0 / UART1
UART 0 Interface
TxD0 RxD0
TxD1 CTS DTR RxD1 DCD RI RTS DTR
UART 1 Interface
UART0 / UART1
Register locations conform to 550 industry standard UART Built-in Baud Rate Generator
16-bit baud rate generator clock divisor made from 2 8-bit divisor registers: DLM (MSB), DLL (LSB) Required baud rate: pclk/(16 * Divisor)
Error Detection
Parity, Framing and Overrun Errors detected Break Interrupt detection
Word Length Select: 5, 6, 7 or 8-bit characters Stop Bit Select: 1 or 2 stop bits Parity Select: Odd or Even parity Standard modem interface signals included (UART1)
(Transmitter Block)
0
Tx Holding Register Tx Shift Register
INTERFACE
(Receiver Block)
0
Rx Buffer Register Rx Shift Register
Interrupt ID Register
INTERFACE
(Transmitter Block)
1
1 1 1 1
Divisor Latch LSB Tx Holding Register Tx Shift Register
1
Serial Output Pin
Ring Indicator
Data Carrier Detect Data Terminal Rdy Ready To Send UART 1 Modem Control Pins
INTERFACE
(Receiver Block)
1
Rx Buffer Register Rx Shift Register
Interrupt ID Register
I2C Interface
SDA
SCL
400Kbits/sec
Easy to configure as Master, Slave, or Master/Slave Programmable clocks allow versatile rate control
SCLK1 OUT
DATA1 OUT
SCLK2 OUT
DATA2 OUT
SCLK IN
DATA IN
SCLK IN
DATA IN
DEVICE 1
DEVICE 2
SPI Interface
Compliant with Serial Peripheral Interface (SPI) specification Combined SPI master and slave function Maximum data bit rate of 1/8 of the peripheral clock rate Programmable settings for data transmit/receive operations
Clock polarity and clock phase MSB / LSB first
SPI Interrupt
SCLK SS
VPB Bus
ADC
10 Bit ADC Measurement range of 0 V to 3 V. Capable of performing more than 400,000 10-bit samples per second. Optional conversion on transition on input pin or Timer Match signal.
ADC Inputs
7 6 5 4 3 2 1 0
All conversions are 10-bit and take 11 Clocks 4.5 MHz Maximum Allows Conversions to be started by external edge
10-bit ADC
(11 Clocks/Conv)
ADDR
(result)
Building applications
Writing codes in C using LPC2148 register set Compiling the code Generating hex file Powering the ARM through USB and serial cables Set ARM in programming mode Download/Burn HEX file onto flash memory Set ARM in run mode to run the application
Software Development
KEIL IDE
Also called uVISION Integrates project management ,editor, compiler and debugger in one seam-less front end. Includes several compilers - Keil CA ARM - GNU GCC - ARM ADS compiler Debugging tools - uVISION simulator - ULINK interface via JTAG
Starting
Check on create HEX file Select folder for path of the executable file Give a name for the executable
Create a new file.Right click on the new file window and click on Insert #include <LPC214X.h> to use all the register set
Save the file with .c extension Ex : prog.c Highlight the Source group 1 folder .Open the local menu with a right click and select Add files to Group Source group 1
Add the appropriate source (.c files) Build/Execute the code by selecting the Project\build target menu .Build icons are also available on the toolbar. The result which includes any compilation errors or hex file generation can be viewed on the Output window
Output window
To download the hex file into the microcontroller board we use a programmer called Flash magic tool.
Step 1-Communications Set COM Port Baud Rate Device Interface Oscillator Freq(MHz)
Step 2-Erase
Select the box Erase all Flash + Code Rd Prot Step 3-Hex File Click on browse to load the serial.hex file from the folder serial_driver.
Step 4-Options
Select the box Verify after programming.
Power up the microcontroller board using USB cable, make serial cable connection between PC and microcontrollers UART0 db9 connector. To make the board enter programming mode Hold down SW2 (isp) and SW3 (reset), then release SW3 first and finally SW2.
Step 5-Start Click the Start button