Laboratory Manual: Embedded Systems
Laboratory Manual: Embedded Systems
Laboratory Manual: Embedded Systems
Laboratory Manual
Enrollment No.:_______________
Name of the student:_________________________________
CERTIFICATE
Date:
INDEX
Sr.
No.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14
Name of Experiment
To understand architecture of ARM7TDMI
architecture
To understand ARM32 and Thumb instruction set
of ARM microcontroller and write simple programs
To understand features and block diagram of LPC2129 ARM processor. To download and execute
program to blink 8 LEDs connected at Port P0 of
LPC-2129 ARM7TDMI chip using LPC2000 flash
utility
To understand features of LPC-2294 ARM
processor and download programs to flash 8 LEDs
connected at Port P1 of LPC-2294 ARM Processor
Write program to blink LEDs one by one.
Download and execute program in LPC-2129 chip.
Modify this program according to given instruction
in exercise
To write and execute program to display message
display WELCOME GEC RAJKOT on LCD screen
for ARM7
To read analog input voltage and display it on LCD
using LPC-2129
To understand embedded system development
using ADSP-2181 kit
To generate sine wave, square wave and other
complex waveforms using ADSP-2181
To filter input signal using FIR filter
implementation with ADSP-2181
To understand features of Cypress Programmable
System on Chip (PSoC). To download and execute
demo programs to display vertical bar graph using
LEDs depending on analog input voltage.
To read analog voltage and display it on LCD using
cypress kit
To become familiar with GCC compiler, WinARM
and crossware development tools
To interface GSM modem with PC and
microcontroller
Assignment
Page
No.
4
11
17
24
26
29
33
39
50
54
58
62
64
66
74
Experiment No.1
Aim: To understand architecture of ARM7TDMI architecture
Brief Theory:
The ARM7TDMI is a member of the Advanced RISC Machines (ARM)
family of general purpose 32-bit microprocessors, which offer high
performance for very low power consumption and price. The ARM
architecture is based on Reduced Instruction Set Computer (RISC)
principles, and the instruction set and related decode mechanism are much
simpler than those of micro-programmed Complex Instruction Set
Computers. This simplicity results in a high instruction throughput and
impressive real-time interrupt response from a small and cost-effective chip.
Pipelining is employed so that all parts of the processing and memory
systems can operate continuously. Typically, while one instruction is being
executed, its successor is being decoded, and a third instruction is being
fetched from memory.
The ARM memory interface has been designed to allow the
performance potential to be realized without incurring high costs in the
memory system. Speed-critical control signals are pipelined to allow system
control functions to be implemented in standard low-power logic, and these
control signals facilitate the exploitation of the fast local access modes
offered by industry standard dynamic RAMs.
The ARM7TDMI processor employs a unique architectural strategy
known as THUMB, which makes it ideally suited to high-volume
applications with memory restrictions, or applications where code density is
an issue.
Thumb Concept:
The key idea behind THUMB is that of a super-reduced instruction set.
Essentially, the ARM7TDMI processor has two instruction sets:
Standard 32-bit ARM set
16-bit THUMB set
The THUMB sets 16-bit instruction length allows it to approach twice the
density of standard ARM code while retaining most of the ARMs
performance advantage over a traditional 16-bit processor using 16-bit
registers. This is possible because THUMB code operates on the same 32-bit
register set as ARM code.
THUMB code is able to provide up to 65% of the code size of ARM, and 160%
of the performance of an equivalent ARM processor connected to a 16-bit
memory system.
THUMB instructions operate with the standard ARM register configuration,
allowing excellent interoperability between ARM and THUMB states. Each
16-bit THUMB instruction has a corresponding 32-bit ARM instruction with
the same effect on the processor model.
The major advantage of a 32-bit (ARM) architecture over a 16-bit
architecture is its ability to manipulate 32-bit integers with single
instructions, and to address a large address space efficiently. When
processing 32-bit data, a 16-bit architecture will take at least two
instructions to perform the same task as a single ARM instruction. However,
not all the code in a program will process 32-bit data (for example, code that
performs character string handling), and some instructions, like Branches,
do not process any data at all.
If a 16-bit architecture only has 16-bit instructions, and a 32-bit
architecture only has 32-bit instructions, then overall the 16-bit
architecture will have better code density, and better than one half the
performance of the 32-bit architecture. Clearly 32-bit performance comes at
the cost of code density.
THUMB breaks this constraint by implementing a 16-bit instruction length
on a 32-bit architecture, making the processing of 32-bit data efficient with
a compact instruction coding. This provides far better performance than a
16-bit architecture, with better code density than a 32-bit architecture.
THUMB also has a major advantage over other 32-bit architectures with 16bit instructions. This is the ability to switch back to full ARM code and
execute at full speed. Thus critical loops for applications such as fast
interrupts and DSP algorithms can be coded using the full ARM instruction
set, and linked with THUMB code. The overhead of switching from THUMB
code to ARM code is folded into sub-routine entry time. Various portions of a
system can be optimized for speed or for code density by switching between
THUMB and ARM execution as appropriate.
Core diagram of the ARM7TDMI is shown in the following figure.
are general-purpose, and may be used to hold either data or address values.
In addition to these, there is a seventeenth register used to store status
information
Register 15 holds the Program Counter (PC). In ARM state, bits [1:0] of
R15 are zero and bits [31:2] contain the PC. In THUMB state, bit [0] is
zero and bits [31:1] contain the PC.
User, IRQ, Supervisor, Abort and Undefined each have two banked
registers mapped to R13 and R14, allowing each of these modes to have a
private stack pointer and link registers.
ABE (Address Bus Enable) pin is LOW, it puts the address bus into a
high impedance state. ABE must be tied HIGH when there is no system
requirement to turn off the address drivers.
instruction adds content of registers R2 and R3 and saves result into R1).
Operations related to memory are load and store operations only. Copy
memory values into registers are called load instructions and copy register
values into memory are called store instructions. ARM does not support
memory to memory operations.
ARM Exceptions: ARM architecture supports range of interrupts, traps and
supervisor calls. All these are grouped under general heading ARM
Exceptions Exceptions are handled in following ways:
WORKSHEET
[1] What are the differences between ARM and 51 Family microcontrollers?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
9
[2] What is the difference between RISC machine and CISC machine?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[3] What is load and store architecture? What kind of operations are not
permitted in load and store archictecture?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[4] List ARM development tools available for the development of ARM
applications.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
10
Experiment No.2
Aim: To understand ARM32 and Thumb instruction set of ARM
microcontroller and write simple programs
ARM instruction is 32 bit long. All operands are 32 bit wide and come
from registers or are specified as literals in the instruction itself. Thumb
instruction set is 16 bit. It is compressed form of subset of ARM
instructions. It provides more code density. ARM processor which supports
Thumb instruction set, also executes standard 32 bit instruction set.
Instruction stream at particular time is determined by bit 5 of CPSR (T bit).
If T bit is set, ARM processor interprets instruction as 16 bit Thumb
instruction otherwise it interprets as standard 32 bit instruction. ARM core
start up after reset, executes normal 32 bit ARM instructions. The normal
way to switch into Thumb mode is by executing branch and exchange
instruction (BX).
ARM instructions fall into one of following three categories.
1. Data processing instructions: These instructions are used to change
register values by various arithmetic and logical operations
2. Data transfer instructions: Copy memory values into registers (load
instructions) and copy register values into memory (store instructions)
3. Control flow instructions: Control flow instructions cause execution to
switch to different address. Conditional and unconditional jump
instructions, interrupts, supervisor calls falls into this category.
4. Instruction set:
Data processing instructions:
Multiply Instructions
11
Some Examples:
Data transfer instructions (Load and Store)
[1] MOV R1,R2
Explanation: Content of register R2 copied into R1 R1 R2
[2] MOV R1,#0x55
Explanation: Move hexadecimal value 0x55 to register R1
[3] MVN R1,R2
Explanation: Content of R2 complemented and than transferred to R1
R1R2`
[5] MOV PC,R14
Explanation: Copy content of register R14 into PC. Return from subroutine
because R14 is the link register.
[5] LDR R1,[R2]
Explanation: Load R1 from memory address pointed by R2 R1 *R2
Data stored at the address pointed by register R2 is loaded into register R1.
[6] LDR R1,[R2,#8]
Explanation: Load register R2 from the memory address pointed by R2+8.
R1 *(R2+8)
[7] STR(R5,#8),R1
Explanation: Store content of register R1 at the memory location specified by
R5+8. *(R5+8) R1
12
13
WORKSHEET
[1] What are the advantages of THUMB mode of ARM microcontroller?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
14
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[2] For what type of applications full arm instructions are better compared to
thumb and switching is required from thumb mode to full arm mode?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[3] Write instructions for the following operations
[a] Move content of register R6 into R5
_____________________________________________________________________
[b] Move immediate data #66 in the register R4
_____________________________________________________________________
[c] Add content of register R3 and R4. Save result in register R6
_____________________________________________________________________
[d] Multiply content of register R1 and R2. Save result in register R3.
_____________________________________________________________________
[e] Write instruction to multiply content of register R4 with 5. Use ADD
instruction in combination with logical shift instruction.
_____________________________________________________________________
_____________________________________________________________________
[f] Write instruction to multiply and accumulate. Use registers R4,R5,R6 and
R7.
_____________________________________________________________________
_____________________________________________________________________
15
_____________________________________________________________________
[4] Write a program to add elements of array. Consider three elements in the
array. Load data from the array using instruction LDR and add it. Store
the result in register R0.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[b] MOV R0,R1,ROR #2
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
16
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[d] ORR R0,R1,R2
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[e] EOR R0,R1,R2
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[f] BIC R0,R1,R2
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[g] CMP R0,#5
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[h] AND R8,R7,#&FF
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
17
Experiment No.3
Aim: To understand features and block diagram of LPC-2129 ARM
processor. To download and execute program to blink 8 LEDs connected at
Port P0 of LPC-2129 ARM7TDMI chip using LPC2000 flash utility
Brief Theory:
The ARM microcontrollers are high-performance, 16/32 bit RISC Core
devices. The ARM market is one of the fastest growing market for
microcontrollers. TheLPC2119/LPC2129 are based on a 16/32bit
ARM7TDMI-S CPU with 256 kB of embedded high speed flash memory. A
128-bit wide memory interface and a unique accelerator architecture enable
32-bit code execution at maximum clock rate. For critical code size
applications, the alternative 16-bit Thumb Mode reduces code by more than
30% with minimal performance penalty.
LPC2129 comes with 64 pin package, low power consumption, various
32-bit timers, 4-channel 10-bitADC, 2 advanced CAN channels, PWM
channels and 46 GPIO lines with up to 9 external interrupt pins these
microcontrollers are particularly suitable for automotive and industrial
control applications as well as medical systems and fault-tolerant
maintenance buses. With a wide range of additional serial communications
interfaces, they are also suited for communication gateways and protocol
converters as well as many other general-purpose applications.
The advantage of ARM microcontrollers are:
It is very fast: ARM7 core run at 60 MHz and ARM9 runs at 150 MHz
Low power dissipation: Typical power dissipation for ARM7 is 0.5-1
mA/MHz
Great range of peripherals: ADC, DAC, USB, SPI,UART, I2C, CAN,
Ethernet, SDRAM
Internal Flash (32 KB to 1 MB depending on chip) and RAM (4 to 256 KB)
The salient features of LPC-2129 are listed below:
16/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package. 16kB
on-chip Static RAM. 128/256kB on-chip Flash Program Memory.
128-bit wide interface/accelerator enables high speed 60MHz operation.
In-System Programming (ISP) and In-Application Programming (IAP) via
on-chip boot-loader software. Flash programming takes 1 ms per 512
byte line. Single sector or full chip erase takes 400ms.
Embedded ICE-RT interface enables breakpoints and watch points.
Interrupt service routines can continue to execute whilst the foreground
task is debugged with the on-chip Real Monitor software.
Embedded Trace Macrocell enables non-intrusive high speed real-time
tracing of instruction execution. Two interconnected CAN interfaces with
advanced acceptance filters.
Four channel 10-bit A/D converter with conversion time as low as 2.44
s.
Multiple serial interfaces including two UARTs (16C550), Fast I2c 400
kbps and two SPIs.
18
19
Features of LPC2129:
Multiple serial interfaces including two UARTs (16C550), Fast I2C 400
kbps two SPIs.
Dual power supply: CPU operating voltage range of 1.65V to 1.95V (1.8V
0.15V).
I/O power supply range of 3.0V to 3.6V (3.3V 10%) with 5V tolerant I/O
pads.
21
31
24
23
22
21
20 .. 17
16
15
14 10
2 1 0
00
0 .. 0
0 0
1 0 0
00
40
02
FC
Program:
/ *********** Program to blink LEDs **********/
#include <LPC21xx.h>
/* LPC21xx definitions in header file */
#include "Timer.h"
extern long volatile timeval;
void wait (void)
/* wait function */
{
unsigned long i;
i = timeval;
while ((i +100 ) != timeval);
/* wait 100ms */
}
int main (void)
{
unsigned int j;
/* LED var */
IODIR0 = 0x004002FC;
/* Define I/O pins */
init_timer();
while (1)
/* Loop forever */
{
j== 0x004002FC;
/* bit pattern for LEDs connected at GPIO port 0*/
IOSET0=j;
/* turn LEDs ON */
wait();
/* Delay */
IOCLR0=j;
/* turn LEDs OFF */
wait();
/* Delay */
}
}
Create project and write above program using KEIL IDE tool. (Create New
Project, write C program in new file, Add C file in your project, Add
necessary header files such as LPC21xx.h, timer.c and timer.h in your
project). Build program to generate HEX file.
Use Philips LPC2000 flash utility to download your program HEX file in
the chip. Screen looks as shown in the figure in the next page
Philips LPC2000 Flash utility connects PCs serial port (COM port) to the
serial port of LPC2129 chip and provides in system flash programming
(ISP).
Select device LPC2129, Change crystal frequency 12000 KHz (12 MHz)
(Or press Read device Id command button, it will select device
automatically)
22
Before downloading HEX file in the chip, ensure that switch SW5 of the
ARM board is in left position. Press RESET key before downloading
After downloading the program, make switch SW5 in the right side and
press the reset key to start execution.
WORKSHEET
[1] Modify program of this practical to change blinking interval. Generate
HEX file of modified program, download it and observe the result
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
23
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[2] What is brown out reset?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[3] Why interrupt execution is fast in ARM processor in FIQ mode?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[4]Write key features of LPC2129 microcontroller
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
24
Experiment No.4
Aim: To understand features of LPC-2294 ARM processor and download
programs to flash 8 LEDs connected at Port P1 of LPC-2294 ARM Processor
Features of LPC-2294:
The LPC-2294 microcontroller is based on a 16-bit/32-bit ARM 7 TDMI-S
It has 256 KB of embedded high - speed flash memory. It has 16 KB on
chip static RAM. A 128-bit wide memory interface and unique accelerator
architecture enable 32-bit code execution at the maximum clock rate. For
critical code size applications, the alternative 16-bit Thumb mode reduces
code by more than 30% with minimal performance penalty.
LPC-2294 ARM chip has 144-pin, low power consumption, various 32-bit
timers, 8-channel 10-bit ADC, 2 advanced CAN channels, PWM channels
and up to nine external interrupt pins these microcontrollers are
particularly suitable for automotive and industrial control applications
as well as medical systems and fault-tolerant maintenance buses. The
number of available GPIO's ranges from 76 (with external memory)
through 112 (single-chip). With a wide range of additional serial
communications interfaces, they are also suited for communication
gateways and protocol converters as well as many other general-purpose
applications.
Procedure:
1.
To program IC via serial port, short the 1-2 pin of the jumpers J7 &
J6 (left side). Connect the serial cable to any functional COM port of
your PC and SP2 (DB-9 Connector) port of the trainer (in PC interface
& ISP section).
2.
To program IC via USB, short the 2-3 pin of the jumpers J7 &
J6 (right side). Connect the USB cable with PC
3.
Change the position of Run/ISP switch 'On' the trainer to ISP mode.
4.
Connect the power cable to the trainer and switch 'On' the power
switch.
5.
Compile program using KEIL compiler and generate hex file LED.hex
6.
7.
8.
Switch 'Off the power supply and change the position of Run/ISP
switch 'On' the trainer to Run mode.
9.
25
Program:
/ *********** Program to blink LEDs **********/
#include <LPC22xx.h>
#include "LED.h"
/* LPC22xx definitions */
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
void main(void)
{
initilise_led();
while (1)
{
blink_led();
}
}
To compile above program, it is necessary to include library file Nvis2294.LIB where
routines blink_led() and initialize_led() are written.
LEDs are connected with port pins P1.16 to P1.23 of LPC-2294 chip. Following
program will also work without using library file Nvis2294.LIB
26
Experiment No.5
Aim: Write program to blink LEDs one by one. Download and execute
program in LPC-2129 chip. Modify this program according to given
instruction in exercise
Program:
#include <LPC21xx.h>
WORKSHEET
Modify above program in such a way that first four LED glow and other four
LEDs remains OFF for a while and then first four LED switched OFF and
other four LEDs becomes ON as shown in following figure (Alternate Nibble
ON-OFF).
27
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Modify program to use pure software delay instead of time delay
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
28
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
29
Experiment No.6
Aim: To write and execute program to display message display
WELCOME GEC RAJKOT on LCD screen for ARM7
LCD data lines are connected with port pins P1.16 to P1.23
Program:
#include <LPC21XX.H>
#define
uchar unsigned char
#define uint unsigned int
#define RS 18
#define EN 19
unsigned char const mcu123[]="WELCOME GEC RAJKOT"
30
{
unsigned char i;
for(i=0;i<8;i++)
{
if(data&1) {Io_Set1(i+16);}
else {Io_Clr1(i+16);}
data=data>>1;
}
}
void delay(unsigned int i)
{
unsigned int k=1000;
while(i>0)
{
i--;
}
while(k>1)k--;
}
void delayms (unsigned int i) {
unsigned int n;
while(i>1)
{
for(n=65535;n>1;n--);
i--;
}
}
void
{
/* Delay function */
delay1s(unsigned char i)
while(i>1)
{
i--;
delayms(20);
}
}
void init_port(void)
{
//port initialized
IODIR1=0x00FF0000;
IODIR0=0x000C0000;
}
31
delay(1);
Io_Set(EN);
delay(1);
Io_Clr(EN);
delay(2);
delayms(10);
/* Enable LCD*/
/* Disable LCD */
}
void DispOneChar(uchar x,uchar y,uchar Wdata) {
LcdWrite_D( Wdata );
}
void disp(uchar x,uchar y,const unsigned char *ptr) {
uchar i,l=0;
while (ptr[l] >31){l++;};
for (i=0;i<l;i++) {
DispOneChar(x++,y,ptr[i]);
if ( x == 16 ){
x = 0; y ^= 1;
}
}
}
void lcdreset(void)
{
LcdWrite_CMD(0x38);
delayms(50);
LcdWrite_CMD( 0x08);
LcdWrite_CMD( 0x01);
LcdWrite_CMD( 0x06);
LcdWrite_CMD( 0x0c);
/* Initialize LCD
}
int main(void)
{
init_port();
delayms(1);
lcdreset();
delay1s(1);
LcdWrite_CMD( 0x80);
disp(0,0,mcu123);
LcdWrite_CMD( 0xC0);
disp(0,1,"E.C. Department");
while(1)
{
}
}
Compile and build above program with Keil compiler and generate
HEX file. Download HEX file in the chip LPC2129 and execute the program
by pressing RESET key
32
WORKSHEET
[1] What are the pins available on the LCD for interfacing with ARM
processor? Describe functions of the pins.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[1] Modify LCD program to display character string Saurashtra on the first
line and University on the second line. Write modified program again.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
33
Experiment No.7
Aim: To read analog input voltage and display it on LCD using LPC-2129
ADC introduction and interfacing details:
10 bit ADC is interfaced with LPC-2294. It is successive approximation type
analog to digital converter with conversion time greater than 2.44 us.
Basic clocking for the A/D converter is provided by the VPB clock. A
programmable divider is included to scale this clock to the 4.5 MHz
(max) clock needed by the successive approximation process. A fully
accurate conversion requires 11 of these clocks. Seven analog input pins are
in LPC2294. The A/D converter includes two registers ADDR and ADCR.
The ADCR register must be written to select the operating mode
before A/D conversion can occur. This ADDR register contains the end of
conversion bit.
Functions of various bits of ADDR and ADCR registers are explained below:
A/D Control Register (ADCR) :
Reset
Value
ADCR
bit
Name
Description
7:0
Sel
0x01
15.8
CLKDIV
16
Burst
34
19:17
CLKS
This field selects the number of clocks used for each conversion
in Burst mode, and the number of bits of accuracy of the result in
the LS bits of ADDR, between 11 clocks (10 bits) and 4 clocks
(3bits): 000=11 clocks/9 bits.... 111=4 clocks/3 bits
21
PDN
23:22
Test1:0
000
When the Burst bit is 0, these bits control whether and when an
A/D conversion is started:000: no start (this value should be
used clearing PDN to 0
001: Start conversion now
26:24
Start
000
27
Edge
35
Name
Description
31
Done
30
OVERUN
29:27
26:24
CHN
23:16
15:6
V/VddA
Reset
Value
36
Procedure:
1.
To program IC via serial port, short the 1-2 pin of the jumpers J7 &
J6 (left side). Connect the serial cable to any functional COM port of
your PC and SP2 (DB-9 Connector) port of the trainer (in PC interface
& ISP section).
2.
To program IC via USB, short the 2-3 pin of the jumpers J7 &
J6 (right side). Connect the USB cable with PC
3.
Change the position of Run/ISP switch 'On' the trainer to ISP mode.
4.
Connect the power cable to the trainer and switch 'On' the power
switch.
5.
6.
7.
Switch 'Off the power supply and change the position of Run/ISP
switch 'On' the trainer to Run mode.
9. Close 1-2 pin of jumper J1 (left side).
10. Switch On the supply, then press reset switch.
8.
<LPC22xx.H>
<LCD.h>
<ADC.h>
<Delay.h>
/* LPC2294 definition */
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
void main(void)
{
adc_initialise();
37
while (1)
{
adc_runmode();
}
}
// Adc.h file
#ifndef ADC_H
#define ADC_H
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
void binbcd(unsigned int );
void adc_initialise(void );
void adc_runmode(void );
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
static unsigned int a,b,c,d,x,y,z;
static unsigned int adcdata;
#endif
:: WORKSHEET ::
[1] What is the advantage of 10 bit ADC over 8 bit ADC?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[2] How many ADC channels are available in LPC-2294 IC?
_____________________________________________________________________
_____________________________________________________________________
[3] Write decimal value displayed on LCD for following input voltage
0.0 V = _________
1 V = ___________
2V=
Resolution of ADC:
3.3V = ____________
______
38
Experiment No.8
Aim: To understand embedded system development using ADSP-2181
kit
Objectives:
Architecture of ADSP-2181:
The ADSP-2181 is a single-chip microcomputer optimized for digital
signal processing (DSP) and other high speed numeric processing
applications. The ADSP-2181 combines the ADSP-2100 family base
architecture (three computational units, data address generators and a
program sequencer) with two serial ports, a 16-bit internal DMA port, a byte
DMA port, a programmable timer, Flag I/O, extensive interrupt capabilities,
and on-chip program and data memory.
The ADSP-2181 integrates 80K bytes of on-chip memory configured as
16K words (24-bit) of program RAM, and 16K word (16-bit) of data RAM.
Power-down circuitry is also provided to meet the low power needs of battery
operated portable equipment. The ADSP-2181 is available in 128-lead TQFP
and 128 lead PQFP packages.
In addition, the ADSP-2181 supports new instructions, which include
bit manipulationsbit set, bit clear, bit toggle, bit test, new ALU constants,
new multiplication instruction (x squared), biased rounding, result free ALU
operations, I/O memory transfers and global interrupt masking for
increased flexibility.
Fabricated in a high speed, double metal, low power, CMOS process,
the ADSP-2181 operates with a 25 ns instruction cycle time. Every
instruction can execute in a single processor cycle. The ADSP-2181s flexible
architecture and comprehensive instruction set allow the processor to
perform multiple operations in parallel.
In one processor cycle the ADSP-2181 can perform following tasks:
Generate the next program address
39
Bus
41
The two address buses (PMA and DMA) share a single external
address bus, allowing memory to be expanded off-chip, and the two data
buses (PMD and DMD) share a single external data bus. Byte memory space
and I/O memory space also share the external buses.
Program memory can store both instructions and data, permitting the
ADSP-2181 to fetch two operands in a single cycle, one from program
memory and one from data memory. The ADSP-2181 can fetch an operand
from program memory and the next instruction in the same cycle. In
addition to the address and data bus for external memory connection, the
ADSP-2181 has a 16-bit Internal DMA port (IDMA port) for connection to
external systems. The IDMA port is made up of 16 data/address pins and
five control pins. The IDMA port provides transparent, direct access to the
DSPs on-chip program and data RAM. An interface to low cost byte-wide
memory is provided by the Byte DMA port (BDMA port). The BDMA port is
bidirectional and can directly address up to four megabytes of external RAM
or ROM for off-chip storage of program overlays or data tables.
Interrupts:
The ADSP-2181 can respond to 13 possible interrupts, eleven of which
are accessible at any given time. There can be up to six external interrupts
(one edge-sensitive, two level-sensitive and three configurable) and seven
internal interrupts generated by the timer, the serial ports (SPORTs), the
Byte DMA port and the power-down circuitry. There is also a master signal.
The two serial ports provide a complete synchronous serial interface
with optional companding in hardware and a wide variety of framed or
frameless data transmit and receive modes of operation. Each port can
generate an internal programmable serial clock or accept an external serial
clock.
The ADSP-2181 provides up to 13 general-purpose flag pins. The data
input and output pins on SPORT1 can be alternatively configured as an
input flag and an output flag. In addition, there are eight flags that are
programmable as inputs or outputs and three flags that are always outputs.
A programmable interval timer generates periodic interrupts. A 16-bit count
register (TCOUNT) is decremented every n processor cycles, where n is a
scaling value stored in an 8-bit register (TSCALE). When the value of the
count register reaches zero, an interrupt is generated and the count register
is reloaded from a 16-bit period register (TPERIOD).
42
Serial Ports:
The ADSP-2181 incorporates two complete synchronous serial ports
(SPORT0 and SPORT1) for serial communications and multiprocessor
communication. Brief list of the capabilities of the ADSP-2181 SPORTs is
given below:
SPORTs are bidirectional and have a separate, double- buffered
transmit and receive section.
SPORTs can use an external serial clock or generate their own serial
clock internally.
SPORTs have independent framing for the receive and transmit
sections. Sections run in a frameless mode or with frame synchronization
signals internally or externally generated. Frame sync signals are active high
or inverted, with either of two pulse widths and timings.
Overview of ADSP-2181 Kit:
ADSP2181 Kit has following features:
Analog Devices ADSP-2181SK-133 processor
Operating at an instruction rate of 33MHz (16.667 external clock)
Analog Audio Interface
- AD1847 Analog Devices stereo codec
Analog Inputs
o One stereo pair of 2V RMS AC coupled line-level inputs
o One stereo pair of 20mV RMS AC coupled microphone
inputs
Analog Outputs
o One stereo pair of 1V RMS AC coupled line-level outputs
Power Source
o 8 to 10V DC at 300mA
RS-232 Interface
43
Board Layout;
44
Remove the EZ-KIT Lite board from the package. Be careful while
handling the board to avoid the discharge of static electricity, which may
damage some components.
Plug the provided cord into a 230 Volt AC receptacle and plug the
connector at the other end of the cable into J4 on the evaluation board.
Visually verify that all of the LEDs light up briefly. The power FL1 blinks.
If the LED does not light (green) LED remains on and up, check the
power connections.
Open Jumper JP2 to GND to enable the AD1847 codec. (This is the board
default).
45
The file loads and the Load Complete message appear in the Output window
when the load process has completed.
Procedure to write and execute program:
Write ADSP program using any text editor and than save it using .dsp
extension.
To link object file to create exe (binary image) file, give following command
>ld21 <object file name> -a <architecture file name with path> -e <output
file name>
For example: >ld21 test -a c:\adi_dsp\macros\2181kit.ach -e test
Example program:
This program generates amplitude modulated waveform using lookup table
{--- choose sampling rate in kHz: ----------------------------------------}
{0xc850 = 8
| 0xc851 = 5.5125 | 0xc852 = 16 }
{0xc853 = 11.025 | 0xc854 = 27.42857 | 0xc855 = 18.9 }
.const fs = 0xc850; {0xc856 = 32
| 0xc857 = 22.05 | 0xc859 = 37.8 }
{0xc85b = 44.1 | 0xc85c = 48
| 0xc85d = 33.075}
{0xc85e = 9.6 | 0xc85f = 6.615
}
.include <c:\adi_dsp\macros\begin.dsp>;
{wrapup}
QUESTIONS
[1] What is the difference between Digital Signal Processor and General
Purpose Microprocessor?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[2] How many pins are there in ADSP-2181. What types of packages are
available?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[3] Which fabrication technology is used for ADSP-2181?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[4] List five internal bus used for efficient data transfer
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
48
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[7] Write features of serial port available in ADSP-2181
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[8] What is function of MAC unit?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[9] Write steps to generate ROM image from the assembly language file
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[10] How DSP programs are downloaded from PC to ADSP-2181 ?
_____________________________________________________________________
_____________________________________________________________________
49
Experiment No. 9
Aim: To generate sine wave, square wave using ADSP-2181
Brief Theory:
To generate sine wave using DSP, look up table is prepared. Magnitude of
samples of sine wave is stored in the look up table hex format. Hex value is
transferred to output port one by one. Output port is connected to digital to
analog converter which provides analog output. Accuracy of sine wave
depends on how many number of samples are used to create it. To smooth
the sine wave output of DAC is passed through low pass filter.
Program:
{
Sine wave generation program
}
.module/RAM/ABS=0
wavegen;
.include <c:\adi_dsp\macros\wavgen.dsp>;
{--- define sampling rate in Khz: ----------------------------------------}
{0xc850 = 8
| 0xc851 = 5.5125 | 0xc852 = 16 }
{0xc853 = 11.025 | 0xc854 = 27.42857 | 0xc855 = 18.9 }
.const fs = 0xc850; {0xc856 = 32
| 0xc857 = 22.05 | 0xc859 = 37.8 }
{0xc85b = 44.1 | 0xc85c = 48
| 0xc85d = 33.075}
{0xc85e = 9.6 | 0xc85f = 6.615 |
}
{-------------------------------------------------------------------------}
.include <c:\adi_dsp\macros\begin.dsp>; { processor initialization.}
{--- define constants, variables, and buffers ----------------------------}
.const D = 4000;
.var/dm/circ sine[D];
.init sine: <sinetbl.hex>;
.const A = 0x1a00;
.const c = 1000;
i6 = ^sine; L6 = %sine;
imask = b#0000110000;
51
imask = b#0000110000;
{enable rx0 interrupt}
{--- start processing input samples --------------------------------------}
wait: idle; jump wait;
WORKSHEET
Observations and waveforms:
Observe sine wave output from the kit at ADC output and plot it in the
following space. Measure amplitude and frequency and mention it on the
waveform.
52
Change sine wave hex table, assemble and link program file again and
observe change in the waveform. Plot modified waveform in the following
space.
QUESTIONS
[1] Explain following instructions for ADSP-2181 processor.
AR=AX0+AY0, AX0=MR2;
AX0=DM(I2,M0), AY0=PM(I4,M6);
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
53
Experiment No.10
Aim: To filter input signal using FIR filter implementation with ADSP-2181
Brief Theory:
In FIR filter, response to impulse becomes zero after a finite number of
samples. Finite duration impulse response filter (FIR) has a system function
of the form:
M 1
H ( z ) b0 b1 z 1 .......... bM 1 z 1 M bn z n
n 0
for 0 n M-1
else where
program
lowpass.dsp
and
link
to
generate
Vary frequency from the function generator and note down amplitude of
the output waveform at different frequency.
54
Program:
{ FIR Low pass filter: lowpass.dsp }
for each input x do:
sD = tap(D, w, p, D)
v0 = a * v1 + sD
u = b0 * v0 + b1 * v1
y=x+u
v1 = v0
*p = y
cdelay(D, w, &p)
}
.const fs = 0xc850;
.include <c:\adi_dsp\macros\begin.dsp>;
.const D = 3000;
.var/dm/circ w[D+1];
i2 = ^w; L2 = %w;
ax0 = 0;
dm(v1) = ax0;
zero(i2, m2, L2);
{--- sample processing algorithm --- process right channel only ----------}
tap(i2, m2, D, mr1);
mx0 = a;
my1 = dm(v1);
{state v1}
55
{mr = b0 * v0}
{mr = u = b0 * v0 + b1 * v1}
{ ay1 = x = input}
{ ar = y = x + u = output}
dm(v1) = sr0;
{ update lowpass filter, v1 = v0}
tapin(i2, m2, ar);
{ put y in tap-0}
cdelay(i2, m2);
{ update delay}
{--- write output samples to codec ---------------------------------------}
dm(tx_buf + 1) = ar;
{ left output sample}
dm(tx_buf + 2) = ar;
{ right output sample}
{--- return from interrupt -----------------------------------------------}
rti;
.include <c:\adi_dsp\macros\end.dsp>;
{wrapup}
WORKSHEET
Observations and waveforms:
Input signal amplitude: Vi = 0.5 Volt
Sr.
No.
Attenuation
(Vo/Vi)
Attenuation
in dB
10log(Vo/Vi)
56
:: WORKSHEET::
[1] Change filter coefficients in the program:
Instead of b0 = 0.2 and b1=0.1 use b0=0.5 and b1=-0.5. Assemble and link
program again. Download ROM image in ADSP kit and run it. Observe
variation in amplitude with frequency.
As per observation by you answer the following question.
What type of filter is implemented? : __________________________________.
[2] What is the difference between FIR filter and IIR filter?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[2] What is the advantage of increasing number of filter coefficients? What is
the disadvantage?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
57
Experiment No. 11
Aim: To understand features of Cypress Programmable System on Chip
(PSoC). To download and execute demo programs to display vertical bar
graph using LEDs depending on analog input voltage.
Introduction:
PSoC is a true programmable embedded system-on-chip integrating
configurable analog and digital peripheral functions, memory and a
microcontroller on a single chip.
It has following features:
Configurable analog and digital circuitry is the basis of the PSoC platform.
We can configure these blocks using pre-built library functions or by
creating our own. By combining several digital blocks, we can create 16-,
24-, or even 32-bit wide logic resources. The analog blocks are composed of
switch capacitor, op-amp, comparator, ADC, DAC, and digital filter blocks,
allowing complex analog signal flows
CPU Subsystem:
PSoC has sophisticated CPU subsystem with SRAM , EEPROM, and flash
memory, multiple core options and a variety of essential system resources
including:
Internal main and low-speed oscillator
Connectivity to external crystal oscillator for precision, programmable
clocking
Sleep and watchdog timers
Multiple clock sources that include a PLL
PSoC devices also have dedicated communication interfaces like I2C, FullSpeed USB 2.0, CAN 2.0, and on-chip debugging capabilities using JTAG
58
and Serial Wire Debug. The newest members of the PSoC family offer
industry-standard processors like the 8051 and ARM Cortex-M3.
We will use PSoC designer software to execute and download programs into
PSoC Device CY8C24894. Program reads analog input voltage which given
by preset available on the board. Depending on preset value, LEDs as
glowing.
Board Section:
PSoC Device:
Project Location:
Top Right
CY8C24894
\Projects\AnalogInputDriveLEDs.app
Procedure:
Step 1. Create a new Project
1.
2.
3.
4.
5.
mode
mode
mode
mode
59
60
else
LED_2_Off();
if(wData>352)
LED_3_On();
else
LED_3_Off();
if(wData>518)
LED_4_On();
else
LED_4_Off();
if(wData>684)
LED_5_On();
else
LED_5_Off();
if(wData>850)
LED_6_On();
else
LED_6_Off();
}
61
Experiment No. 12
Aim: To read analog voltage and display it on LCD using cypress kit
Description:
62
M8C_EnableGInt;
// Enable Global Interrupts
PGA_1_Start(PGA_1_LOWPOWER);
ADCINC_1_Start(ADCINC_1_LOWPOWER); // Apply power to the SC Block
ADCINC_1_GetSamples(0); // Have ADC run continuously
LCD_1_Init();
LCD_1_Start();
// Initialize LCD
LCD_1_Position(1,0); // Place LCD cursor at row 0, col 5.
LCD_1_InitBG(LCD_1_SOLID_BG);
while(1)
{
while(ADCINC_1_fIsDataAvailable() == 0); // Loop until value ready
wData = ADCINC_1_iClearFlagGetData(); // Clear ADC flag and get data
bBarPos = ((float)wData/1024)*80;
LCD_1_DrawBG(0,0,16,bBarPos);
LCD_1_Position(1,0);
// Place LCD cursor at row 1, col 0.
LCD_1_PrHexInt(wData);
}
63
Experiment No.13
Aim: To become familiar with GCC compiler, WinARM and crossware
development tools. To assemble and run programs using crossware
tools
Write your program in the text editor provided in the Linux and save it with
extension .c for C .cpp for C++ and .s for assembly language
Give following command on command line (Dollar sign $ is shell prompt)
$ g++ test.cpp
This command will compile test.cpp file and generates binary file a.out because
we have not specified target file name
To run the program type:
$./a.out
We can also give output file option like following:
$ g++ -o test.o test.cpp
It will generate output file test.o
To run this file in shell prompt:
$ ./test
Write any c++ program and try above commands
Similarly C programs can be compiled by GNU GCC compiler
$ gcc test.c
$ gcc o test test.c
-c option can be specified to compile only (It will compile but not link)
$ gcc c test.c
Stop after assembling. Do not link
(It will not generate executable file. This will check syntax error in the program)
Another option is S.
$ gcc s test.c
This will compile but not assemble and link the program.
-Wall option turn on all warning levels.
$ gcc Wall W test.c
To turn off all the warning use following command (Actually do not use it because it
will not give any warning which is dangerous during programming)
$ gcc w test.c
$ g++ -w test.cpp (For C++)
64
$ as test.s
This will generate a.out file
$ as o test.o test.s (Assembling)
This will generate object file test.o
$ld o test.elf test.o (Linking)
This will generate HEX file test.elf which can be further programmed into
the chip
$ arm-elf-as o test.o test.s (Assemble)
$ arm-elf-ld o test.elf test.o (Link)
We can also define target cpu
$ arm-elf-as cpu=arm7tdmi o test.o test.s
Write following sequence in assembly language for ARM processor and
simulate it using Crossware tool and verify the result.
Program 1:
LOOP:
Program 2:
LOOP:
HERE:
MOV R1,#0x55
MOV R2,#0x33
ADD R3,R1,R2
SUB R4,R1,R2
B LOOP
MOV R0,#0x64
MOV R1,#0x10
ADD R1,R1,#1
CMP R1,R0
BLT LOOP
B HERE
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
65
EXPERIMENT NO. 14
Aim: To interface GSM Modem with PC and Microcontroller.
Objectives:
Introduction:
A GSM modem is a specialized type of modem which accepts a SIM card,
and operates over a subscription to a mobile operator, just like a mobile
phone. From the mobile operator point of view, a GSM modem is just like a
mobile phone.
When a GSM modem is connected to a computer, this allows the computer
to use the GSM modem to communicate over the mobile network. While
these GSM modems are most frequently used to provide mobile internet
connectivity, many of them can also be used for sending and receiving SMS
and MMS messages.
GSM modems support an extended set of AT commands. These extended AT
commands are defined in the GSM standards. With the extended AT
commands, we can do things like:
Procedure:
66
[1] Give call from another mobile to GSM and see response
Response: ___________
Meaning:
[2] AT+CPAS=?
Response: ______________
Meaning:
[3] AT+CSQ=?
Response: _______________
Meaning:
[4] AT+CBC
Response: ________________
Meaning:
[5] AT+CMGR=1
Response:
_______________________________________________________________
_______________________________________________________________
Meaning:
_______________________________________________________________
_______________________________________________________________
[6] AT+CBC
Response: ________________
Meaning:
_______________________________________________________________
_______________________________________________________________
[7] AT+CMGL
Response:
_______________________________________________________________
_______________________________________________________________
67
Meaning:
_______________________________________________________________
_______________________________________________________________
Interface GSM modem with microcontroller and issue AT command
GSM modem is interfaced to microcontroller for wireless control
applications. Once we interface GSM modem with the microcontroller, we
can control devices remotely via another mobile handset. We can also send
data collected by microcontroller to remote place through GSM network.
Circuit diagram:
Vcc
10uF
R/W
4
RS
D0
21
22
23
P3.0(RxD)
P3.1(TxD)
P2.0
P2.1
P2.2
10
12
11
D8
11
R1OUT
T1IN
22 PF
X2
18
X1
20
19
22uF
C1-
15
GND
22 PF
C1+
22uF
1 16
39
38
37
36
35
34
33
32
V+
P0.0/AD0
P0.1/AD1
P0.2/AD2
P0.3/AD3
P0.4/AD4
P0.5/AD5
P0.6/AD6
P0.7/AD7
P1.7
P1.6
P1.5
P1.4
P1.3
P1.2
P1.1
P1.0
16
RING
8
7
6
5
4
3
2
1
VCC
D7
R1IN
MAX232
D1
1K X 8
T1OUT
C2+
C2-
RxD
13
14
GSM
MODEM
TxD
5
5
22uF
V-
89C51
15
RST
GND
DB9 Connector
Serial Port of PC
RESET
10K
31
40
150
EA
VCC
10K
22uF
Program:
;This program sends AT+CMGR=1 command to GSM Modem
;It receives response from GSM Modem and display it on LCD
;Mobile Communication Lab GEC Rajkot
RS EQU P2.1
EN EQU P2.0
RW EQU P2.2
_DATA EQU P1
org 00h
ajmp START
org 03h
reti
org 0bh
reti
org 13h
reti
org 1bh
reti
org 23h
;Vector location for serial Interrupt
ajmp serial
reti
START:
MOV TMOD,#20h
MOV TH1,#0fdh ;Load TH1 with FDh to achieve baud rate 9600
MOV SCON,#50h ;8 bit, 1 stop bit, REN Enabled.
MOV IE,#90h
;Enable serial interrupt
SETB TR1
MOV P1,#00h
;Configure Port 1 as output port
MOV P3,#0ffh
; P3 input port
MOV P0,#00h
; P0 output port
MOV P2,#00h
; P2 output port
MOV A,#38h
;Initialize LCD, 2 lines, 5X7 matrix
lcall command ;Issue command to the LCD
MOV A,#0EH
acall command ;LCD ON, Cursor ON
MOV A,#01H
acall command ;Clear LCD
MOV A,#06H
acall command ;Shift cursor right
MOV A,#01H
acall command ;Clear LCD
acall s_delay
MOV A,#80H
acall command ;Force cursor at begining of the first line
MOV DPTR,#msg1 ;Point to initial message
acall disp_msg
MOV A,#0C0H
acall command
MOV DPTR,#msg2 ;Point to AT Command
send_msg:
acall delay
clr a
movc a,@a+dptr
jz wait
mov sbuf,a
inc dptr
sjmp send_msg
wait:
sjmp wait
command:
push dph
push dpl
mov _data,a
clr RW
acall delay ;Write when when display not busy
clr RS
;Select command register
setb EN
;Set Enable terminal of LCD
nop
nop
clr EN
pop dpl
pop dph
69
ret
disp_data:
push dph
push dpl
clr RW
acall delay
mov _data,a
;Get data for display
setb RS
;Select data register
setb EN
;Enable LCD (Strobe LCD)
nop
nop
clr EN
;Clear Enable and latch data
pop dpl
pop dph
ret
disp_msg:
exit:
acall delay
clr a
movc a,@a+dptr
jz exit
acall disp_data
inc dptr
sjmp disp_msg
ret
serial:
JB TI,transmit
MOV A,SBUF
acall disp_data
CLR RI
RETI
transmit:
CLR TI
RETI
delay:
loop2:
mov r7,#02h
acall s_delay
djnz r7,loop2
ret
s_delay:
loop1:
msg1:
msg2:
mov R6,#0ffh
djnz R6,loop1
ret
db 'GEC RAJKOT',0
db 'AT+CMGR=1',0
END
:: WORKSHEET ::
70
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
71
[2] Write program to flash all LEDs connected at port P0, when somebody
give call to GSM Modem.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
72
[3] Draw interfacing diagram to connect 230V Single phase AC motor with
port pin P2.7. Write a program so that motor should start when incoming
call is coming for the SIM used in GSM modem.
Interfacing diagram:
Program:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
73
:: ASSIGNMENT ::
[1] What is meaning of load and store architecture?
[2] What are the performance matrices for DSP processors?
[3] Why interrupt response is fast in ARM processor?
[4] What is the meaning of T and M in ARM7TDMI architecture?
[5]What is the difference between fixed point and floating point
representation? Explain IEEE floating point format.
[6] Explain how three stage pipeline works
[7] What are the variants of ARM processor?
[8] What do you mean by hardwired implementation?
[9] Which technology is used in ARM7TDMI? What is typical die size?
[10] What is CAN?
[11] Which ARM chip you have used in your practical? What is the size of
RAM and ROM in that chip ?
[12] Give example of two data transfer instructions
[13] What is post indexing and pre indexing?
[14]How exception handling is done in ARM?
[15]Explain branch operations in ARM
[16] Explain instructions LDR r4,[r5,#8]! And LDR r4,[r5,#8]
[17] What is difference between ASR and LSR?
[18] What is the difference between real time operating system and
general purpose operating system?
[19] What is the difference between CISC and RISC processor?
[20] ARM processor is based on which architecture?
[21] What is CPSR and SPSR?
[22] What is the difference between ARM processor and DSP processor?
[23] Explain following instructions:
[a] RSC R1,R2 [b] ADD R1,R2,R2,LSL#1 [c] MLA R1,R2,R3,R4
[24] What is real time operating system?
[25] List applications of Embedded systems
[26] What is watchdog timer?
[27] What is brown out reset?
[28] Write commands to compile C language file and assemble assembly
language file using GNU C compiler and GNU assembler.
[29] What is priority inversion? How it occurs?
[30] Explain deadlock situation. How to prevent deadlock situation?
[31] What is round-robbin scheduling? Is it suitable for real time
applications?
[32] What is job of scheduler?
[33] What is context switching?
[34] What is yield?
[35] What are the special functions of R13, R14 and R15 in ARM
processor?
74