Emb Lab Manual Final
Emb Lab Manual Final
Emb Lab Manual Final
1
EC6711 Embedded Systems Laboratory
User Manual
1. VSK – 2148
The ARM7 LPC2148 Syllabus Board based on a 32/16 Bit ARM7TDMI-s CPU with real
time Emulation and Embedded Trace support, that combines with microcontroller with
embedded high speed 512KB flash memory. It can also work in 16-bit Thumb Mode.
With the interfaced peripherals and onboard peripherals, plentiful practical codes can be
implemented with ARM7 LPC2148 Syllabus Board. The board has fast and reliable tools
that can satisfy the needs of experienced engineers and beginners alike.
2
EC6711 Embedded Systems Laboratory
User Manual
ARM7 LPC2148 Syllabus Boards achieve their small size through Modern SMD
technology and Multilayer Design. All Controller signals and ports extend from the
controller to high density pitch Connectors of the board.
ARM7 LPC2148 Syllabus Board Hardware Manual Describes the board’s design and
functions. Precise Specifications for the NXP LPC2148 Microcontroller can be found in
the enclosed Microcontroller Data sheet/User’s Manual. In this hardware manual,
schematic diagrams and Block Diagrams are attached.
IAR Embedded Workbench is the preferable IDE for this VSK-2148 board.
2. VLEDD – 02
The VLEDD – 02 boards is having 12 LEDs. The LEDs are controlled by two transistors.
The operating voltage can be varied as per the industrial requirement. The possible
3
EC6711 Embedded Systems Laboratory
voltages are 3.3V, 5V and 12V. The operational voltage can be selected depending on the
hardware design.
The LED sequence D1, D2, D3, D7, D8 and D9 are controlled by the transistor Q1 and
the sequence D4, D5, D6, D10, D11 and D12 are controlled by the transistor Q2.
The board is also having an LDR. The LEDs can be used to lighten the zone with this
output of the LDR.
3. Vi -XBB
The Xbee board is a Wireless board that has to be interfaced with the controller. It can be
interfaced either by RS232 cable or USB cable. A switch is provided to select the mode
of communication.
4
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
The IDE is the framework where all necessary tools are seamlessly integrated:
The highly optimizing IAR C/C++ Compiler
The IAR Assembler
The versatile IAR ILINK Linker, including accompanying tools
A powerful editor
A project manager
A command line build utility
5
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
FEATURES
PROJECT MANAGEMNET
The IDE comes with functions that will help you to stay in control of all project
modules, for example, C or C++ source code files, assembler files, include files, and
other related modules. You create workspaces and let them contain one or several
projects. Files can be grouped, and options can be set on all levels—project, group, or
file. Changes are tracked so that a request for rebuild will retranslate all required
modules, making sure that no executable files contain out-of-date modules. This list
shows some additional features:
Project templates to create a project that can be built and executed out of
the box for a smooth development startup
Hierarchical project representation
Source browser with an hierarchical symbol presentation
Options can be set globally, on groups of source files, or on individual source files
The Make command automatically detects changes and performs only the
required operations.
Text-based project files
Custom Build utility to expand the standard tool chain in an easy way
Command lines build with the project file as input.
6
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
FLASH MAGIC
Flash Magic provides a clear and simple user interface to these features and more
as described in the following sections. Under Windows, only one application may have
access the COM Port at any one time, preventing other applications from using the COM
Port. Flash Magic only obtains access to the selected COM Port when ISP operations are
being performed. This means that other applications that need to use the COM Port, such
as debugging tools, may be used while Flash Magic is loaded.
Win X talk
Win X talk software is windows software that allows send and receives the data
from serial port. COM port configuration is variable.
7
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
advantage of the ARM- specific facilities. The compiler is integrated with other IAR
Systems software in the IDE.
FEATURES
CODE GENERATION
LANGUAGE FACILITIES
Support for IAR Extended EC++ with features such as full template
support, namespace support, the cast operators static_cast, const_cast, and
reinterpret_cast,
as well as the Standard Template Library (STL).
Conformance to the ISO/ANSI C standard for a free-standing environment
IAR Assembler
The IAR Assembler is integrated with other IAR Systems software for the ARM
core. It is a powerful relocating macro assembler (supporting the Intel/Motorola style)
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 Ltd Assembler for
ARM, which simplifies the migration of existing code.
FEATURES
C preprocessor
List file with extensive cross-reference output
Number of symbols and program size limited only by available memory
Support for complex expressions with external references
255 significant characters in symbol names
Support for ARM EABI ELF/DWARF object format.
10
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
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.
11
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
2. Make sure the Tool chain is set to ARM, and click OK.
3. Select the project template Empty project, and click ok button. This simply creates
an empty project that uses default project setting.
4. In the standard Save As dialog box that appears, specify where you want to place
your project file, that is, in your newly created projects directory. Type your
project name in the File name box, and click Save to create the new project.
E.g. LED.
12
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
To Creating your Application ‘C’ file, Choose FILE menu and select NEW>File
13
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
To Save your ‘C’ file, Choose File>Save As. In the standard Save As dialog box that
appears, specify where you want to place your project file, that is, in your project
directory. Type your filename in the File name box, and click Save to create the new
project. E.g. Led.c
1. In the Workspace window, select the destination to which you want to add a
source file; a group or, as in this case, directly to the project.
2. Choose Project>Add Files to open a standard browse dialog box. Locate the files
led.c
Select them in the file selection list, and click Open to add them to the project.
14
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
15
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
To save your work space, Choose File>Save Workspace and specify where you
want to place your workspace file. In this tutorial, you should place it in your newly
created project directory. Type LED in the File name box, and click save button.
Now you will set the project options. For application projects, options can be set
on all levels of nodes. First you will set the general options to suit the processor
configuration in this tutorial. Because these options must be the same for the whole build
configuration, they must be set on the project node.
1. Select the project folder icon LED - Debug in the Workspace window and choose
Project>Options. Then select Output Converter in the Category list to display the
linker option pages.
16
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
The Output options are used for specifying details about the output format and the
level of debugging information included in the output file.
Select “option” on the popup menu. After selecting popup menu window shows as given
below.
17
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Select output format as “Intel Extended”, output file in the format of .hex format.
Select the linker file menu, linker configuration file available at project directory. To
Compile your Project, Choose Project>Rebuild ALL
18
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
If your project has no error, then it will show Building successfully and the Hex file will
be generated.
19
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
2. Make sure the Tool chain is set to ARM, and click OK.
3. Select the project template Empty project, and click ok button. This simply creates
an empty project that uses default project settings.
4. In the standard Save As dialog box that appears, specify where you want to place
your project file, that is, in your newly created projects directory. Type your
project name in the File name box, and click Save to create the new project. E.g.
LED.
20
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
RTOS Package comprises set of ‘C’ files and headed files. C Files are classified as
Application file, CPU files, μC/OS-II Files and BSP.
In this project, we have to split the C files according to the functions. So these files are
integrated under separate folder.
APP
BSP
CPU
UCOS-II
- PORT
- SOURCE
21
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
22
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
23
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
24
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
25
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Under ucos-ii group, create two group named as source and ports.
26
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
27
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
For Creating the Hex file, we choose output file format as given below.
29
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
If there is no error, Message window shows like this. Now Hex file is created.
30
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
ISP UTILITY
Under Windows, only one application may have access the COM Port at any one
time, preventing other applications from using the COM Port. Flash Magic only obtains
access to the selected COM Port when ISP operations are being performed. This means
that other applications that need to use the COM Port, such as debugging tools, may be
used while Flash Magic is loaded. Note that in this manual third party Compilers are
listed alphabetically. No preferences are indicated or implied.
31
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Procedure:
32
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Processing……..
33
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
34
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Instruction:
Follow the given steps for getting started with the syllabus experiments:
1. Install IAR Embedded Workbench IDE software and Win X-Talk software.
2. After successful installation of IAR, Install Flash Magic.
3. Connect the RS232 cable/USB cable provided to the PC and the LPC2148 Syllabus
Board, and Power on the VSK-2148 Development Board.
4. If you are using USB cable, then install the required USB to Serial driver (FTDI for
on beard converter).
5. Search/Set the COM Port no here :
Start >> My Computer >> Manage (on right click) >> Device Manager >>
Ports (COM & LPT).
6. Now, Identify the Mode-Select-Switch provided on the VSK 2148 Board marked
with the text PROG & EXEC.
PROG: Programming Mode used for downloading the code/program into the
flash memory.
EXEC: Execution Mode used for executing program after downloading.
35
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
After selecting any position (PROG / EXEC) press the reset switch provided on
the board.
7. After setting the proper COM port number & selecting the Mode-Select-Switch
position properly, Extract the “VSK-2148 SOURCE CODES V 1.0” (WinRAR
archive) file.
8. Open the project and follow the instructions given in each experiment.
36
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Experiment 1
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
real-time 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. For critical code size applications, the alternative 16-bit Thumb
mode reduces code by more than 30 % with minimal performance penalty.
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 8 kB up to 40 kB,
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.
37
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
FEATURES
16/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package.
Single flash sector or full chip erase in 400 ms and programming of 256 bytes in
1 ms.
USB 2.0 Full Speed compliant Device Controller with 2 kB of endpoint RAM.
In addition, the LPC2146/8 provides 8 kB of on-chip RAM accessible to USB by
DMA.
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.
Single 10-bit D/A converter provide variable analog output.
Two 32-bit timers/external event counters (with four capture and four compare
channels each), PWM unit (six outputs) and watchdog.
Low power real-time clock with independent power and dedicated 32 kHz clock
input.
Multiple serial interfaces including two UARTs (16C550), two Fast I2C-bus
(400 Kbit/s), SPI and SSP with buffering and variable data length capabilities.
Vectored interrupt controller with configurable priorities and vector addresses.
Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package.
38
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
60 MHz maximum CPU clock available from programmable on-chip PLL with
settling time of 100s
Processor wake-up from Power-down mode via external interrupt, USB, Brown-
Out Detect (BOD) or Real-Time Clock (RTC).
Single power supply chip with Power-On Reset (POR) and BOD circuits:
- CPU operating voltage range of 3.0 V to 3.6 V (3.3 V 10 %) with 5 V
tolerant I/O
ARCHITECTURE OVERVIEW
The LPC2148 consists of an ARM7TDMI-S CPU with emulation support, the
ARM7 Local Bus for interface to on-chip memory controllers, the AMBA Advanced
High-performance Bus AHB for interface to the interrupt controller, and the VLSI
Peripheral Bus (A compatible superset of ARM’s AMBA Advanced Peripheral Bus) for
connection to on-chip peripheral functions. The LPC2148 configures the ARM7TDMI-S
processor in little-endian byte order. AHB peripherals are allocated a 2 megabyte range
of addresses at the very top of the 4 gigabyte ARM memory space. Each AHB peripheral
is allocated a 16 kB address space within the AHB address space. LPC2148 peripheral
functions are connected to the VPB bus. The AHB to VPB Bridge interfaces the VPB bus
to the AHB bus. VPB peripherals are also allocated a 2 megabyte range of addresses,
beginning at the 3.5 gigabyte address point. Each VPB peripheral is allocated a 16 kB
39
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
address space within the VPB address space. The connection of on-chip peripherals to
device pins is controlled by a Pin Connect Block. This must be configured by software to
fit specific application requirements for the use of peripheral functions and pins.
ARM7TDMI PROCESSOR
The ARM7TDMI-S is a general purpose 32-bit microprocessor, which offers high
performance and very low power consumption. 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 processor core.
Pipeline techniques are 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
ARM7TDMI-S processor also 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. The key idea behind THUMB
is that of a super-reduced instruction set. Essentially, the ARM7TDMI-S processor has
two instruction sets:
The standard 32-bit ARM instruction set.
BLOCK DIAGRAM
41
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Result
The evolution, core features, general characteristics and the applications of ARM
processors has been studied and is evaluated.
42
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Experiment 2
Aim
3. Flash Magic.
4. CRO
5. USB cable.
Theory
i) ADC
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.
43
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
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.
Procedure
44
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program
/* - - - - - HEADER FILES - - - - -
*/ #include<nxp/iolpc2148.h>
#include<stdio.h>
#include "uart.h"
#include "adc.h"
/* - - - - - User defined Variables - - - - - */
void main(void)
{
PINSEL1_bit.P0_28=1;
init(); /* Call the initialization function. Function definition is in
“uart.h” */
uart_inital(); /* Call the uart function. Function definition is in “uart.h” */
adc(); /* Call adc function. Function definition is in “adc.h” */
PINSEL1=0X01000000; //ADC0.1
while(1)
{
while(AD0DR_bit.DONE==0); // Start A/D Conversion
val=AD0DR1_bit.RESULT;
printf("adc = %d \n\r",val);
}
}
45
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Compile, Debug & Simulate the above code in IAR.
Connect the RS232 cable/USB cable provided to the PC/Laptop and the VSK-
2148 Board, and Power on the Board.
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.
Now change the Mode-Selection-Switch to EXEC position and reset the board.
Open Win X-Talk, and select the COM port and the baud rate as 9600.
Now vary the on board potentiometer knob and observe the values displayed in
PC.
As you tune the knob, the values displayed in the PC/Laptop should vary from 0 to
1023 and there will be a shift in the position of the load line depending on the
values in the ADC.
You can interface any other analog sensor also (range 0-3.3V) to measure and
display the following parameters: temp./pressure/force/flow/acceleration/humidity
etc.
46
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
ii) DAC
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
1. 10 bit digital to analog converter
2. Resistor string architecture
3. Buffered output
4. Power-down mode
5. Selectable speed vs. power
Procedure
4
7
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program
/* - - - - - Header Files - - - - - */
#include<nxp/iolpc2148.h>
#define DAC_BIAS 0x00010000 /*The settling time of the DAC is 2.5 µs and the maximum
current is 350 µA when BIAS=1*/
/* - - - - - delay routine - - - - - */
for(int i=0;i<=x;i++);
void main()
PINSEL1=0X00080000;
while(1)
DACR = (1023 << 6) | DAC_BIAS; /* 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)) */
delay(100000); delay(100000);
delay(100000); delay(100000);
DACR = (0 << 6) | DAC_BIAS; /* 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)) */
delay(100000); delay(100000);
delay(100000); delay(100000);
48
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Compile, Debug & Simulate the above code in IAR.
Connect the RS232 cable/USB cable provided to the PC/Laptop and the VSK-
2148 Board, and Power on the Board.
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.
Now change the Mode-Selection-Switch to EXEC position and reset the board.
Connect the +ve terminal of the CRO probe to Aout and _ve terminal to AGND
pins on the board to see the variation in the pulse.
49
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Experiment 3
Aim
To write a C program to generate a PWM and to vary the brightness of the LED
depending on the duty cycle.
3. Flash Magic.
4. CRO
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
50
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Procedure
1. Follow the steps 1 of How to create a New project
2. Type the below code and save it with the name (anyname.c)
3. Follow the steps 2 and 3 of How to create a New Project to compile and build
the program
4. Follow the procedures in How to Download a Code to Our Controller to
download your code.
51
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program pwm.c
/* - - - - - 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 = 0X000A0005; /* To select Port pin P0.8 and also p0.9 as pwm4 and
pwm6 */
PWMPR = 0X00000000; /* To set Prescaler register value to one */
PWMPCR = 0X00005000; /* 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 */
PWMMR4 = x; PWMMR6
= 600; PWMTCR =
0X00000002; PWMTCR = /* To reset pwm timer */
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)
{
52
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
for(i=0;i<=1200;i++)
{
pwm(x);
delay();
x=x+1;
if(i>=1200)
{
x=0;
}
}
}
}
53
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Result
The C code to generate a PWM and to vary the intensity of the LEDs is developed and is
verified.
54
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Experiment 4
Aim
To develop a C-Language program for reading the RTC, convert into decimal and to
display it.
3. Flash Magic.
Theory
RTC
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
Serial Communication
Serial communication takes a byte of data and transmits the 8 bits in the byte one at a
time. The advantage is that a serial port needs only one wire to transmit the 8 bits (while
55
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
a parallel port needs 8). The disadvantage is that it takes 8 times longer to transmit the
data than it would if there were 8 wires. Serial ports lower cable costs and make cables
smaller.
Procedure
1. Follow the steps 1 of How to create a New project
2. Type the below code and save it with the name rtc.c (anyname.c)
3. Follow the steps 2 and 3 of How to create a New Project to compile and build
the program
4. Follow the procedures in How to Download a Code to Our Controller to
download your code.
56
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program rtc.c
/* - - - - - Header Files - - - - - */
#include<nxp/iolpc2148.h>
#include<stdio.h>
#include<string.h>
#include "uart.h"
/* - - - - - Real Time Clock Initialization - - - - - */
void RTC_Init()
{
ILR = 3; /* Disable 32'768 interrupt */
CCR = 0x11; /* Clock enable + 32'767Hz quartz enable; starts the RTC */
57
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
And, for
CIIR = Counter Increment Interrupt Register,
CCR = Clock Control Register
ILR = Interrupt Location Register
{
CCR |= 0x01; /* CTC Reset */
}
/* - - - - - Read Clock - - - - - */
printf("TIME--->%d:%d:%d\t",HOUR,MIN,SEC);
printf("DATE--->%d:%d:%d\n",DOM,MONTH,YEAR);
}
/* - - - - - main function starts - - - - - */
void main()
{
baudrate_settings(); /* call function baudrate_settings */
while(1)
{
Read_rtc(); /* call function Read_rtc */
}
}
59
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Compile, Debug & Simulate the above code in IAR.
Connect the RS232 cable / USB cable provided to the PC / Laptop and the VSK -
2148 Board, and Power on the Board.
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.
Now change the Mode-Selection-Switch to EXEC position and reset the board.
Open Win X- Talk, Select COM port and Baud rate as 9600
Now observe the output data in the PC, it should display the digital clock running
with Hr., Min., & Sec. Digits following format: “HH:MM:SS “. along with the
Day as “DD:MM:YYYY”
Digital Clock will start running from 10:21:00 as programmed by default, you can
modify the code and you can load your desired timing also.
Apart from timing it can be programmed to display AM-PM (12Hr mode) also.
Result
The C-Language program for reading RTC and displaying it in PC was written &
output is verified with running the RTC from a default/specified time.
60
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Experiment 5
Aim
To develop a C-Language program for displaying the Key pressed in the Keypad in the
LCD module. The display should come in the desired line and column.
Apparatus & Software Required
3. Flash Magic.
Theory
Keypad
The Matrix keyboard is used to minimize the number of I/O lines. Normally it is possible
to connect only one key or switch with an I/O line. If the number of keys in the system
exceeds the more I/O lines are required. To reduce the number of I/O lines the keys are
connected in the matrix circuit. Keyboards use a matrix with the rows and columns made
up of wires. Each key acts like a switch. When a key is pressed a column wire makes
contact with row wire and completes a circuit.
For example 16 keys arranged in a matrix circuit uses only 8 I/O lines.
In VSK-2148 board Dip-switch and matrix keypad lines are multiplexed.
61
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
LCD
Liquid crystals are a phase of matter whose order is intermediate between that of a liquid
and that of a crystal. The molecules are typically rod-shaped organic matters about 25
Angstroms in length and their ordering is a function of temperature. The molecular
orientation can be controlled with applied electric fields.
A standard character LCD is probably the most widely used data Visualization
component.
Character LCDs are available in various kinds of models.
1. No. Of characters x Lines: 8x1, 16x1, 16x2, 16x4, 20x4, 40x4…
2. Color: Yellow, Green, Gray, Blue…
62
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
The Character LCD communicates with the microcontroller via 8 bit data bus. The pin
description for character LCD is given below.
VCC, GND AND V0 - While VCC and VSS provide +5V and ground, respectively; V0
is used for controlling LCD contrast.
RS (Register Select) - If RS = 0, the instruction command code register is selected,
allowing the user to send a command such as clear display, cursor at home, etc.
If RS = 1, the data register is selected, allowing the user to send data to be displayed on
the LCD.
RW (Read/Write) - RW allows the user to write information to the LCD or read
information from it. RW=1 when reading; RW=0 when writing.
EN (Enable) - The LCD to latch information presented to its data pins uses the enable
pin. When data is supplied to data pins, a high to low pulse must be applied to this pin in
order for the LCD to latch in the data present at the data pins.
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.
63
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Procedure
1. Follow the steps 1 of How to create a New project
2. Type the below code and save it with the name keypad.c (anyname.c)
3. Follow the steps 2 and 3 of How to create a New Project to compile and build
the program
4. Follow the procedures in How to Download a Code to Our Controller to
download your code.
64
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program keypad.c
/* Keypad Interface
/ K1 TO K8 : P0.16 TO P0.23
/* - - - - - Header Files - - - - - */
#include<nxp/iolpc2148.h>
#include<stdio.h>
# include "lcd.h"
#include "key.h"
/* - - - - - main function starts here - - - - - */
void main()
{
PINSEL2 = 0x00000000; /* P0.16 TO P0.23 Configured as GPIO. */
data1("Press any Key"); /* call the function to display the data in LCD */
while(1)
{
scomm(0xC0); /* function to write single datas in LCD location C0 */
}
}
65
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
st
1 line (upper line) should display the Alphabets Press any Key and the
nd
2 line (lower line) should display the corresponding data as the Key is Pressed
You can change Address for upper line from 0x80 to 0x8F and
Result
The C-Language program for displaying the Key pressed in the Keyboard is displayed in
the LCD module and the output was verified on the LCD on the desires line and
column/address.
66
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Experiment 6
Aim
To develop a C-Language program to write and read a data in EEPROM and also to
analyze its performance with the interrupt
3. Flash Magic.
Theory
67
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Procedure
1. Follow the steps 1 of How to create a New project
2. Type the below code and save it with the name (anyname.c)
3. Follow the steps 2 and 3 of How to create a New Project to compile and build
the program
4. Follow the procedures in How to Download a Code to Our Controller to
download your code.
68
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program
/* - - - - - Header Files - - - - - */
#include<nxp\iolpc2148.h>
#include<stdio.h>
#include "intrinsics.h"
void TIMER0(void);
void TIMER1(void);
#include "int.h"
#include "uart.h"
#include "timer.h"
while(1)
{
printf("\n Welcome... ");
}
}
69
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
The main function will execute continuously. The Timer Interrupt function will
execute for every 1 second.
For every 1 second the Interrupt data will be printed in the PC
Result
The C-Language program to write and read a data in EEPROM and also to analyze its
performance with the interrupt is developed and is verified.
70
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Experiment 7
Mailbox
Aim
To develop a ‘C’ code to create a mailbox and to understand the RTOS functions.
3. Flash Magic.
Theory
71
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
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.
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.
72
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Procedure
1. Follow the steps 1 of How To Create Rtos Programs
2. Type the below code and save it with the name main.c (anyname.c)
3. Follow the steps 2 and 3 of How to create a New Project to compile and build
the program
4. Follow the procedures in How to Download a Code to Our Controller to
download your code.
73
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program main.c
/* - - - - - Header Files - - - - - */
#include <includes.h>
#include <intrinsics.h>
#include<stdio.h>
#include “uart.h”
OS_EVENT *comm;
INT8U err;
OS_STK Task1stk[100];
OS_STK Task2stk[100];
/* - - - - - TASK FUNCTION - - - - - */
74
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
val1 = *msg;
printf("\n data = %d ",val1);
OSTimeDlyHMSM(0, 0, 0, 100);
}
}
}
75
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
The tasks will run alternatively. The first task will post a data whereas the second
task will receive the data and display it in PC.
Result
The C-Language program to create a mailbox and to understand the about the RTOS
functions is developed and is verified.
76
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Experiment 8
Aim
To study about the Interrupt performance characteristics between ARM and FPGA
3. Flash Magic
6. ModelSim SE
7. JTAG 5.5
8. CRO
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
77
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
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.
78
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program (ARM)
#include<nxp\iolpc2148.h>
#include<stdio.h>
#include "intrinsics.h"
void TIMER0(void);
void TIMER1(void);
#pragma vector=0x18
void (*intrrupt_function)();
= VICVectAddr;
intrrupt_function = (void(*)())vector;
(*intrrupt_function)();
VICVectAddr = 0;
79
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
while(1);
void timerenable()
VICIntSelect&=~(1<<VIC_TIMER0);
VICVectCntl0=0X20|(VIC_TIMER0);
VICIntEnable|=(1<<VIC_TIMER0);
VICIntSelect&=~(1<<VIC_TIMER1);
VICVectCntl1=0X20|(VIC_TIMER1);
VICIntEnable|=(1<<VIC_TIMER1);
__enable_interrupt();
void TIMER0(void)
led2=0;
T0IR=1;
void TIMER1(void)
led1=0;
80
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
led2=0;
T1IR=1;
if (ch=='\n')
U0THR=ch;
void main()
PINSEL0=0X00000005;
IO0DIR=0X00003000;
VPBDIV=0X01;
U0LCR=0X83;
U0DLL=0X4E;
81
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
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
82
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Step 1: Create a “New project” in Xilinx ISE Project Navigator from File
Button.
Step 3: Check/ modify the properties for the FPGA hardware and click
“Next”.
Step 4: Click “Finish” for the Summary window.(Now the new project
window has been displayed in the ISE Project Navigator.)
Step 5: Right click on the Xilinx FPGA hardware in the Hierarchy window pane
and select add “New Source”.
Step 6: Select “VHDL Module” and enter the file name before clicking
“Next”.
83
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Step 7: Define the “port details” of the VHDL module and click “Next”.
Step 9: Now copy and paste the below program in the module.
(Follow the same procedure from “Step 5 to Step 8” for adding
the VHDL modules for the below program.)
Step 10: Right click on the Xilinx FPGA hardware in the Hierarchy window
pane and select add “New Source”.
Step 11: Select “Implementation Constraint File” and enter the file name
before clicking “Next”.
Step 12: Copy and Paste the Implementation Constraint File module in the
appropriate module.
Step 13: Click “Generate Programming File” in the Processes pane for the
entire project.(Now the .bit file has been generated for the project)
Step 14: Before continuing with the further process please Connect the
FPGA hardware kit with the CPU by using serial cable and Switch
“ON”.
Step 15: Now Open the JTAG 5.5 software from Start menu in your
computer and initialize the FPGA device for dumping the
program into it.
Step 16: 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.
84
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program (FPGA)
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
END COMPONENT;
85
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
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
_INTERRUPT2);
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
86
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Interrupt
-------------------------------------------------------------------------
-- LIBRARY PART --
-------------------------------------------------------------------------
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
-------------------------------------------------------------------------
-- PORT DECLARATION PART --
-------------------------------------------------------------------------
ENTITY INTERRUPT IS
PORT ( CLK : IN STD_LOGIC ; -- INPUT
CLOCK
INPUT1 : IN STD_LOGIC; -- SQUARE
SIGNAL
INPUT2 : IN STD_LOGIC; -- SQUARE
SIGNAL
INPUT3 : IN STD_LOGIC; -- SQUARE
SIGNAL
RISING_INTERRUPT : OUT STD_LOGIC; -- INTERRUPT OUTPUT
1
RISING_INTERRUPT1 : OUT STD_LOGIC; -- INTERRUPT OUTPUT
2
RISING_INTERRUPT2 : OUT STD_LOGIC -- INTERRUPT OUTPUT
3
);
END INTERRUPT ;
-------------------------------------------------------------------------
--DESIGN ARCHITECTURE BEGIN'S --
-------------------------------------------------------------------------
87
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
--------------------------------------------------------------------------
-- FIRST INTERRUT DESIGN --
--------------------------------------------------------------------------
8
8
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Y<='1';
END IF;
WHEN '1'=>
IF INPUT2='0' THEN --ROUTINE WILL CONTINUE IF INPUT 1 IN
'0' CONDITION
Y<='0'; -- VALUE OF X
TENDS TO '0'
END IF;
89
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
END CASE;
END PROCESS;
END BEHAVIORAL;
90
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
By connecting the probes of CRO/MSO/DSO to the Desired Input and Output pins of the
I/O connectors we will acquire the result of the Interrupt performance of FPGA device.
Step 1: Run the Simulation process of the Project by selecting “Simulation” in the
“View” pane and select the Simulator (ModelSim) in the Processes pane.
Step 2: Force clock input to the CLK variable by right clicking the variable Step
3: Now you can observe the Input and output result in the Simulator.
91
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Experiment 9
Flashing of LEDS
Aim
To develop a ‘C’ program to make the LED blink (including delay routine). Upon change
in the delay program the speed should vary.
Theory
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 the color of the light is determined by the
energy gap of the semiconductor.
VSK-2148 has 8 LEDs that are connected to the Microcontroller Port
Line. Used Port Lines: LED0 – LED7: P1.24 – P1.31
92
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Procedure
1. Follow the steps 1 of How to create a New project
2. Type the below code and save it with the name led.c (anyname.c)
3. Follow the steps 2 and 3 of How to create a New Project to compile and build
the program
4. Follow the procedures in How to Download a Code to Our Controller to
download your code.
93
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program led.c
/* - - - - - Header File - - - - - */
#include<nxp/iolpc2148.h>
/* - - - - - delay Routine - - - - - */
void delay()
{
for(int i=0x00;i<=0xff;i++)
for(int j=0x00;j<=0xFf;j++);
while(1)
{
IO1SET=0XFF000000; /* P1.24 TO P1.31 goes to high state */
delay(); /* delay */
delay(); /*delay */
}
}
94
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Compile, Debug & Simulate the above code in IAR.
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.
Now change the Mode-Selection-Switch to EXEC position and reset the board.
Run/Execute the program on the VSK – 2148 board and observe the LED blink
duration (on/off).
Result
The C-Language program to make the LED blink was developed and output was
verified. Upon change in the delay program the speed variation was verified.
95
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Experiment 10
Aim
3. Flash Magic.
4. Stepper motor
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.
96
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Jumper Position
Closed 1 and 2 - Internal voltage for stepper motor.
Closed 2 and 3 - External voltage for stepper motor.
Procedure
1. Follow the steps 1 of How to create a New project
2. Type the below code and save it with the name step.c (anyname.c)
3. Follow the steps 2 and 3 of How to create a New Project to compile and build
the program
4. Follow the procedures in How to Download a Code to Our Controller to
download your code.
97
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program step.c
/* - - - - - header files - - - - - */
#include<nxp/iolpc2148.h>
#include<stdio.h>
#include "uart.h"
#include "stepper.h"
#include "adc.h"
/* - - - - - user defined variables - - - - - */
98
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
else if(temp<=70)
{
rev(); /* call the reverse rotation function of stepper motor. Function definition is in
“stepper.h” */
}
}
}
99
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
The variations in the temperature is displayed in the PC and the motor will rotate
in clock-wise direction if the temperature in below 70 and will rotate in anti –
clock-wise, if the temperature is above 70.
Modify the program as per your desire/logic and verify the output.
Result
100
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Experiment 11
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
using local addressing, simple networks of more than 65,000 nodes can be
configured, with reduced address overhead
101
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
102
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Aim
3. Flash Magic.
Procedure
1. Follow the steps 1 of How to create a New project
2. Type the below code and save it with the name (anyname.c)
3. Follow the steps 2 and 3 of How to create a New Project to compile and build
the program
4. Follow the procedures in How to Download a Code to Our Controller to
download your code.
103
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program main.c
/* - - - - - header files - - - - - */
#include<nxp/iolpc2148.h>
#include<stdio.h>
#include "stdlib.h"
#include "uart.h"
#include "stepper.h"
/* - - - - - user defined variables - - - - - */
while(1)
{
for(i=0;i<4;i++)
{
out[i]= serial_rx(); /* receive the datas serially and store it in an array */
}
out[i]='\0';
z=atoi(out); /* convert array to integer */
104
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
printf("%d ",z);
if(z >70)
{
fwd(); /* stepper motor forward rotation */
}
}
}
105
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Based on the Variation in the ADC value the stepper motor will start rotating in
the clock-wise direction.
Result
The C Programs to control the rotation of a stepper motor connected with a controller
depending on the variation in the ADC of another controller is developed and is verified.
106
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Experiment 11
11.2 Keypad
Aim
To transmit the data or the key pressed in the keypad via Xbee and view the output
data in the PC.
3. Flash Magic.
Procedure
1. Follow the steps 1 of How to create a New project
2. Type the below code and save it with the name (anyname.c)
3. Follow the steps 2 and 3 of How to create a New Project to compile and build
the program
4. Follow the procedures in How to Download a Code to Our Controller to
download your code.
107
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
Program main.c
/* Keypad Interface
/ K1 TO K8 : P0.16 TO P0.23
/* - - - - - header files - - - - - */
#include<nxp/iolpc2148.h>
#include<stdio.h>
#include "uart.h"
/* - - - - - user defined variables - - - - - */
int i;
unsigned char dat[16]="Press Any Key";
/* - - - - - delay routine - - - - - */
void delay()
{
long int i;
for(i=0;i<50000;i++);
}
/* - - - - - main function - - - - - */
void main()
{
PINSEL2 = 0x00000000; /* P0.16 TO P0.23 Configured as GPIO. */
IO1DIR=0x00ff0000;
uart_inital();
10
8
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
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; /* Scan second 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;
109
EC6711 Embedded Systems Laboratory
User Manual
Vi Microsystems Pvt. Ltd.
}
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 */
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 */
The keys that are pressed in the board will be displayed in the PC.
Result
The C-Language program for displaying the Key pressed in the Keyboard is displayed in
PC via Xbee.
111