DEPARTMENT OF ECE
ACADEMIC YEAR 2016-2017
REGULATION 2013
STAFF IN CHARGE
HOD / ECE
LTPC
0032
OBJECTIVES:
The student should be made to:
Learn the working of ARM processor
Understand the Building Blocks of Embedded Systems
Learn the concept of memory map and memory interface
Know the characteristics of Real Time Systems
Write programs to interface memory, I/Os with processor
Study the interrupt performance
LIST OF EXPERIMENTS
1. Study of ARM evaluation system
2. Interfacing ADC and DAC.
3. Interfacing LED and PWM.
4. Interfacing real time clock and serial port.
5. Interfacing keyboard and LCD.
6. Interfacing EPROM and interrupt.
7. Mailbox.
8. Interrupt performance characteristics of ARM and FPGA.
9. Flashing of LEDS.
10. Interfacing stepper motor and temperature sensor.
11. Implementing zigbee protocol with ARM..
TOTAL: 45 PERIODS
Page
Date
Name of Experiments
No
Marks
No
FIRST CYCLE
1
Mailbox
Flashing of LEDS
10
11
12
Remarks
Exp.No:
Date :
EXPT 1
ARM-2378 DEVELOPMENT BOARD
Introduction
ARM is a 32-bit RISC (Reduced Instruction Set Computer) processor architecture
developed by ARM Corporation. It was previously known as Advanced RISC Machines and
prior to that Acorn RISC Machines. The ARM architecture is licensed to companies that want to
manufacture ARM-based CPUs or system-on-a-chip products. This enables the licensees to
develop their own processors compliant with the ARM instruction set architecture. For
example, the device we are using (LPC21XX) is ARM architecture based SOC product
developed by NXP semiconductors, similarly all major semiconductor manufacturers like
Atmel, Samsung, TI they all make ARM based SOCs. So learning about ARM is pretty cool as
once you are familiar to ARM instruction set you can easily switch between various ARM
based SOCs available in market.
RESULT:
10
Program
#include <iolpc2378.h>
#include "irq.h"
#include "config.h"
void delay()
{
unsigned int i,j;
for(i=0;i<0x3fff;i++)
for(j=0;j<0xff;j++);
}
int main (void)
{
unsigned int Fdiv;
TargetResetInit();
PINSEL0 = 0x00000050;
/* RxD0 and TxD0 */
U0LCR = 0x83;
/* 8 bits, no Parity, 1 Stop bit */
Fdiv = ( Fpclk / 16 ) / 19200 ;
/*baud rate */
U0DLM = Fdiv / 256;
U0DLL = Fdiv % 256;
U0LCR = 0x03;
/* DLAB = 0 */
U0FCR = 0x07;
/* Enable and reset TX and RX FIFO. */
FIO3DIR = 0X008000FF;
while(1)
{
FIO3PIN = 0X000000ff;
delay();
FIO3PIN = 0X00000000;
delay();
}
}
11
Exp.No:
EXPT:2
Date
FLASHING OF LEDS
Aim
To perform the flashing of LEDs with ARM 7 controller
Components Required:
1. LPC 2378 ARM Development board
2. IAR Embedded Workbench 6.5
3. Flash Magic ISP Utility
Theory
LED (Light Emitting Diodes) Light Emitting Diodes (LED) is the most commonly used
components, usually for displaying pins digital states. Typical uses of LEDs include alarm
devices, timers and confirmation of user input such as a mouse click or keystroke. Light
Emitting diodes are most commonly used components, usually for displaying Pins Digital
state. The 8 nos of LED are connected to pin Q0-Q7.The 330 ohm resistor limit the current to
about 4 mA. A low output pin drives current through the LEDs and they will light. Each Led
can be individually enabled or disabled. The digital data sent by the microcontroller is latched
using 74LS273. This latch is selected via 74LS154 decoder.
12
OUTPUT:
13
PROCEDURE:
1. Run the Application IAR Embedded Workbench 6.5
2. Create new project in the current work space. Create a new project by selecting the tool
chain as ARM and create empty project and click ok. Give Project Name and click
SAVE Button.
3. Select LPC2378 >Options menu
4. Select General options category. Enable target option file and select the device as NXP
LPC2378 and click ok.
5. Select C/C++ Compiler >Select Preprocessor and include (C:\Program Files\IAR
Systems\Embedded
Workbench
6.5\arm\inc\c,
C:\Program
Files\IAR
Systems\Embedded Workbench 6.5\arm\inc\NXP)
6. Enable Output Converter Menu and select output format as Intel extended and Enable
Override default option
7. Select Linker Category. Enable Override default option, click SAVE Button.
8. New>File Menu, for creating a new C file. File>Save As, for saving a file. Give your
File name ( Eg: LED.C) and click Save Button.
9. Right Click the project name option for select a C file in
workspace window. Select Add >Add (LED.C) Menu.
10. Select LPC2378>Rebuild all menu, for checking any error in your C file. If your
Cfile has no error.
11. Select LPC2378>Rebuild all menu, for checking any error in your C file.
12. If your project has no error, Building completed and Hex file generated.
13. This Hex file will be downloaded to the VIARM-2378 controller by Flash Magic
Software
14
15
RESULT:
16
<iolpc2378.h>
"irq.h"
"config.h"
"dac.h"
*/
while ( 1 )
{
DACR = (i << 6) | DAC_BIAS;
i++;
if ( i == 1024 )
{
i = 0;
}
}
return 0;
}
17
Exp.No:
Date :
Aim
To interface ADC and DAC with ARM 7 Controller
Components Required:
1. LPC 2378 ARM Development board
2. IAR Embedded Workbench 6.5
3. Flash Magic ISP Utility
Theory
A digital-to-analog converter is a device for converting a digital (usually binary) code to
an analog signal (current, voltage or charges). Digital-to-Analog Converters are the interface
between the abstract digital world and the analog real life. Simple switches, a network of
resistors, current sources or capacitors may implement this conversion. A DAC inputs a binary
number and outputs an analog voltage or current signal.
MCP429x:
The Microchip Technology Inc. MCP492X is 2.7 5.5V, low-power, low DNL, 12-Bit
Digital-to-Analog Converters (DACs) with optional 2x buffered output and SPI interface. The
MCP492X are DACs that provide high accuracy and low noise performance for industrial
applications where calibration or compensation of signals is required
Interfacing SPI-DAC:
Fig.4 shows how to interface the SPI-DAC to microcontroller. With an SPI connection
there is always one master device (usually a microcontroller) which controls the peripheral
devices. Typically there are three lines common to all the devices,
Master In Slave Out (MISO) - The Slave line for sending data to the master,
Master Out Slave In (MOSI) - The Master line for sending data to the peripherals,
Serial Clock (SCK) - The clock pulses which synchronize data transmission generated by
the master.
Slave Select pin - the pin on each device that the master can use to enable and disable
specific devices.
18
OUTPUT:
19
Interfacing of ADC:
An analog-to-digital converter is a device that converts a continuous quantity to a
discrete digital number. Typically, an ADC is an electronic device that converts an input analog
voltage (or current) to a digital number proportional to the magnitude of the voltage or current.
The resolution of the converter indicates the number of discrete values it can produce over the
range of analog values. The values are usually stored electronically in binary form, so the
resolution is usually expressed in bits. In consequence, the number of discrete values available,
or "levels", is usually a power of two.
An ADC with a 10-bit output can represent up to 1024 (210) unique conditions of signal
measurement. Over the range of measurement from 0% to 100%, there will be exactly 1024
unique binary numbers output by the converter (from 0000000000 to 1111111111, inclusive).
ViARM - 2378 Development board has two potentiometers for working with A/D
Converter. All Potentiometers outputs are in the range of 0V to 3.3V. ARM processor takes
analog signal from its input pin and translates it into a digital value. Basically, you can measure
any analog signal that fits in range acceptable by LPC2378. That range is 0V to 3.3V.
PROCEDURE:
1. Run the Application IAR Embedded Workbench 6.5
2. Create new project in the current work space. Create a new project by selecting the tool
chain as ARM and create empty project and click ok. Give Project Name and click
SAVE Button.
3. Select LPC2378 >Options menu
4. Select General options category. Enable target option file and select the device as NXP
LPC2378 and click ok.
5. Select C/C++ Compiler >Select Preprocessor and include (C:\Program Files\IAR
Systems\Embedded
Workbench
6.5\arm\inc\c,
C:\Program
Files\IAR
Systems\Embedded Workbench 6.5\arm\inc\NXP)
6. Enable Output Converter Menu and select output format as Intel extended and Enable
Override default option
7. Select Linker Category. Enable Override default option, click SAVE Button.
8. New>File Menu, for creating a new C file. File>Save As, for saving a file. Give your
File name ( Eg: DAC.C) and click Save Button.
20
t1000,t100,t10,t1,temp;
/ 1000;
% 1000;
/ 100;
% 100;
/ 10;
% 10;
send_serial_data(t1000+0x30);
send_serial_data(t100 +0x30);
send_serial_data(t10+0x30);
send_serial_data(t1+0x30);
send_serial_data(0x0d);
send_serial_data(0x0a);
}
void main()
{
unsigned long int val;
unsigned int Fdiv;
TargetResetInit();
PCONP |= (1 << 12);
PINSEL1 = 0X00054000;
PINSEL0 = 0x00000050;
21
22
// AD0CR = 0x01200601;
// Start A/D Conversion
AD0CR = ( 0x01 << 1 ) |
/* SEL=1,select channel 0~7 on ADC0 */
( ( Fpclk / ADC_CLK - 1 ) << 8 ) | /* CLKDIV = Fpclk / 1000000 - 1 */
( 1 << 16 ) |
/* BURST = 0, no BURST, software controlled */
( 0 << 17 ) |
/* CLKS = 0, 11 clocks/10 bits */
( 1 << 21 ) |
/* PDN = 1, normal operation */
( 0 << 22 ) |
/* TEST1:0 = 00 */
( 1 << 24 ) |
/* START = 0 A/D conversion stops */
( 0 << 27 );
/* EDGE = 0 (CAP/MAT singal falling,trigger A/D
conversion) */
while(1)
{
while((AD0GDR & 0X80000000)!=0X80000000);
val = (AD0GDR>>6)& 0x3ff ;
// convesion data holds AD0DR0[6]
to AD0DR0[15]
adc_serial_tx(val);
// 10 bit adc data transmit serial
port.
}
}
23
RESULT:
24
U0LCR = 0x83;
/* 8 bits, no Parity, 1 Stop bit */
Fdiv = ( Fpclk / 16 ) / 19200 ; /*baud rate */
U0DLM = Fdiv / 256;
U0DLL = Fdiv % 256;
U0LCR = 0x03;
/* DLAB = 0 */
U0FCR = 0x07;
/* Enable and reset TX and RX FIFO. */
FIO4DIR = 0X00000FFF;
FIO3DIR = 0X008000FF;
while(1)
{
//First Row
FIO4SET = 0X00000e00;
Read_Key = FIO4PIN;
Read_Key = (Read_Key & 0xf000) >> 12 ;
if((Read_Key==0x07))
{
send_serial_data('0');
FIO3PIN = 0X00000000;
}
if((Read_Key==0x0b))
{
send_serial_data('1');
FIO3PIN = 0X00000001;
}
25
Exp.No:
Date :
Aim
To interface the Keypad with ARM 7 Controller
Components Required:
1. LPC 2378 ARM Development board
2. IAR Embedded Workbench 6.5
3. Flash Magic ISP Utility
Theory
A keypad is a set of buttons arranged in a block or "pad" which usually bear digits,
symbols and usually a complete set of alphabetical letters. If it mostly contains numbers then it
can also be called a numeric keypad. Here we are using 4 X 4 matrix keypad.
Interfacing keypad:
Fig. shows how to interface the 4 X 4 matrix keypad to two ports in microcontroller. The
rows are connected to an output port and the columns are connected to an input port. To detect a
pressed key, the microcontroller grounds all rows by providing 0 to the output latch, and then it
reads the columns. If the data read from the columns is D3-D0=1111, no key has been pressed
and the process continues until a key press is detected.
26
if( (Read_Key==0x0d))
{
send_serial_data('2');
FIO3PIN = 0X00000002;
}
if((Read_Key==0x0e))
{
send_serial_data('3');
FIO3PIN = 0X00000003;
}
FIO4CLR = 0X00000e00;
delay();
//Second Row
FIO4SET = 0X00000d00;
Read_Key = FIO4PIN;
Read_Key = (Read_Key & 0xf000) >> 12 ;
if((Read_Key==0x07))
{
send_serial_data('4');
FIO3PIN = 0X00000004;
}
if((Read_Key==0x0b))
{
send_serial_data('5');
FIO3PIN = 0X00000005;
}
if( (Read_Key==0x0d))
{
send_serial_data('6');
FIO3PIN = 0X00000006;
}
if( (Read_Key==0x0e))
{
send_serial_data('7');
FIO3PIN = 0X00000007;
}
FIO4CLR = 0X00000d00;
delay();
//Third Row
FIO4SET = 0X00000b00;
Read_Key = FIO4PIN;
Read_Key = (Read_Key & 0xf000) >> 12 ;
if((Read_Key==0x07))
{
send_serial_data('8');
FIO3PIN = 0X00000008;
}
if((Read_Key==0x0b))
{
send_serial_data('9');
FIO3PIN = 0X00000009;
}
27
However, if one of the column bits has a zero, this means that a key press has occurred.
For example, if D3-D0=1101, this means that a key in the D1 column has been pressed. After a
key press is detected, the microcontroller will go through the process of identifying the key.
Starting with the top row, the microcontroller grounds it by providing a low to row D0 only;
then it reads the columns.
If the data read is all 1s, no key in that row is activated and the process is moved to the
next row. It grounds the next row, reads the columns, and checks for any zero. This process
continues until the row is identified. After identification of the row in which the key has been
pressed, the next task is to find out which column the pressed key belongs to.
PROCEDURE:
1. Run the Application IAR Embedded Workbench 6.5
2. Create new project in the current work space. Create a new project by selecting the tool
chain as ARM and create empty project and click ok. Give Project Name and click
SAVE Button.
3. Select LPC2378 >Options menu
4. Select General options category. Enable target option file and select the device as NXP
LPC2378 and click ok.
5. Select C/C++ Compiler >Select Preprocessor and include (C:\Program Files\IAR
Systems\Embedded
Workbench
6.5\arm\inc\c,
C:\Program
Files\IAR
Systems\Embedded Workbench 6.5\arm\inc\NXP)
6. Enable Output Converter Menu and select output format as Intel extended and Enable
Override default option
7. Select Linker Category. Enable Override default option, click SAVE Button.
8. New>File Menu, for creating a new C file. File>Save As, for saving a file. Give your
File name ( Eg: KEYPAD.C) and click Save Button.
9. Right Click the project name option for select a C file in
workspace window. Select Add >Add (KEYPAD.C) Menu.
10. Select LPC2378>Rebuild all menu, for checking any error in your C file. If your
Cfile has no error.
11. Select LPC2378>Rebuild all menu, for checking any error in your C file.
12. If your project has no error, Building completed and Hex file generated.
13. This Hex file will be downloaded to the VIARM-2378 controller by Flash Magic
Software
28
if( (Read_Key==0x0d))
{
send_serial_data('a');
FIO3PIN = 0X0000000a;
}
if( (Read_Key==0x0e))
{
send_serial_data('b');
FIO3PIN = 0X0000000b;
}
FIO4CLR = 0X00000b00;
delay();
//Fourth Row
FIO4SET = 0X00000700;
Read_Key = FIO4PIN;
Read_Key = (Read_Key & 0xf000) >> 12 ;
if((Read_Key==0x07))
{
send_serial_data('c');
FIO3PIN = 0X0000000c;
}
if((Read_Key==0x0b))
{
send_serial_data('d');
FIO3PIN = 0X0000000d;
}
if((Read_Key==0x0d))
{
send_serial_data('e');
FIO3PIN = 0X0000000e;
}
if( (Read_Key==0x0e))
{
send_serial_data('f');
FIO3PIN = 0X0000000f;
}
FIO4CLR = 0X00000700;
delay();
// send_serial_data('c');
}
return 0;
}
29
RESULT:
30
31
Exp.No:
Date :
Aim
To interface the LCD with ARM 7 Controller
Components Required:
1. LPC 2378 ARM Development board
2. IAR Embedded Workbench 6.5
3. Flash Magic ISP Utility
Theory:
Liquid Crystal Display also called as LCD is very helpful in providing user interface as
well as for debugging purpose. A liquid crystal display (LCD) is a flat panel display that uses
the light modulating properties of liquid crystals (LCs). LCD Modules can present textual
information to user.
Interfacing LCD
Fig. shows how to interface the LCD to microcontroller. The 2x16 character LCD
interface card with supports both modes 4-bit and 8-bit interface, and also facility to adjust
contrast through trim pot. In 4-bit interface 7 lines needed to create 4-bit interface; 4 data bits
(D0 D3), three control lines, address bit (RS), read/write bit (R/W) and control signal (E).
32
33
PROCEDURE:
1. Run the Application IAR Embedded Workbench 6.5
2. Create new project in the current work space. Create a new project by selecting the tool
chain as ARM and create empty project and click ok. Give Project Name and click
SAVE Button.
3. Select LPC2378 >Options menu
4. Select General options category. Enable target option file and select the device as NXP
LPC2378 and click ok.
5. Select C/C++ Compiler >Select Preprocessor and include (C:\Program Files\IAR
Systems\Embedded
Workbench
6.5\arm\inc\c,
C:\Program
Files\IAR
Systems\Embedded Workbench 6.5\arm\inc\NXP)
6. Enable Output Converter Menu and select output format as Intel extended and Enable
Override default option
7. Select Linker Category. Enable Override default option, click SAVE Button.
8. New>File Menu, for creating a new C file. File>Save As, for saving a file. Give your
File name ( Eg: KEYPAD.C) and click Save Button.
9. Right Click the project name option for select a C file in
workspace window. Select Add >Add (KEYPAD.C) Menu.
10. Select LPC2378>Rebuild all menu, for checking any error in your C file. If your
Cfile has no error.
11. Select LPC2378>Rebuild all menu, for checking any error in your C file.
12. If your project has no error, Building completed and Hex file generated.
13. This Hex file will be downloaded to the VIARM-2378 controller by Flash Magic
Software
34
35
RESULT:
36
37