0% found this document useful (0 votes)
25 views12 pages

Chapter 6 Notes - QA

Uploaded by

jaishuklaaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views12 pages

Chapter 6 Notes - QA

Uploaded by

jaishuklaaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Chapter 6 arm programming with Embedded C

State the important features of LPC2148


● The LPC2148 is a 16 bit or 32 bit ARM7 family based microcontroller
● ISP (in system programming) or IAP (in application programming)
using on-chip boot loader software.
● On-chip static RAM is 8 kB-40 kB, on-chip flash memory is 32 kB-512
kB, the wide interface is 128 bit, or accelerator allows 60 MHz
high-speed operation.
● It takes 400 milliseconds time for erasing the data in full chip and 1
millisecond time for 256 bytes of programming.
● It has 2 kB of endpoint RAM and USB 2.0 full speed device controller.
Furthermore, this microcontroller offers 8kB on-chip RAM nearby to
USB with DMA.
● One or two 10-bit ADCs offer 6 or 14 analogs i/ps with low conversion
time as 2.44 μs/ channel.
● Only 10 bit DAC offers changeable analog o/p.
● External event counter/32 bit timers-2, PWM unit, & watchdog.
● Low power RTC (real time clock) & 32 kHz clock input.
● Several serial interfaces like two 16C550 UARTs, two I2C-buses with
400 kbit/s speed.
● 5 volts tolerant quick general purpose Input/output pins in a small
LQFP64 package.
● Outside interrupt pins-21.
● 60 MHz of utmost CPU CLK-clock obtainable from the
programmable-on-chip phase locked loop by resolving time is 100 μs.
● The incorporated oscillator on the chip will work by an exterior crystal
that ranges from 1 MHz-25 MHz
● The modes for power-conserving mainly comprise idle & power down.

Explain GPIO (Port 0& Port 1) of ARM 7

General Purpose Input Output (GPIO) pins of a microcontroller are used


for driving loads, reading digital and analog signal, controlling external
components, generating triggers for external devices etc.

LPC2148 has two IO ports namely PORT0 (P0) and PORT1 (P1). These
two IO ports are of 32-bit wide and are provided by the 64 pins of the
microcontroller.

The naming convention of the I/O pins on the LPC2148 Microcontroller is


Pa.bc where ‘a’ is the number of the port i.e. 0 or 1 (as LPC2148 has only
two ports) and ‘bc’ is the number of the pin in the port a. For example, P0.1
indicates pin number 1 of PORT0 and P1.10 indicates pin number 10 of
PORT1.

PORT0 is a 32-bit wide input/output port with dedicated direction control


bits for each physical pin. Out of the 32 pins, 28 pins can be used as
general purpose bidirectional I/O pins. Pin P0.31 is an output only pin. Pins
P0.24, P0.26 and P0.27 of PORT0 are not available.

PORT1 is also a 32-bit wide input/output port. In PORT1, pins P1.0 to


P1.15 are not available and pins P1.16 to P1.31 are the available general
purpose input/output pins.

Most of the pins in both the I/O ports of the LPC2148 have more than one
function i.e. they are multiplexed with different functions. For example, Pin
19 of the LPC2148 has three functions namely P0.0, a general purpose I/O
pin, TXD0, the transmitter O/P for UART0 and PWM1, the pulse width
modulator O/P 1.

At any point of operation, each pin can have a single function and the
function can be selected with the help of three Configuration Registers
which control the multiplexers to allow connection between the external
pin and the on-chip peripheral.

The configuration register is called PINSEL and is classified in to three


registers: PINSEL0, PINSEL1 and PINSEL2. These configuration registers
are of 32-bit wide. Any pin on the LPC2148 can have a maximum of 4
functions. Hence in order to select one of the four functions, two
corresponding bits of the PINSEL register are needed. So, a 32-bit PINSEL
register can control 16 pins with 2-bits to control each pin.

PINSEL0 controls PORT0 pins P0.0 to P0.15, PINSEL1 controls PORT0


pins P0.16 to P0.31 and PINSEL2 controls PORT1 pins P1.16 to P1.31.

Example-PINSELO REGISTER
The default function of all the Pins is GPIO. But it is a good programming
practice to mention “PINSEL0=0” in order to select the GPIO function of
the Pins.

State the functions of IOPIN, IODIR, IOSET and IOCLR. register of


ARM7
GPIO function is the most frequently used functionality of the
microcontroller. The GPIO function in both the Ports are controlled by a set
of 4 registers: IOPIN, IODIR, IOSET and IOCLR.

IOPIN: It is a GPIO Port Pin Value register and can be used to read or write
values directly to the pin. The status of the Pins that are configured as
GPIO can always be read from this register irrespective of the direction set
on the pin (Input or Output).

The syntax for this register is IOxPIN, where ‘x’ is the port number i.e.
IO0PIN for PORT0 and IO1PIN for PORT1.

IODIR: It is a GPIO Port Direction Control register and is used to set the
direction i.e. either input or output of individual pins. When a bit in this
register is set to ‘0’, the corresponding pin in the microcontroller is
configured as Input. Similarly, when a bit is set as ‘1’, the corresponding
pin is configured as Output.

The syntax for this register is IOxDIR, where ‘x’ is the port number i.e.
IO0DIR for PORT0 and IO1DIR for PORT1.

IOSET: It is a GPIO Port Output Set Register and can be used to set the
value of a GPIO pin that is configured as output to High (Logic 1). When a
bit in the IOSET register is set to ‘1’, the corresponding pin is set to Logic
1. Setting a bit ‘0’ in this register has no effect on the pin.

The syntax for this register is IOxSET, where ‘x’ is the port number i.e.
IO0SET for PORT0 and IO1SET for PORT1.

