Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
CODE/NAME:EC6711/EMBEDDED LABORATORY
SEMESTER : VII
PREPARED BY
Mr.T.PASUPATHI, AP/ECE
Mrs.P.THIRUMAGAL, AP/ECE
List of Experiments
CYCLE-I
1. Study of ARM evaluation system
2. Interfacing LED.
3. (i) Flashing of LEDS.
(ii)Interfacing PWM.
4. (i)Interfacing ADC.
(ii)Interfacing DAC.
5. (i)Interfacing LCD.
(ii)Interfacing keyboard.
6. (i)Interfacing serial port.
(ii)Interfacing real time clock
CYCLE-II
7. (i)Interfacing stepper motor.
(ii)Interfacing Temperature sensor
8. Implementing zigbee protocol with ARM.
9. Interfacing EPROM and interrupt.
10.Interrupt performance characteristics of ARM and FPGA
11.Mailbox.
CONTENTS
DATE OF MARK
S.NO. TITLE OF THE EXPERIMENT PAGE SIGNATURE
EXPT (10)
CYCLE 1
2 Interfacing LED.
10 Interrupt performance
characteristics of ARM and FPGA
11
Mailbox.
Expt. No:01
STUDY OF ARM EVALUATION SYSTEM
Date:
AIM:
To learn about the evolution, core features, general characteristics and applications of
ARM processors.
THEORY:
The LPC2148 microcontrollers are based on a 32/16 bit ARM7TDMI-S CPU with
realtime emulation and embedded trace support, that combines the microcontroller with
embedded high speed flash memory ranging from 32 kB to 512 kB. A 128-bit wide memory
interface and unique accelerator architecture enable 32-bit code execution at the maximum
clock rate.
Due to their tiny size and low power consumption, LPC2148 are ideal for applications
where miniaturization is a key requirement, such as access control and point-of-sale. A blend
of serial communications interfaces ranging from a USB 2.0 Full Speed device, multiple
UARTS, SPI, SSP to I2Cs and on-chip SRAM of 8kB up to 40kB, make these devices very well
suited for communication gateways and protocol converters, soft modems, voice recognition
and low end imaging, providing both large buffer size and high processing power. Various
32-bit timers, single or dual 10-bit ADC(s), 10-bit DAC, PWM channels and 45 fast GPIO lines
with up to nine edge or level sensitive external interrupt pins make these microcontrollers
particularly suitable for industrial control and medical systems.
FEATURES:
1. CPU operating voltage range of 3.0 V to 3.6 V.
2. One or two (LPC2141/2 vs. LPC2144/6/8) 10-bit A/D converters provide a total
of 6/14 analog inputs, with conversion times as low as 2.44 s per channel.
3. Single 10-bit D/A converter provide variable analog output.
4. 16/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package.
IAR Embedded Workbench is the preferable IDE for this VSK-2148 board.
LANGUAGE FACILITIES:
Support for the C and C++ programming language.
Support for the IAR Extended EC++ with features such as full template support,
namespace,the cast operators static_cast,const_cast and reinterpt_cast,as well as
Standard Template Library (STL).
Conformance to the ISO/ANSI C Standard for a free standing environment.
IEEE Compatible floating point arithmetic.
IAR ASSEMBLER:
The IAR Assembler is integrated with other IAR systems software for the ARM Core. It
is a powerful relocating macro assembler with a versatile set of directives and expression
operators. The assembler features a built-in C-Language preprocessor and supports
conditional assembly.The assembler uses the same mnemonics and operand syntax as the
advanced RISC machines limited Assembler for ARM, which simplifies the migration of the
existing code.
IAR Assembler provides the following Features:
C-Preprocessor
List file with extensive cross-references output.
Number of symbols and program size limited only by available memory.
Support for complex expressions with external references.
255 significant characters in symbol means.
CREATING AN APPLICATION PROJECT USING IAR WORKBENCH:
STEP1:Setting up a new project
Using the IDE, you can design advanced project models. You create a workspace to
which you add one or several projects.
CREATING THE NEW PROJECT
1. To create a new project, choose Project>Create New Project. The Create New
Project dialog box appears, which lets you base your new project on a project
template.
5. Before you add any files to your project, you should save the workspace. Choose
File>Save Workspace and specify where you want to place your workspace file. This
tutorial, you should place it in your newly created projects directory. Type tutorials in
the File name box, and click Save to create the new workspace.
2. Choose Project>Add Files to open a standard browse dialog box. Locate the files
Tutor.c and Utilities.c, select them in the file selection list, and click Open. add them to
the project1
2. Select C/C++ Compiler in the Category list to display the compiler option pages.
Alternatively, click the Compile button in the toolbar or choose the Compile
command from the context menu that appears when you right-click on the selected
file in the Workspace window.
The progress is displayed in the Build messages window.
2. Click OK to save the linker options. Now you should link the object file, to generate
code that can be debugged.
3. Choose Project>Make. The progress will as usual be displayed in the Build messages
window. The result of the linking is a code file project1.out with debug information
located in the Debug\Exe directory and a map file project1.map located in the
Debug\List directory.
ISP UTILITY:
NXP semiconductors produce a range of microcontrollers that feature both on-chip flash
memory and the ability to be reprogrammed using In-System Programming technology.
Flash magic is windows software that allows easy access to all the ISP features provided by
the devices.These features include,
Reading Flash memory
Programminig the flash memory
Erasing the Flash memory
Performing a blank check on a section of flash memory.
Reading the signature bytes.
Flash magic obtains access to the selected COM Port when ISP operations being Performed.
PROCEDURE:
STEP1: Select the COM port
STEP2: Select the baud rate.
STEP3: Select device.
STEP4: Interface –None ISP.
STEP 5: Select Osc-Frequency-12Mhz
STEP6: Enable “Erase blocks used by Hex Files.
STEP 7: Select the Hex File to be downloaded.
VIVA QUESTIONS:
1. Compare Microprocessor and Microcontroller.
RESULT:
Thus the study of ARM Evaluation system and open source software IAR embedded
workbench was done.
THEORY:
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.
LEDs are based on the semiconductor diode. When the diode is forward biased (Switched
on), electrons are able to recombine with holes and energy is released in the form of light.
This effect is called Electroluminescence and color of the light is determined by the energy
gap of the semiconductor.
The ARM7 LPC2148 Primer board has eight numbers of point LEDs, connected with I/O Port
lines (P1.24 – P1.31) to make port pins high. Flash a LED using LPC2148 Primer Board. It
works by turning ON a LED & then turning it OFF & then looping back to START. However the
operating speed of microcontroller is very high so the flashing frequency will also be very
fast to be detected by human eye.
void main()
{
PINSEL2 = 0X00000000; // P1.24 TO P1.31 as GPIO
IO1DIR = 0XFF000000; // p1.24 TO P1.31 Configured as Output port.
while(1)
{
IO1SET=0XFF000000; // P1.24 TO P1.31 goes to high state
delay();
IO1CLR=0XFF000000; // P1.24 TO P1.31 goes to low state
delay();
}
}
PROCEDURE:
STEP1: Create a New project
STEP2: Type the below code and save it with the name (Ex: anyname.c)
OUTPUT:
View the output in LED. It works by turning ON a LED & then turning it OFF & then looping
back to START.
VIVA QUESTIONS:
1. List the application of LED?
RESULT:
Thus the interfacing of LED with ARM7 was done by using embedded C program.
Expt. No.:3.1
FLASHING OF LED’s
Date:
AIM:
To develop a ‘C’ program to flash the LED (including delay routine). Upon change in
the delay program the speed should vary.
APPARATUS REQUIRED:
S.No Description Specification Quantity
5. ARM Processor LPC2148 1 No
6. PC with IAR Embedded --
workbench software.
7. Flash magic --
8. RS232 Cable -- 1 No
THEORY:
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.
LEDs are based on the semiconductor diode. When the diode is forward biased (Switched
on), electrons are able to recombine with holes and energy is released in the form of light.
This effect is called electroluminescence and color of the light is determined by the energy
gap of the semiconductor.
INTERFACING LED:
Fig.3.0 shows how to interface the LED to microcontroller. The Anode is connected through a
resistor to GND & the Cathode is connected to the Microcontroller pin. So when the Port Pin
is HIGH the LED is OFF & when the Port Pin is LOW the LED is turned ON.
Flash a LED using LPC2148 Primer Board. It works by turning ON a LED & then turning it
OFF & then looping back to START. However the operating speed of microcontroller is very
high so the flashing frequency will also be very fast to be detected by human eye.
The ARM7 LPC2148 Primer board has eight numbers of point LEDs, connected with I/O Port
lines (P1.24 – P1.31) to make port pins high.
INTERFACING DIAGRAM:
IO1SET=0X08000000; delay();
IO1CLR=0X08000000; delay();
IO1SET=0X04000000; delay();
IO1CLR=0X04000000; delay();
IO1SET=0X02000000; delay();
IO1CLR=0X02000000; delay();
IO1SET=0X01000000; delay();
IO1CLR=0X01000000; delay(); } }
PROCEDURE:
STEP1: Create a New project
STEP2: Type the below code and save it with the name (Ex: anyname.c)
STEP3: Compile and build the program
STEP4: Burn the code to the device.
STEP5: Compile, Debug & Simulate the above code in IAR.
STEP6: For seeing the output in real-time, select the PROG mode, reset the board and
download the code in board using Flash Magic through UART0.
STEP7: Now change the Mode-Selection-Switch to EXEC position and reset the board.
STEP8: Run/Execute the program on the VSK – 2148 board and observe the LED
blink duration (on/off).
RESULT:
Thus the interfacing and blinking of LED with ARM processor is done successfully
AIM:
To write a C program to generate a PWM and to vary the brightness of the LED
depending on the duty cycle.
APPARATUS & SOFTWARE REQUIRED:
S.No Description Specification Quantity
1. ARM Processor LPC2148 1 No
2. PC with IAR Embedded --
workbench software.
3. Flash magic --
4. RS232 Cable -- 1 No
THEORY:
The PWM is based on the standard timer block and inherits all of its features, although only
the PWM function is pinned out on the LPC2148. The timer is designed to count cycles of the
peripheral clock (PCLK) and optionally generate interrupts or perform other actions when
specified timer values occur, based on seven match registers. The PWM function is also
based on match register events. VLEDD-02 board conned to VSK-2148 using port P4, P5.
Pulse width modulation (PWM) is a powerful technique for controlling analog circuits with a
processor's digital outputs. PWM is employed in a wide variety of applications, ranging from
measurement and communications to power control and conversion.
LPC2148 supports 2 types of PWM :
1) Single Edge PWM – Pulse starts with new Period i.e pulse is always at the beginning
2) Double Edge PWM – Pulse can be anywhere within the Period
A PWM block , like a Timer block , has a Timer Counter and an associated prescale Register
along with Match Registers. These work exactly the same way as in the case of Timers
In LPC214x we have 7 match registers inside the PWM block . Generally the first Match
register PWMMR0 is used to generate PWM period and hence we are left with 6 Match
Registers PWMMR1 to PWMMR6 to generate 6 Single Edge PWM signals or 3 Double Edge
PWM signals. Double edge PWM uses 2 match registers hence we can get only 3 double edge
outputs. The way this works in case of Single Edge PWM is as follows (and similarly for
Double Edge):
Following figure shows three different PWM signals. One is PWM output at a 25% duty cycle.
That is, the signal is on for 25% of the period and off the other 75%. Next shows PWM
output at 50%, 75% duty cycles, respectively.
PROGRAM:
/* - - - - - Header Files - - - - - */
#include<nxp\iolpc2148.h>
/* - - - - - User Defined Variables - - - - - */
int x;
/* - - - - - delay Routine - - - - - */
void delay()
{
for( int i=0;i<=1500;i++);
}
/* - - - - - PWM function - - - - - */
void pwm(int x)
{
PINSEL0 = 0X00088005; /* To select Port pin P0.8 and also p0.9 as pwm4 and pwm6
*/
PWMPR = 0X00000000; /* To set Prescaler register value to one */
PWMPCR = 0X00004400; /* To select pwm2 as single edge controlled */
PWMMCR = 0X00000002; /* To Reset pwm timer counter when matches occur */
PWMMR0 = 1200 ; /* To set total time period of pwm output */
PWMMR2 = x;
PWMMR6 = 600;
PWMTCR = 0X00000002; /* To reset pwm timer */
PWMTCR = 0X00000009;
}
/* - - - - - main function starts here - - - - - */
void main()
{
PINSEL1_bit.P0_21=1;
IO0DIR_bit.P0_21=1;
PINSEL2 = 0X00000000;
IO1DIR = 0XFF000000;
int i;
while(1)
{
for(i=0;i<=1200;i++)
{
pwm(x);
delay();
x=x+1;
if(i>=1200)
{
x=0;
}
}
}
}
PROCEDURE:
STEP1. Create a New project
STEP2. Type the below code and save it with the name anyname.c
STEP3. Compile and build the program
STEP4. Burn the code to the device.
STEP5. Connect VLEDD-02 external board and connect J2 to P5(i/p) to view the
output.
STEP6. Compile, Debug & Simulate the above code in IAR.
STEP7. Connect the RS232 cable/USB cable provided to the PC/Laptop and the VSK-
2148 Board, and Power on the Board.
STEP8. For seeing the output in real-time, select the PROG mode, reset the board and
download the code on to the board using Flash Magic through UART0/USB.
STEP9. Now change the Mode-Selection-Switch to EXEC position and reset the board.
STEP10. Press the Switch and we can observe the variation in the intensity of the LEDs
depending on the duty cycle of the PWM
OUTPUT:
Press the SW20 switch (VLEDD-02) and view the output in VLEDD-02.
VIVA QUESTIONS:
1. List the application of LED?
4. Define PWM
RESULT:
Thus the interfacing of LED and PWM with ARM DEVELOPMENT KIT was done by using
embedded C program.
THEORY:
ANALOG TO DIGITAL CONVERTER:
The analog to digital converter that which has a purpose to convert the analog input signal to
binary value that can be easily further processed or handle by microcontroller or
microprocessor.
The conversion is divided in to two parts
1) Quantization 2) Sampling
Quantization is the process of converting a continuous range of values (analog signal) into a
finite range of discreet values (digital numbers or Binary form).
The conversion involves of the input, so it necessarily introduces a small amount of error.
Sampling of input signal means to take ADC does the conversion periodically or repeatedly
after definite time periods rather than continuously. The result will gives a discrete-time and
discrete-amplitude digital signal from a continuous-time and continuous-amplitude analog
signal.
NEED of ADCs.
In our daily life, we have seen sensors and that are input devices, there are several sensors
that gives only analog or continuous values. Most of the time these values must be processed
and can be further shown output devices LCDs and 7-Segment as per user requirement. ADC
is used to convert analog (continuous) values to discrete (digital) values. Below are common
analog sensors which are used for different purposes.
1) Temperature Sensor
2) Glucose meter
3) Blood meter.
4) Speed Sensor etc.
Common ADC conversion Terminologies adopted by semiconductors companies:
1) Successive Approximation Methods
2) Delta-Sigma ADCs
3) Dual Slop ADCs
LPC2148 has 10-bit successive approximation ADC. Basic clocking for the A/D converter is
provided by the VPB clock. A Programmable divider is included in each converter to scale
this clock to 4.5 Mhz clock needed by the successive approximation process. A fully accurate
conversion requires 11 of these clocks
The LPC 2148 has 10-bit successive approximation analog to digital converter. Basic
clocking for the A/D converters is provided by the VPB clock. A programmable divider is
included in each converter, 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.
The ADC cell can measure the voltage on any of the ADC input signals.
VSK-2148 has one potentiometer for working with A/D Converter. Potentiometer outputs
are in the range of 0V to 3.3V.
Short the J4 jumper for reading the Potentiometer value by ADC.
PROGRAM:
#include<nxp/iolpc2148.h>
#include<stdio.h>
#define DESIRED_BAUDRATE 9600
#define CRYSTAL_FREQUENCY_IN_HZ 120000000
#define PCLK CRYSTAL_FREQUENCY_IN_HZ
#define DIVISOR (PCLK/(16*DESIRED_BAUDRATE))
int putchar(int a)
{
while(!(U0THR&0X20));
return(U0THR=a);
}
void ADC_init()
{
AD0CR_bit.SEL=2;
AD0CR_bit.CLKDIV=12000000/4500000;
AD0CR_bit.BURST=1;
AD0CR_bit.CLKS=0;
AD0CR_bit.PDN=1;
AD0CR_bit.START=0x0001;
}
void Arm_Uart0_Init()
{
U0LCR=0x83;
VPBDIV=0x01;
U0DLL=DIVISOR&0xff;
U0DLM=DIVISOR>>8;
U0LCR=0x03;
U0FCR=0x05;
}
void main()
{
float ADCresult;
PINSEL0=0X00000005;
PINSEL1=0x01000000;
Arm_Uart0_Init();
ADC_init();
while(1)
{
while(AD0DR_bit.DONE==0);
ADCresult=(AD0DR>>6)& 0x3ff;
}
OUTPUT:
View the output in PC-Hyper Terminal
RESULT:
Thus the interfacing of ADC (In-built) with ARM processor has been verified and observed
the output successfully.
THEORY:
DIGITAL ANALOG CONVERTER:
The two 10-bit buffered DAC channels can be used to convert digital signals into analog
voltage signal outputs.
The features of the DAC in LPC2148 are
10 bit digital to analog converter
Buffered output
Power-down mode
PROGRAM:
/* - - - - - Header Files - - - - - */
#include<nxp/iolpc2148.h>
/*The settling time of the DAC is 2.5 μs and the maximum current is 350 μA when BIAS=1*/
#define DAC_BIAS 0x00010000
/* - - - - - delay routine - - - - - */
void delay(unsigned int x)
{
for(int i=0;i<=x;i++);
}
/* - - - - - main function - - - - -*/
void main()
{
PINSEL1=0X00080000;
while(1)
{
/* The Datas has to be passed or moved on to the VALUE bits i.e 15 - 6 and the result
will be (VALUE/(1024*Vref)) */
DACR = (1023 << 6) | DAC_BIAS;
delay(100000);
delay(100000);
delay(100000);
delay(100000);
/* The Datas has to be passed or moved on to the VALUE bits i.e 15 - 6 and the
result will be (VALUE/(1024*Vref)) */
DACR = (0 << 6) | DAC_BIAS;
delay(100000);
delay(100000);
delay(100000);
delay(100000);
}
}
OUTPUT:
Output pin is connected in P9.
VIVA QUESTIONS:
1.What is ADC?
RESULT:
Thus the interfacing of DAC (In-built) with ARM processor has been verified and observed
the output successfully.
Expt. No.:5.1
LCD INTERFACING
Date:
AIM:
To interface LCD with ARM processor.
APPARATUS REQUIRED:
S.No Description Specification Quantity
1. ARM Processor LPC2148 1 No
2. PC with IAR Embedded --
workbench software.
3. Flash magic --
4. RS232 Cable -- 1 No
THEORY:
The LCD is an output device and abbreviated as Liquid Crystal Display. LCD is now a very
common option for graphical and alphanumeric displays. In our daily life, we can
alphanumeric displays LCD on coffee machine, cash register, weighing machine and
calculator as consumer electronics embedded products.
LCD CLASSIFICATIONS:
LCDs are generally two type character and graphic LCDs.
Graphical LCDs are again subdivided in two categories: Monochrome (Black and White) and
Color graphical LCD. Here we will discuss about Character LCDs. Character LCDs are those
which have ability to display numbers, alphabetical characters, special characters,
customized character (created by user). LCDs are available in different sizes common format
are LCD Row x Column LCD 16 x 1, LCD 16 x 2, LCD 20 x 2, LCD 40x 4. The display is a
standard LM016L which displays 2 lines of 16 characters (16 x 2)
ADVANTAGES OF LCD:
LCD is easy to program for character and graphics
The circuit having is much smaller and lighter than from LED or seven segment
Due to easy availability with low prices, LCD is preferable then from LEDs
There is no issue of refreshing LCD because it has its own controller.
They are low power and comparatively flexible in their use.
The ability to display various format like display numbers, alphabetical characters,
special characters, customized character (created by user) with graphic on graphic
LCD.
D0 – D7:
The 8-bit data pins, are used to send information to the LCD or read the contents of the
LCD’s internal registers. To display letters and numbers, we send ASCII codes for the letters
A-Z, a-z, and numbers 0-9 to these pins while making RS = 1.
CIRCUIT DIAGRAM-LCD INTERFACING:
D3 :Connected to P1.19
D4 :Connected to P1.20
D5 :Connected to P1.21
D6 :Connected to P1.22
D7 :Connected to P1.23
PROGRAM:LCD INTERFACING:
#include <nxp/iolpc2148.h>
#define LCD_EN 0X00000800
#define RS 0X00000100
#define DIOW 0X00000200
unsigned char arr1[16]="KCE ECE ERTS LAB";
unsigned char arr2[16]=" THANJAVUR ";
void delay_ms()
{
unsigned int i,j;
for(j=0;j<0xf;j++)
for(i=0;i<0xff;i++);
}
void busy_check()
{
delay_ms();
}
void command_write(int comm)
{
busy_check();
IO0CLR = RS;
IO0CLR = DIOW;
IO1PIN = comm<<16;
IO0SET = LCD_EN;
IO0CLR = LCD_EN;
}
void lcd_init()
{
command_write(0x38); // 5 * 7 Matrix
command_write(0x01); // Clear Display
command_write(0x0f); // Display ON and Cursor Blinking
command_write(0x86); // 5 * 7 Matrix
command_write(0x06);
}
void lcd_out(unsigned char z)
{
busy_check();
IO0SET = RS; //RS = 1
IO0CLR = DIOW;
IO1PIN = (z<<16); //data with Rs=1
IO0SET = LCD_EN;
IO0CLR = LCD_EN;
}
void main()
{
PINSEL2=0x00000000;
IO0DIR =0xffffffff; // RS, DIOW & LCDEN - Output Pins
IO1DIR =0xFFFFFFFF; // LCD0 to LCD7 - Output Pins
IO0DIR =0x5FFF7FFF;
IO1DIR =0xFFFFFFFF;
IO0CLR = 0X00000800;
IO1PIN = 0X00000000;
IO0PIN = 0X00000000;
IO0CLR = RS;
IO0CLR = DIOW;
IO0CLR = LCD_EN;
lcd_init();
command_write(0x80);
for(int i=0;i<16;i++)
lcd_out(arr1[i]);
command_write(0xC0);
for(int i=0;i<16;i++)
lcd_out(arr2[i]);
while(1);
}
PROCEDURE:
STEP 1. Create a New project
STEP 2. Type the below code and save it with the name anyname.c
STEP 3. Compile and build the program
STEP 4. Download the Code to Controller.
STEP 5. Compile, Debug & Simulate the above code in IAR.
STEP 6. For seeing the output in real-time, select the PROG mode, reset the board and
download the code in the board using Flash Magic through UART0.
STEP 7. Now change the Mode-Selection-Switch to EXEC position and reset the board.
STEP 8. Now observe the output in LCD of ARM7 kit.
VIVA QUESTIONS:
3. What are the ports used for Keypad interfacing with LPC2148.
RESULT:
Thus the interfacing of LCD with ARM7 microcontroller using embedded C program
has been verified successfully.
Expt. No.:5.2
KEYPAD INTERFACING WITH ARM
Date:
AIM:
To interface Keypad with ARM processor.
APPARATUS REQUIRED:
S.No Description Specification Quantity
1. ARM Processor LPC2148 1 No
2. PC with IAR Embedded --
workbench software.
3. Flash magic --
4. RS232 Cable -- 1 No
THEORY:
KEYPAD
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. 1 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. 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.
#include<nxp/iolpc2148.h>
#define DESIRED_BAUDRATE 19200
#define CRYSTAL_FREQUENCY_IN_HZ 12000000
#define PCLK CRYSTAL_FREQUENCY_IN_HZ
#define DIVISOR (PCLK/(16*DESIRED_BAUDRATE))
void delay_ms()
{
int i,j;
for(i=0;i<=0xff;i++)
for(j=0;j<=0xf0;j++);
}
int putchar(char ch)
{
if (ch=='\n')
{
while (!(U0LSR&0x20));
U0THR='\r';
}
while (!(U0LSR&0x20)) {}
U0THR=ch;
return ch;
}
void Arm_Uart0_Init()
{
U0LCR=0x83;
VPBDIV=0x01;
U0DLL=DIVISOR&0xFF;
U0DLM=DIVISOR>>8;
U0LCR=0x03 ;
U0FCR=0x05 ;
}
void main()
{
PINSEL0 = 0x00000005;
PINSEL2 = 0x00000000;
IO0DIR = 0X00F00005;
Arm_Uart0_Init();
printf("\n\r 4 x 4 Matrix Key Pad Interface ");
printf("\n\r Press any Key Pad Interface ");
while(1)
{
IO0PIN=0x00E00000; // First Scan Line
if(( IO0PIN & 0x000F0000 )!= 0x000F0000)
{
switch(IO0PIN & 0x000F0000)
{
case 0x00070000 : printf("F");break;
case 0x000B0000 : printf("B");break;
case 0x000D0000 : printf("7");break;
case 0x000E0000 : printf("3");break;
}
}
IO0PIN=0x00D00000;
STEP 6. Connect the RS232 cable / USB cable provided to the PC / Laptop and the VSK -
2148 Board, and Power on the Board.
STEP 7. For seeing the output in real-time, select the PROG mode, reset the board and
download the code in the board using Flash Magic through UART0.
STEP 8. Now change the Mode-Selection-Switch to EXEC position and reset the board.
STEP 9. Press the keys in keypad and observe the output in LCD.
RESULT:
Thus the interfacing of keypad was verified successfully.
THEORY:
The Real Time Clock (RTC) is a set of counters for measuring time when system power
is on, and optionally when it is off. It uses little power in Power-down mode. On the
LPC2141/2/4/6/8, the RTC can be clocked by a separate 32.768 KHz oscillator, or by a
programmable prescale divider based on the VPB clock. Also, the RTC is powered by its own
power supply pin, VBAT, which can be connected to a battery or to the same 3.3 V supply
used by the rest of the device.
PROGRAM:
#include<nxp/iolcp2148.h>
Void delay()
{
For(ini i=0;i<5000;i++)
}
Voidcmd_write(int X)
{
IO1PIN=X<<16;
IO0SET=(1<<8);
IO0CLR=(1<<9);
IO0CLR=(1<<11);
IO0SET=(1<<11);
delay();
IO0CLR=(1<<11);
}
voiddata_write(int X)
{
IO1PIN=X<<16;
IO0SET=(1<<8);
IO0CLR=(1<<9);
IO0CLR=(1<<11);
IO0SET=(1<<11);
delay();
IO0CLR=(1<<11);
}
void main()
PINSEL2=0X00000000;
IO1DIR=0X00FF0000;
PINSEL0=0X00000000;
IO0DIR=0X00000B00;
cmd_write(0X38);
cmd_write(0X01);
cmd_write(0X0F);
cmd_write(0X06);
cmd_write(0X82);
data_write(‘K’);
int h,m,s,h1,h2,m1,m2,s1,s2;
HOUR=02;
MIN=25;
SEC=00;
CCR=0X11;
for(;;)
{
h=HOUR;
m=MIN;
s=SEC;
h1=(h/10);
h2=(h%10);
m1=(m/10);
m2=(m%10);
s2=(s/10);
s2=(s%10);
cmd_write(0X80);
data_write(h1+0X30);
data_write(h2+0X30);
data_write(‘:’);
data_write(m1+0X30);
data_write(m1+0X30);
data_write(‘:’);
data_write(s1+0X30);
data_write(s1+0X30);
}
PROCEDURE:
STEP 1. Create a New project
STEP 2. Type the code and save it with the name anyname.c
STEP 3. Compile and build the program
STEP 4. Download a Code to the Controller
STEP 5. Compile, Debug & Simulate the above code in IAR.
STEP 6. Connect the RS232 cable / USB cable provided to the PC / Laptop and the VSK -
2148 Board, and Power on the Board.
STEP 7. For seeing the output in real-time, select the PROG mode, reset the board and
download the code in the board using Flash Magic through UART0.
STEP 8. Now change the Mode-Selection-Switch to EXEC position and reset the board.
STEP 9. Now observe the output in LCD, it should display the digital clock running
VIVA QUESTIONS:
1. What are Real Time Clocks?
RESULT:
THEORY:
UART- RS-232 COMMUNICATION
There are two basic types of serial communications,
(i) Synchronous and
(ii) Asynchronous.
With synchronous communications, the two devices initially synchronize themselves to each
other, and then continually send characters to stay in sync. Even when data is not really
being sent, a constant flow of bits allows each device to know where the other is at any given
time. That is, each character that is sent is either actual data or an idle character.
Synchronous communications allows faster data transfer rates than asynchronous methods,
because additional bits to mark the beginning and end of each data byte are not required.
Data-bits
CLK
Start-bit Stop-bit
INTERFACING DIAGRAM:
VPBDIV=0x01;
U0DLL=DIVISOR&0xFF;
U0DLM=DIVISOR>>8;
U0LCR=0x03 ;
U0FCR=0x05 ;
}
void main ()
{
int i;
Arm_Uart0_Init();
while(1)
{
for(i=0;arr[i]!='\0';i++)
{
serial_tr(arr[i]);
}
}
}
PROCEDURE:
STEP 1. Create a New project
STEP 2. Type the code and save it with the name anyname.c
STEP 3. Compile and build the program
STEP 4. Download a Code to the Controller
STEP 5. Compile, Debug & Simulate the above code in IAR.
STEP 6. Connect the RS232 cable / USB cable provided to the PC / Laptop and the VSK -
2148 Board, and Power on the Board.
STEP 7. For seeing the output in real-time, select the PROG mode, reset the board and
download the code in the board using Flash Magic through UART0.
STEP 8. Now change the Mode-Selection-Switch to EXEC position and reset the board.
STEP 9. Open Win X- Talk, Select COM port and Baud rate as 9600
STEP 10. Now observe the output data in the PC, it should display the data.
VIVA QUESTIONS:
1. Mention what are the essential components of embedded system?
RESULT:
Thus the interfacing of UART was verified successfully.
THEORY:
Stepper motors, effectively have multiple "toothed" electromagnets arranged around a
central metal gear. To make the motor shaft turn, first one electromagnet is given power,
which makes the gear's teeth magnetically attracted to the electromagnet's teeth. When the
gear's teeth are thus aligned to the first electromagnet, they are slightly offset from the next
electromagnet. So when the next electromagnet is turned on and the first will turn off, the
gear rotates slightly to align with the next one and from there the process is repeated. Each
of those slight rotations is called a "step." In that way, the motor can be turned to a precised
angle. There are two basic arrangements for the electromagnetic coils: bipolar and unipolar.
Interfacing diagram:
Jumper Position
Procedure
STEP1. Create a New project
STEP2. Type the code and save it with the name anyname.c
STEP3. Compile and build the program
STEP4. Download a Code to the Controller
STEP5. Compile, Debug & Simulate the above code in IAR.
STEP6. Connect the RS232 cable / USB cable provided to the PC / Laptop and the VSK -
2148 Board, and Power on the Board.
STEP7. For seeing the output in real-time, select the PROG mode, reset the board and
download the code in the board using Flash Magic through UART0.
STEP8. Now change the Mode-Selection-Switch to EXEC position and reset the board.
STEP9. Now connect/interface the stepper motor at the motor port available in the
VSK -2148 Board with proper polarity.
STEP10. The stepper motor will rotate in the forward and reverse direction.
Program
/* - - - - Header files - - - - */
#include<nxp/iolpc2148.h>
/* - - - - - delay routine - - - - - */
void delay()
{
int i;
for(i=0;i<5000;i++);
}
/* - - - - - stepper motor functions - - - - - */
/* - - - - - forward rotation - - - - - */
void fwd()
{
IO0PIN = 0X90;
delay();
IO0PIN = 0X50;
delay();
IO0PIN = 0X60;
delay();
IO0PIN = 0XA0;
delay();
}
/* - - - - - reverse rotation - - - - - */
void rev()
{
IO0PIN = 0XA0;
delay();
IO0PIN = 0X60;
delay();
IO0PIN = 0X50;
delay();
IO0PIN = 0X90;
delay();
}
void main()
{
IO0DIR=0xF0; //Set port line as output port
for(int i=0;i<=50;i++)
{
fwd();
}
for(int i=0;i<=50;i++)
{
rev();
} }
OUTPUT:
Stepper motor terminal are connect to P10 connector.
RESULT:
Thus, the interfacing of stepper motor with ARM7 processor has been done.
AIM:
To write C Programs to observe the variation in the temperature sensor.
APPARATUS & SOFTWARE REQUIRED:
S.No Description Specification Quantity
1. ARM Processor LPC2148 1 No
2. PC with IAR Embedded --
workbench software.
3. Flash magic --
4. RS232 Cable -- 1 No
THEORY:
Temperature Sensor
The temperature sensor that is used here is LM35. The LM35 series are precision
integrated-circuit temperature sensors, whose output voltage is linearly proportional to the
Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature
sensors calibrated in ° Kelvin, as the user is not required to subtract a large constant voltage
from its output to obtain convenient Centigrade scaling. The LM35 does not require any
external calibration.
PROCEDURE:
STEP 1. Create a New project
STEP 2. Type the code and save it with the name anyname.c
STEP 3. Compile and build the program
STEP 4. Download a Code to the Controller
STEP 5. Compile, Debug & Simulate the above code in IAR.
STEP 6. Connect the RS232 cable / USB cable provided to the PC / Laptop and the VSK –
2148 Board, and Power on the Board.
STEP 7. For seeing the output in real-time, select the PROG mode, reset the board and
download the code in the board using Flash Magic through UART0.
STEP 8. Now change the Mode-Selection-Switch to EXEC position and reset the board.
STEP 9. Now check the jumpers J4 and J6. Jumper J4 has to be left opened whereas
jumper J6 has to be closed.
STEP 10. Open Win X- Talk and select the COM port and the desired baud rate as 9600.
STEP 11. Heat the temperature sensor to view the variation in the temperature
PROGRAM:
#include<nxp/iolpc2148.h>
#include<stdio.h>
#define DESIRED_BAUDRATE 9600
#define CRYSTAL_FREQUENCY_IN_HZ 120000000
Arm_Uart0_Init();
ADC_init();
while(1)
{
while(AD0DR_bit.DONE==0);
ADCresult=(AD0DR>>6)& 0x3ff;
printf("\n\r Temperature value ----->%f",ADCresult*0.097);
}
}
OUTPUT:
change the jumper setting close the J6 and open the J4 jumer.
View the output in PC-Hyper Terminal Link.
VIVA QUESTIONS:
1.Write a short note on stepper motor.
RESULT:
Thus, the interfacing of temperature sensor with ARM7 processor has been done and
executed the temperature value.
Expt. No.: 8
Date: IMPLEMENTING ZIGBEE PROTOCOL WITH ARM
AIM:
To implement the wireless protocol with ARM
APPARATUS AND SOFTWARE REQUIRED:
S.No Description Specification Quantity
1. ARM Processor LPC2148 1 No
2. PC with IAR Embedded --
workbench software.
3. Flash magic --
4. RS232 Cable -- 1 No
5. Xbee modules -- 2 Nos
THEORY:
The X Bee/X Bee-PRO ZNet 2.5 (formerly known as Series 2 and Series 2 PRO) RF
Modules were directed to operate within the ZigBee protocol. The modules provide reliable
delivery of data between remote devices. Zigbee is the communication protocol like wifi and
Bluetooth. Xbee is the module using Zigbee protocol
SOME OF ITS FEATURES ARE:
STEP 1. ZigBee is targeted at radio-frequency (RF) applications
STEP 2. Low data rate, long battery life, and secure networking
STEP 3. Transmission range is between 10 and 75 meters (33~246 feet)
STEP 4. The addressing space allows of extreme node density—up to
18,450,000,000,000,000,000 devices (64 bit IEEE address) using local
addressing, simple networks of more than 65,000 nodes can be configured,
with reduced address overhead
STEP 5. The radios use direct-sequence spread spectrum coding, which is managed by
the digital stream into the modulator.
STEP 6. To ensure reliable data transmission
STEP 7. Binary phase shift keying (BPSK) in the 868/915 MHz
STEP 8. Offset quadrature phase shift keying (O-QPSK) at 2.4 GHz
{
long int i;
for(i=0;i<50000;i++);
}
/* - - - - - main function - - - - - */
void main()
{
PINSEL2 = 0x00000000; /* P0.16 TO P0.23 Configured as GPIO. */
IO0DIR = 0X00F00F05; /* P0.20 TO P0.23 (O/P), P0.16 TO P0.19(I/P) */
IO1DIR=0x00ff0000;
uart_inital();
printf("\n\r 4 x 4 Matrix Key Pad Interface ");
printf("\n\r Press any Key Pad Interface ");
while(1)
{
IO0PIN=0x00E00000; /* Scan First Line */
if(( IO0PIN & 0x000F0000 )!= 0x000F0000) /* Check if any key is pressed in
4th row */
{
switch(IO0PIN & 0x000F0000) /* Check which one of the key is pressed */
{#include<nxp/iolpc2148.h>
#include<stdio.h>
void timer0_conf()
{
VPBDIV = 0X01; //12MHZ
T0TCR = 0X00; //STOP TIMER
T0PR = 0X12000; //load prescasle or timer value
T0TCR = 0X02; //reset timer0
}
void uart0_conf()
{
PINSEL0 = 0X05;
VPBDIV = 0X01;
U0LCR = 0X83; // 8bit data,divisior latch
U0DLL = 0X4E; //9600 baudrate
U0DLM = 0X00; //msb
U0LCR = 0X03; //8bit data
void main()
{
PINSEL1 = 0X00000000;
IO0DIR = 0X00F00005; //P0.20 t0 P0.23 as o/p or P0.16 t0 P0.20 as i/P
timer0_conf();
uart0_conf();
while(1)
{
IO0PIN=0x00E00000; // First Scan Line
if(( IO0PIN & 0x000F0000 )!= 0x000F0000) //Check if any key is pressed in //4th row
{
switch(IO0PIN & 0x000F0000) //Check which one of the key is pressed
{
case 0x00070000 :
printf("F");
break;
case 0x000B0000 :
printf("B");
break;
case 0x000D0000 :
printf("7");
break;
case 0x000E0000 :
printf("3");
break;
}
}
IO0PIN=0x00D00000; //Move second data to scan line
if(( IO0PIN & 0x000F0000 )!= 0x000F0000) //Check if any key is pressed in 3rd row.
{
switch(IO0PIN & 0x000F0000) //check which one of the key is pressed
{
case 0x00070000 :
printf("E");
break;
case 0x000B0000 :
printf("A");
break;
case 0x000D0000 :
printf("6");
break;
case 0x000E0000 :
printf("2");
break;
}
}
IO0PIN=0x00B00000; //Move 3rd scan data to port line
if(( IO0PIN & 0x000F0000 )!= 0x0F000000)//Scan any key is pressed in 2nd row
{
switch(IO0PIN & 0x000F0000) //Check which one of the key is pressed in 2nd row
{
case 0x00070000 :
printf("D");
break;
case 0x000B0000 :
printf("9");
break;
case 0x000D0000 :
printf("5");
break;
case 0x000E0000 :
printf("1");
break;
}
}
IO0PIN=0x00700000; //Move 4th scan data to port line
if(( IO0PIN & 0x000F0000 )!= 0x000F0000) //Check any key is pressed in 1st row
{
switch(IO0PIN & 0x000F0000) //Check which one of the key is pressed in 1st row
{
case 0x00070000 :
printf("C");
break;
case 0x000B0000 :
printf("8");
break;
case 0x000D0000 :
printf("4");
break;
case 0x000E0000 :
printf("0");
break;
}
}
}
}
RX PROGRAM:
#include<nxp/iolpc2148.h>
void uart0_conf()
{
VPBDIV = 0X01; //12Mhz clk
U0LCR = 0X83; //8bit data,
U0DLL = 0X4E; //9600 baudrate LSB
}}
OUTPUT:
Xbee board are connected to P2 connector.
Input is using matrix keyboard.
View the output in onboard LED.
VIVA QUESTIONS:
1. What are the features of XBee ZNet 2.5 Modules.
RESULT:
Thus the implementation of ZigBee protocol with ARM7 processor board using embedded C
program has been done.
Expt. No.: 9
INTERFACING EEPROM AND INTERRUPT.
Date:
AIM:
To develop a C-Language program to write and read a data in EEPROM and also to analyze its
performance with the interrupt
APPARATUS & SOFTWARE REQUIRED:
S.No Description Specification Quantity
1. ARM Processor LPC2148 1 No
2. PC with IAR Embedded --
workbench software.
3. Flash magic --
4. RS232 Cable -- 1 No
THEORY:
Serial-interface EEPROM’s are used in a broad spectrum of consumer, automotive,
telecommunication, medical, industrial and PC related markets. Primarily used to store
personal preference data and configuration/setup data, Serial EEPROM’s are the most
flexible type of nonvolatile memory utilized today. Compared to other NVM solutions, Serial
EEPROM devices offer a lower pin count, smaller packages, lower voltages, as well as lower
power consumption.
EEPROM (electrically erasable programmable read - only memory) is user-modifiable read-
only memory (ROM) that can be erased and reprogrammed (written to) repeatedly through
the application of higher than normal electrical voltage. It is a type of non-volatile memory
used in computers and other electronic devices to store small amounts of data that must be
saved when power is removed, e.g., calibration tables or device configuration.
void TIMER1(void);
#include "int.h"
#include "uart.h"
#include "timer.h"
/* - - - - - main function starts here - - - - - */
void main()
{
uart_init(); /* call the uart initialization function. Function definition is in “uart.h” */
timer_config(); /* call the timer configuration function. Function definition is in
“timer.h”*/
timerenable(); /* call the timer interrupt function. Function definition is in “int.h” */
while(1)
{
printf("\n Welcome... ");
}
}
OUTPUT:
VIVA QUESTIONS:
1.Write a short note on interrupts.
RESULT:
Expt. No.:10
INTERRUPT PERFORMANCE CHARACTERISTICS OF ARM AND FPGA
Date:
AIM:
To study about the Interrupt performance characteristics between ARM and FPGA
THEORY;
The ARM7 CPU has two external interrupt lines for the fast interrupt request (FIQ) and
general purpose interrupt IRQ request modes. As a generalization, in an ARM7 system there
should only be one interrupt source which generates an FIQ interrupt so that the processor
can enter this mode and start processing the interrupt as fast as possible. This means that all
the other interrupt sources must be connected to the IRQ interrupt. In a simple system they
could be connected through a large OR gate. This would mean that when an interrupt was
asserted the CPU would have to check each peripheral in order to determine the source of
the interrupt. This could take many cycles. Clearly a more sophisticated approach is
required. In order to handle the external interrupts efficiently an on-chip module called the
Vector Interrupt Controller (VIC) has been added.
STEP 2. Type the below code and save it with the name led.c (anyname.c)
STEP 3. Compile and build the program
STEP 4. Burn the program in controller.
PROGRAM:
#include<nxp\iolpc2148.h>
#include<stdio.h>
#include "intrinsics.h"
#define led1 IO0PIN_bit.P0_12
#define led2 IO0PIN_bit.P0_13
void TIMER0(void);
void TIMER1(void);
#pragma vector=0x18
__irq __arm void irq_handler (void)
{
void (*intrrupt_function)();
unsigned int vector;
vector = VICVectAddr;
intrrupt_function = (void(*)())vector;
(*intrrupt_function)();
VICVectAddr = 0;
}
__fiq __arm void fiq_handler(void)
{
while(1);
}
void timerenable()
{
VICIntSelect&=~(1<<VIC_TIMER0);
VICVectAddr0=(unsigned int)& TIMER0;
VICVectCntl0=0X20|(VIC_TIMER0);
VICIntEnable|=(1<<VIC_TIMER0);
VICIntSelect&=~(1<<VIC_TIMER1);
VICVectAddr1=(unsigned int)& TIMER1;
VICVectCntl1=0X20|(VIC_TIMER1);
VICIntEnable|=(1<<VIC_TIMER1);
__enable_interrupt();
}
void TIMER0(void)
{
led2=0;
printf("\n vimicrosystem \n");
T0IR=1;
}
void TIMER1(void)
{
led1=0;
led2=0;
printf("\n chennai \n");
T1IR=1;
}
int putchar(int ch)
{
if (ch=='\n')
{while ((U0LSR&0x20)!=0x20); //wait until Transmit Holding Register is empty
U0THR=0x0d; //then store to Transmit Holding Register
}
U0THR=ch;
while ((U0LSR&0x20)!=0x20) ; //wait until Transmit Holding Register is empty
return(ch); //then store to Transmit Holding Register
}
void main()
{
PINSEL0=0X00000005;
IO0DIR=0X00003000;
VPBDIV=0X01;
U0LCR=0X83;
U0DLL=0X4E;
U0DLM=0X00;
U0LCR=0X03;
T0IR=0XFF;
T0TC=0;
T0PR=0;
//T0MR0=0X00000000C;
T0MR0=0X002255100;
T0MCR=3;
T0TCR=1;
T1IR=0XFF;
T1TC=0;
T1PR=0;
T1MR0=0X000002EE0;
T1MCR=3;
T1TCR=1;
while(1)
{
timerenable();
printf("\n working... \n");
led1=1;
}}
STEP9. Now copy and paste the below program in the module.
STEP10. (Follow the same procedure from “Step 5 to Step 8” for adding the VHDL
modules for the below program.)
STEP11. Right click on the Xilinx FPGA hardware in the Hierarchy window pane and
select add “New Source”.
STEP12. Select “Implementation Constraint File” and enter the file name before
clicking “Next”.
STEP13. Copy and Paste the Implementation Constraint File module in the appropriate
module.
STEP14. Click “Generate Programming File” in the Processes pane for the entire
project (Now the .bit file has been generated for the project)
STEP15. Before continuing with the further process please Connect the FPGA hardware
kit with the CPU by using serial cable and Switch “ON”.
STEP16. Now Open the JTAG 5.5 software from Start menu in your computer and
initialize the FPGA device for dumping the program into it.
STEP17. While initializing please “Assign” the “.bit file” and “Program” your FPGA by
in the JTAG 5.5 application. (Now the coded instructions have been loaded in
the FPGA hardware kit.
PROGRAM:
Top module
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
-- DECLARATION OF THE PORT DETAILS IN TOP MODULE SECTION
ENTITY TOP_MODULE IS
PORT ( CLK : IN STD_LOGIC;
GEN_CLK1 : OUT STD_LOGIC;
GEN_CLK2 : OUT STD_LOGIC;
GEN_CLK3 : OUT STD_LOGIC;
INPUT1 : IN STD_LOGIC; ---- SQUARE SIGNAL
INPUT2 : IN STD_LOGIC; ---- SQUARE SIGNAL
INPUT3 : IN STD_LOGIC; ---- SQUARE SIGNAL
RISING_INTERRUPT : OUT STD_LOGIC;
RISING_INTERRUPT1: OUT STD_LOGIC;
RISING_INTERRUPT2: OUT STD_LOGIC
);
END TOP_MODULE;
ARCHITECTURE BEHAVIORAL OF TOP_MODULE IS
-- DECLARATION OF THE PORT DETAILS IN INPUT SIGNAL MODULE--
COMPONENT CLK_GEN IS PORT ( CLK : IN STD_LOGIC;
GEN_CLK1 : OUT STD_LOGIC;
GEN_CLK2 : OUT STD_LOGIC;
GEN_CLK3 : OUT STD_LOGIC
);
END COMPONENT;
-- DECLARATION OF THE PORT DETAILS IN INTERRUPT ROUTINE MODULE--
COMPONENT INTERRUPT IS PORT ( CLK : IN STD_LOGIC;
INPUT1 : IN STD_LOGIC; ---- SQUARE SIGNAL
INPUT2 : IN STD_LOGIC; ---- SQUARE SIGNAL
INPUT3 : IN STD_LOGIC; ---- SQUARE SIGNAL
RISING_INTERRUPT : OUT STD_LOGIC;
RISING_INTERRUPT1: OUT STD_LOGIC;
RISING_INTERRUPT2: OUT STD_LOGIC
);
END COMPONENT;
BEGIN
--DECLARING THE SIGNAL DETAILS OF THE COMPONENTS FOR PORT MAPPING --
CLK_SECTION :CLK_GEN PORT MAP
(CLK,GEN_CLK1,GEN_CLK2,GEN_CLK3);
INTERRUPT_SECTION :INTERRUPT PORT MAP
(CLK,INPUT1,INPUT2,INPUT3,RISING_INTERRUPT,RISING_INTERRUPT1,RISING_INT
ERRUPT2);
END BEHAVIORAL;
CLK_GEN
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
-- DECLARATION OF PORT DETAILS --
ENTITY CLK_GEN IS
PORT ( CLK : IN STD_LOGIC;
GEN_CLK1 : OUT STD_LOGIC;
GEN_CLK2 : OUT STD_LOGIC;
GEN_CLK3 : OUT STD_LOGIC);
END CLK_GEN;
ARCHITECTURE BEHAVIORAL OF CLK_GEN IS
OUTPUT:
View the output in PC-Hyper Terminal.
VIVA QUESTIONS:
1. What are the components of embedded system?
RESULT
Thus the interrupt performance characteristics of ARM and FPGA are studied. On
comparison, ARM counts at slow speed because it consumes more instruction cycles and
FPGA is more efficient for servicing and processing external interrupt pulses.
Expt. No.: 11
MAIL BOX
Date:
AIM:
To develop a ‘C’ code to create a mailbox and to understand the RTOS functions.
THEORY:
Real-time and embedded systems operate in constrained environments in which
computer memory and processing power are limited. They often need to provide their
services within strict time deadlines to their users and to the surrounding world. It is these
memory, speed and timing constraints that dictate the use of real-time operating systems in
embedded software.
The "kernel" of a real-time operating system ("RTOS") provides an "abstraction layer"
that hides from application software the hardware details of the processor (or set of
processors) upon which the application software will run. In providing this "abstraction
layer" the RTOS kernel supplies five main categories of basic services to application software
The most basic category of kernel services is Task Management. This set of services
allows application software developers to design their software as a number of separate
"chunks" of software -- each handling a distinct topic, a distinct goal, and perhaps its own
real-time deadline. Each separate "chunk" of software is called a "task." The main RTOS
service in this category is the scheduling of tasks as the embedded system is in operation.
The second category of kernel services is Intertask Communication and
Synchronization. These services make it possible for tasks to pass information from one to
another, without danger of that information ever being damaged. They also make it possible
for tasks to coordinate, so that they can productively cooperate with one another. Without
the help of these RTOS services, tasks might well communicate corrupted information or
otherwise interfere with each other.
Since many embedded systems have stringent timing requirements, most RTOS
kernels also provide some basic Timer services, such as task delays and time-outs. Many
(but not all) RTOS kernels provide Dynamic Memory Allocation services. This category of
services allows tasks to "borrow" chunks of RAM memory for temporary use in application
software. Often these chunks of memory are then passed from task to task, as a means of
quickly communicating large amounts of data between tasks. Some very small RTOS kernels
that are intended for tightly memory-limited environments, do not offer Dynamic memory
allocation.
Many (but not all) RTOS kernels also provide a "Device I/O Supervisor" category of
services. These services, if available, provide a uniform framework for organizing and
accessing the many hardware device drivers that are typical of an embedded system.
PROCEDURE:
STEP1. Create RTOS Programs
STEP2. Type the below code and save it with the name main.c (anyname.c)
STEP3. Compile and build the program
STEP4. Burn the program into the controller.
PROGRAM MAIN.C
/* - - - - - Header Files - - - - - */
#include <includes.h>
#include <intrinsics.h>
#include<stdio.h>
#include “uart.h”
/* - - - - - User Defined Variables - - - - - */
OS_EVENT *comm;
INT8U err;
/* - - - - - OS TASK STACK ALLOCATION - - - - - */
OS_STK Task1stk[100];
OS_STK Task2stk[100];
/* - - - - - TASK FUNCTION - - - - - */
void Task1(void *pdata)
{
pdata = pdata;
INT32U temp;
while(1)
{
temp=123;
OSMboxPost(comm,(void *)&temp);
OSTimeDlyHMSM(0, 0, 0, 10);
}
}
void Task2(void *pdata)
{
INT8U err;
INT8U *msg;
char val1;
while(1)
{
msg = OSMboxPend(comm,0,&err);
val1 = *msg;
printf("\n data = %d ",val1);
OSTimeDlyHMSM(0, 0, 0, 100);
}
}
void main (void)
{
uart_init(); /* call the Uart initialization functions */
BSP_Init(); /* Call Board Supporting packages */
OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
OSTaskCreate(Task1,0,&Task1stk[99],0);
OSTaskCreate(Task2,0,&Task2stk[99],1);
comm = OSMboxCreate((void *)0);
OSStart(); /* Start multitasking (i.e. give control to uC/OS-II) */
}
OUTPUT:
View the output in PC-Hyper Terminal.
VIVA QUESTIOS:
1.Define MAILBOX.
RESULT:
Thus the concept of Mailbox with ARM7 processor using embedded C program was done and
verified the message successfully.