Professional Documents
Culture Documents
Peeyush.K.P.
Amrita School of Engineering
Coimbatore
NXP’s LPC2148
Architecture
Peeyush.K.P.
Amrita School of Engineering
Coimbatore
LPC 2148 ARCHITECTURE
LPC 2148 ARCHITECTURE
PHASE LOCKED LOOPS (PLL)
PLL FREQUENCY CALCULATION (CCLK)
M = CCLK / FOSC
M = 60 MHz / 12 MHz = 5
P = FCCO / (2 X CCLK)
1) Enable PLL and Disconnect PLL from CPU and other peripherals
PLL0CON = 0x01;
2) Configure M value and P value
PLL0CFG = 0x24;
3) Feed Sequence for locking to desired frequency
PLL0FEED = 0xAA; PLL0FEED = 0x55;
4) Check whether the PLL0 has locked on to the desired frequency
while( !( PLL0STAT & 0x00000400)); PLOCK = 0
5) Enable (again) PLL and Connect the PLL to CPU
PLL0CON = 0x03;
6) Feed Sequence for connecting the PLL0 as system clock
PLL0FEED = 0xAA; PLL0FEED = 0x55;
7) Configure PCLK at 1/4 frequency of System Clock
VPBDIV = 0x00; CCLK = 60 MHz and PCLK = 15 MHz
1) Enable PLL and Disconnect PLL from CPU and
other peripherals
PLL0CON = 0x01;
PLL Control Register (PLL0CON)
PLL0CON = 0x01;
2) Configure M value and P value
PLL0CFG = 0x24;
PLL Configuration Register (PLL0CFG)
PLL0CFG = 0x24 0 0 1 0 0 1 0 0
2 4
3) Feed Sequence for locking to desired frequency
PLL0FEED = 0xAA; PLL0FEED = 0x55;
PLL Feed Register (PLL0FEED)
PLL0CON = 0x03;
6) Feed Sequence for connecting the PLL0 as system clock
PLL0FEED = 0xAA; PLL0FEED = 0x55;
PLL Feed Register (PLL0FEED)
VPBDIV = 0x00;
NXP’s LPC2148
GPIO
Peeyush.K.P.
Amrita School of Engineering
Coimbatore
PIN DIAGRAM – GPIO
P0 – 30 Pins PORTS
P1 – 16 Pins P0.0 – P0.25
P0.28 – P0.31
P1.16 – P1.31
STEPS TO BLINK LEDs
PINSEL2 = 0;
STEPS TO BLINK LEDs
IODIR1 = 0xFFFAFFFF;
LEDs Switches
IODIR1 = 0xFFFFFFFF;
STEPS TO BLINK LEDs
IOSET1 = 0XFFFFFFFF;
STEPS TO BLINK LEDs
IOCLR1 = 0XFFFFFFFF;
STEPS TO BLINK LEDs
15 14 13 12 11 4 3 2 1 0
PINSEL2 GPIO/TRACE GPIO/DEBUG SEL
NXP’s LPC2148
UART
Peeyush.K.P.
Amrita School of Engineering
Coimbatore
ARM Vs PC Serial Communication
ARM PC
Tx Rx
Rx Tx
Gnd Gnd
TTL RS232
Logic 1 – 5V Logic 1 – -3V to -15V
Logic 0 – 0V Logic 0 – +3V to +15V
ARM Vs PC Serial Communication
Tx TIN TOUT Tx
Rx ROUT RIN Rx
Gnd
Gnd
Level
Converter
TTL RS232
Logic 1 – 5V Logic 1 – -3V to -15V
Logic 0 – 0V Logic 0 – +3V to +15V
DB9 Connector Details
PIN DIAGRAM – USART 0 & USART 1
STEPS TO TRANSMIT A CHARACTER
(ARM To PC)
U0LCR = 0x83 1 0 0 0 0 0 1 1
8 3
STEPS TO TRANSMIT A CHARACTER
(ARM To PC)
Substitute,
MULVAL=15 & DIVADDVAL=1.
We get U0DLL = 183
On substi. U0DLL = 183 in Baud Rate equation,
Baud rate = 9605.53, i.e ~9605!
Final Config,
PCLK = 30 x 106 Hz
U0DLL = 183
U0DLM = 0
MULVAL = 15
DIVADDVAL = 1
Ex 2 : PCLK = 60 Mhz and Required Baud Rate is 9600 bauds.
Start with U0DLM = 0 , DIVADDVAL = 0 & MULVAL = 1 with PCLK = 60
x 106 Hz
U0DLL = 97;
STEPS TO TRANSMIT A CHARACTER
(ARM To PC)
U0LCR = 0x03 0 0 0 0 0 0 1 1
0 3
STEPS TO TRANSMIT A CHARACTER
(ARM To PC)
2/0 0
STEPS TO TRANSMIT A CHARACTER
(ARM To PC)
0 1/0
6) Read the received Data from U0RBR
data = U0RBR; // Receive Buffer Register
Register Summary - UART
7 6 5 4 3 2 1 0
U0RBR
U0THR
U0DLL
U0DLM
Tx Fifo
U0FCR Rx Trigger Rx Fifo Rst Rx Enable
Reset
Rx
U0LSR TEMT THRE BI FE PE OE RDR
FIFOEr
U0FDR MulVal DivAddVal
UOTER TXEN
NXP’s LPC2148
ADC
Peeyush.K.P.
Amrita School of Engineering
Coimbatore
PIN DIAGRAM – ADC 0
1) Set P0.30 pin as AD0.3 (ADC Input Pin for ADC Channel 3)
PINSEL1<29:28> = 01
Bit Clear/Set
11100101
&11111011
11100001
| 00000010
11100010
11100101
| 00000010
11100110
1 0 0 0 0 0 0 0 0 0 0 0 0
AD0CR |= 0x00000008;
STEPS FOR AD CONVERSION
AD0CR |= 0x00000700;
STEPS FOR AD CONVERSION
AD0CR |= 0x00200000;
STEPS FOR AD CONVERSION
AD0CR |= 0x01000000;
STEPS FOR AD CONVERSION
AD0CR |= 0x01000000;
Register Summary - ADC
31 19
27 26 24 21 16 15 8 7 0
28 17
2
3
31 30 26 24 15 6 5 0
1
6
31 13 12 11 0
PCONP PCAD0
NXP’s LPC2148
External
Interrupts
Peeyush.K.P.
Amrita School of Engineering
Coimbatore
PIN DIAGRAM – External Interrupts
EINT0 - P0.1, P0.16
EINT – 9 Pins EINT1 - P0.3, P0.14
EINT2 - P0.7, P0.15
EINT3 - P0.9, P0.20, P0.30
Steps to Control an Led with External Interrupt
1) Configure P0.14 as EINT1
PINSEL0<29:28> = 10
2) Configure Edge Sensitive/Level Sensitive Interrupt for EINT1
EXTMODE<1> = 1 (Edge Sensitive)
3) Configure Rising/Falling Edge Sensitive Interrupt for EINT1
EXTPOLAR<1> = 0 (Falling)
4) Clear EINT1 Interrupt Flag Bit
EXTINT<1> = 1
5) Configure EINT1 (Interrupt No. 15) as FIQ/IRQ
VICIntSelect<15> = 0 (IRQ)
6) Enable EINT1 Interrupt
VICIntEnable<15> = 1
7) Configure the Interrupt No. of Interrupt Request assigned to
Vectored IRQ Slot (IRQ Slot 5)
VICVectCntl5<4:0> = 1111 (Decimal 15)
8) Enable Vectored IRQ Slot (IRQ Slot 5)
VICVectCntl5<5> = 1
9) Configure ISR Vector Address to VIC IRQ Slot
VICVectAddr5 = (unsigned int)Ext_ISR;
1) Configure P0.14 as EINT1
PINSEL0<29:28> = 10
EXTMODE = 0x2;
External Interrupt Mode Register (EXTMODE)
3) Configure Rising/Falling Edge Sensitive Interrupt
for EINT1
EXTPOLAR<1> = 0 (Falling)
EXTINT |= 0x2;
VICIntEnable = 1<<15;
VIC Interrupt Enable Register (VICIntEnable)
7) Configure Interrupt No. of EINT1 (15) to
Vectored IRQ Slot (IRQ Slot 5)
VICVectCntl5<4:0> = 1111 (Decimal 15)
VICVectCntl5 = 15;
VIC Vector Control Registers (VICVectCntl0-15)
8) Enable Vectored IRQ Slot (IRQ Slot 5)
VICVectCntl5<5> = 1
VICVectCntl5 |= 1<<5;
VIC Vector Control Registers (VICVectCntl0-15)
9) Configure ISR Vector Address to VIC IRQ Slot
VICVectAddr5 = (unsigned int)Ext_ISR;
31 - 6 5 4-0
VICVectCntl0-15 IRQSlot_en Int_request
31 - 0
VICVectAddr0-15 IRQ_vector
peeyushkp.in