Академический Документы
Профессиональный Документы
Культура Документы
1
EC6711 Embedded Systems Laboratory
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.
2
EC6711 Embedded Systems Laboratory
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.
3
EC6711 Embedded Systems Laboratory
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
4
EC6711 Embedded Systems Laboratory
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.
5
EC6711 Embedded Systems Laboratory
BLOCK DIAGRAM
7
EC6711 Embedded Systems Laboratory
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.
8
EC6711 Embedded Systems Laboratory
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
9
EC6711 Embedded Systems Laboratory
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);
}
}
10
EC6711 Embedded Systems Laboratory
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.
11
EC6711 Embedded Systems Laboratory
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
12
EC6711 Embedded Systems Laboratory
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);
13
}
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.
14
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
15
EC6711 Embedded Systems Laboratory
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.
16
EC6711 Embedded Systems Laboratory
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 - - - - - */
17
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;
}
18
/* - - - - - main function starts here - - - - - */
void main()
{
PINSEL1_bit.P0_21=1;
IO0DIR_bit.P0_21=1;
PINSEL2 = 0X00000000;
IO1DIR = 0XFF000000;
int i;
while(1)
{
19
EC6711 Embedded Systems Laboratory
for(i=0;i<=1200;i++)
{
pwm(x);
delay();
x=x+1;
if(i>=1200)
{
x=0;
}
}
}
}
Result
The C code to generate a PWM and to vary the intensity of the LEDs is developed and is
verified.
21
EC6711 Embedded Systems Laboratory
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
22
EC6711 Embedded Systems Laboratory
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.
23
EC6711 Embedded Systems Laboratory
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 */
24
EC6711 Embedded Systems Laboratory
.
And, for
CIIR = Counter Increment Interrupt Register,
CCR = Clock Control Register
ILR = Interrupt Location Register
25
void RTCStart( void )
{
CCR |= 0x01; /* CTC Reset */
26
/* - - - - - Read Clock - - - - - */
printf("TIME--->%d:%d:%d\t",HOUR,MIN,SEC);
printf("DATE--->%d:%d:%d\n",DOM,MONTH,YEAR);
}
/* - - - - - main function starts - - - - - */
27
void main()
{
baudrate_settings(); /* call function baudrate_settings */
28
EC6711 Embedded Systems Laboratory
while(1)
{
Read_rtc(); /* call function Read_rtc */
}
}
29
EC6711 Embedded Systems Laboratory
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.
30
EC6711 Embedded Systems Laboratory
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.
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…
33
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.
Program keypad.c
/* Keypad Interface
/ K1 TO K8 : P0.16 TO P0.23
34
/ Key Value is displayed on UART0
/* - - - - - Header Files - - - - - */
#include<nxp/iolpc2148.h>
#include<stdio.h>
# include "lcd.h"
#include "key.h"
/* - - - - - main function starts here - - - - - */
35
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)
{
36
scomm(0xC0); /* function to write single datas in LCD location C0 */
}
}
37
Procedure to see OUTPUT:
Compile, Debug & Simulate the above code in IAR.
Connect the RS232 cable / USB cable provided to the PC / Laptop and the VSK -
2148 Boards, and Power on the Board.
For seeing the output in real-time, select the PROG mode, reset the board and
download the code in VSK-2148 board using Flash Magic through UART0.
Now change the Mode-Selection-Switch to EXEC position and reset the board.
Now observe the LCD output, it should display the Alphabets & Numbers.
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.
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
39
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.
Program
40
/* - - - - - 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"
41
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”*/
while(1)
{
printf("\n Welcome... ");
}
}
42
EC6711 Embedded Systems Laboratory
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.
Mailbox
Aim
To develop a ‘C’ code to create a mailbox and to understand the RTOS functions.
3. Flash Magic.
Theory
44
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.
45
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.
Program main.c
/* - - - - - Header Files - - - - - */
46
#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 - - - - - */
47
EC6711 Embedded Systems Laboratory
48
val1 = *msg;
printf("\n data = %d ",val1);
OSTimeDlyHMSM(0, 0, 0, 100);
}
}
49
OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
OSTaskCreate(Task1,0,&Task1stk[99],0);
OSTaskCreate(Task2,0,&Task2stk[99],1);
50
EC6711 Embedded Systems Laboratory
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.
51
EC6711 Embedded Systems Laboratory
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
53
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;
while(1);
void timerenable()
54
{
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;
led2=0;
T1IR=1;
55
if (ch=='\n')
U0THR=ch;
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;
56
T1TC=0;
T1PR=0;
T1MR0=0X000002EE0;
T1MCR=3;
T1TCR=1;
while(1)
timerenable(); printf("\n
57
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 variation in
the main process as an interrupt occurred.
The variations can be viewed in the CRO.
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”.
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”.
58
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.
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;
59
INPUT1 : IN STD_LOGIC; ---- SQUARE SIGNAL
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
_INTERRUPT2);
END BEHAVIORAL;
60
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
Interrupt
-------------------------------------------------------------------------
-- LIBRARY PART --
61
-------------------------------------------------------------------------
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 --
-------------------------------------------------------------------------
--------------------------------------------------------------------------
-- FIRST INTERRUT DESIGN --
--------------------------------------------------------------------------
62
END IF;
WHEN '1'=>
IF INPUT1='0' THEN --ROUTINE WILL CONTINUE IF INPUT
1 IN OFF CONDITION
X<='0'; -- VALUE OF X TENDS
TO '0'
END IF;
WHEN OTHERS=> -- IF ANY CONDITION OTHER
THAN '0' AND '1' THEN THE SUBJECT SHOULD BE ENDED.
END CASE;
IF RISING='1' THEN -- IF THE SIGNAL FOUND AS RISING EDGE
THEN THE BELOW OPERATION SHOULD BE FOLLOWED BY THE PROCESSOR
63
-- SECOND INTERRUPT DESIGN --
--------------------------------------------------------------------------
PROCESS(CLK,INPUT2) --SENSITIVITY LIST FOR INPUT USE
VARIABLE A,B,C,D,E,F,G,H,I,J,K,L,M,N:INTEGER :=0; --INTERNAL VARIABLE'S
DECLARATION FOR INTERNAL PROCESS
BEGIN
IF RISING_EDGE(CLK) THEN --CLOCK SIGNAL
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;
END CASE;
64
CONVENIENCE
RISING1<='0'; -- ONCE THE COUNTER EXCEEDS
THE VALUE OF 6000 THEN THE STATE OF RISING SHOULD BE '0'. THEN THE ROUTINE
WILL END UP.
END PROCESS;
END BEHAVIORAL;
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.
65
EC6711 Embedded Systems Laboratory
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
66
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
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.
67
EC6711 Embedded Systems Laboratory
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++);
68
void main()
{
while(1)
{
delay(); /* delay */
delay(); /*delay */
}
}
69
EC6711 Embedded Systems Laboratory
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.
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.
71
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.
Program step.c
72
/* - - - - - header files - - - - - */
#include<nxp/iolpc2148.h>
#include<stdio.h>
#include "uart.h"
#include "stepper.h"
#include "adc.h"
/* - - - - - user defined variables - - - - - */
73
void main()
{
init(); /* call function initializations. Function definition is in “uart.h”*/
74
if(temp>=70)
{
fwd(); /* call the forward rotation function of stepper motor. Function definition is in
“stepper.h” */
else if(temp<=70)
{
rev(); /* call the reverse rotation function of stepper motor. Function definition is in
“stepper.h” */
}
}
}
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
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
77
EC6711 Embedded Systems Laboratory
78
EC6711 Embedded Systems Laboratory
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.
79
EC6711 Embedded Systems Laboratory
Program main.c
/* - - - - - header files - - - - - */
#include<nxp/iolpc2148.h>
#include<stdio.h>
#include "stdlib.h"
#include "uart.h"
#include "stepper.h"
/* - - - - - user defined variables - - - - - */
80
void main()
{
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 */
81
EC6711 Embedded Systems Laboratory
82
printf("%d ",z);
if(z >70)
{
fwd(); /* stepper motor forward rotation */
}
}
}
83
EC6711 Embedded Systems Laboratory
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.
84
EC6711 Embedded Systems Laboratory
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.
Program main.c
85
/* 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 - - - - - */
86
void main()
{
PINSEL2 = 0x00000000; /* P0.16 TO P0.23 Configured as GPIO. */
IO1DIR=0x00ff0000;
uart_inital();
87
88
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 */
{
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;
89
EC6711 Embedded Systems Laboratory
90
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 */
91
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 */
92
EC6711 Embedded Systems Laboratory
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.
93