IOCLR: It is a GPIO Port Output Clear Register and can be used to set the
value of a GPIO pin that is configured as output to Low (Logic 0). When a
bit in the IOCLR register is set to ‘1’, the corresponding pin in the
respective Port is set to Logic 0 and at the same time clears the
corresponding bit in the IOSET register. Setting ‘0’ in the IOCLR has no
effect on the pin.

The syntax for this register is IOxCLR, where ‘x’ is the port number i.e.
IO0CLR for PORT0 and IO1CLR for PORT1.
Timer Registers

State the function of Prescale counter, Prescale Register, Timer count


register (TOTC) and Timer control register(TOTCR), Match register
and Match Control register

Prescale Counter: The 32-bit PC is a counter which is incremented to the


value stored in PR (Prescale Register) when value in PR is reached, The
TC (Timer Counter) is incremented and PC is cleared. The PC is
observable and controllable through bus interface

Prescale Register: The 32-bit register which hold the maximum value of
prescale counter after which it reset

Timer count register (TOTC)


32 bit register,which gives range of counting from 0 to 0xFFFF FFFF. Then
wraps back to the value 0x0000 0000. This register is incremented on every
tick of clock(PCLK) if prescale count is made 0.
Timer control register(TOTCR)
Timer Control register used to control the timer control functions. We’ll
enable, disable and reset Timer Counter (TC) through this register

Match register(MRO to mr3)

● There are four 32 bit match registers available MR0 to MR3


● For the operations of timer ,one of the match registers may be
sufficient and used by loading number into it
● During operation ,the timer count register starts incrementing,
and at the same time,its count matches with the number in the
match register
● When this match occurs some action can be done by configuring
the bits of match control register

Match Control register


It is a 16-bit register.
It controls what action is to be taken on a match between the Match
Registers and Timer Counter.

Explain Timer Operation of LPC 2148

LPC2148 has two 32-bit timers/counters:Timer0/Counter0 &


Timer1/Counter1.

Calculate the count as per the amount of delay to be generated

Load desired count in Match register.( LPC2148 has match registers that
contain count value which is continuously compared with the value of the
Timer register.

Start the timer by enabling E bit in Timer control register

The timer counter register starts increasing for every tick of PCLK

When the value in the Timer register matches the value in the match
register, specific action (timer reset, or timer stop, or generate an interrupt)
is taken.
Also, LPC2148 has capture registers which can be used to capture the timer
value on a specific external event on capture pins. For information about
LPC2148 capture operation refer Input Capture Mode

To write a program to blink LED or to generate square wave as an


output using ARM processor
Algorithm:-
For LED Interfacing:-
1. Make the port connected to LED high i.e. send a high signal on the
respective port.
2. Call Delay.
3. Send a low signal on the port to switch off the LED.
4. Repeat the steps one to three to blink the LED continuously i.e. put
the steps in a continuous loop.
Figure 6-5 Square wave generation

#include <LPC210x.H>
delay()
{
int i,j;
for(i = 1;i<= 500;i++)
for(j = 1; j<= 500;j++)
;
}
int main()
{
IODIR = 0x00000700;

while(1)
{
IOCLR = 0x00000700;
delay(); //delay
IOSET = 0x00000700;
delay(); //delay
}
}
To write a program to blink LED or to generate square wave as an
output using ARM processor use Timer of 2148
To write a program to interface Seven Segment LED with ARM and display the
numbers from 0-9 sequentially.
Algorithm:
1. Port 0 of ARM is used as an output port (P 0.0 – P 0.7).
2. Provide a code 00000003F to display ‘0’ on segment display.
3. Call delay.
4. Provide a code 00000006 to display ‘1’.
5. Call delay.
6. Provide a code 0000005B to display ‘2’.
7. Call delay.
8. Provide a code 00004F to display ‘3’.
9. Call delay.
10.Provide a code 0000066 to display ‘4’.
11.Call delay.
12.Provide a code 000006D to display ‘5’.
13.Call delay.
14.Provide a code 000007D to display ‘6’.
15.Call delay.
16.Provide a code 00000007 to display ‘7’.
17.Call delay.
18.Provide a code 000007F to display ‘8’.
19.Call delay.
20.Provide a code 000006F to display ‘9’.
21.Call delay.
22. Repeat step from 2 to 21 to display numbers continuously.
Program:
#include <LPC210x.H>
delay()
{ int i,j;
for(i = 1;i<= 300;i++)
for(j = 1; j<= 300;j++);
}
int main()
{ IODIR = 0x000000ff;

while(1)
{ IOSET = 0x0000003f;
delay(); //delay
IOCLR = 0x0000003f;
delay(); //delay

IOSET = 0x00000006;
delay(); //delay
IOCLR = 0x00000006;
delay(); //delay
IOSET = 0x0000005b;
delay(); //delay
IOCLR = 0x0000005b;
delay(); //delay

IOSET = 0x0000004f;
delay(); //delay
IOCLR = 0x0000004f;
delay(); //delay

IOSET = 0x00000066;
delay(); //delay
IOCLR = 0x00000066;
delay(); //delay

IOSET = 0x0000006d;
delay(); //delay
IOCLR = 0x0000006d;
delay(); //delay

IOSET = 0x0000007d;
delay(); //delay
IOCLR = 0x0000007d;
delay(); //delay

IOSET = 0x00000007;
delay(); //delay
IOCLR = 0x00000007;
delay(); //delay

IOSET = 0x0000007f;
delay(); //delay
IOCLR = 0x0000007f;
delay(); //delay

IOSET = 0x0000006f;
delay(); //delay
IOCLR = 0x0000006f;
delay(); //delay
}
}

Circuit Diagram:

You might also like