You are on page 1of 84

ADT_V1.

1 Lab Manual

Embedded Lab Manual


For

ADT-V1

Page 1 of 84

ADT_V1.1 Lab Manual

DISCLAIMER
Embedded Lab Manual for ARM9 CORTEX and other documentation:
This manual and the accompanying documentation such as schematic diagrams in soft or hard form contains descriptions of copyrighted products, which are not explicitly indicated as such. The absence of
trademark symbol does not infer that a Product is not protected.

Additionally, registered patents and trademarks are similarly not expressly indicated in these documents.
The information in these documents has been carefully checked and is believed to be entirely reliable.
However, Advance Instruments & Services, Chennai. (henceforth Company) assumes no
responsibility for any inaccuracies. The Company neither gives any guarantee nor accepts any liability
whatsoever for consequential damages resulting from the use of these documents or associated products.
The Company reserves the right to alter the information contained herein without prior notification and
accepts no responsibility for any damages that might result. Additionally, The Company offers no
guarantee nor accepts any liability for damages arising from the improper usage or improper installation
of the hardware or software. The Company further reserves the right to alter the layout and/or design of
the hardware without prior notification and accepts no liability for doing so.

Advantech Instruments And Services


#10(Old No. 18), 16th Street,
Jai Nagar, Arumbakkam,
Chennai-600106.

Page 2 of 84

ADT_V1.1 Lab Manual

Table Of Contents
1.Introduction...............................................................................................................................................5
2. Getting Started............................................................................................................................................ 6
2.1 Quick starts to create C language applications:.................................................................................6
2.2 Creating C applications for ADT V1.1: In Detail............................................................................. 8
3. Hardware Description...............................................................................................................................15
3.1 ADT V1.1:.......................................................................................................................................... 15
4. Connector Details, Jumper and Switch Settings...................................................................................... 15
4.1 ADT V1.1 Block Diagram:............................................................................................................... 15
4.2 DIP Switches Details:......................................................................................................................... 17
4.3 Push-Button Switches Details:........................................................................................................... 17
4.4 LEDs and Buzzer Details:.................................................................................................................. 18
4.5 Connector Details:.............................................................................................................................. 18
5. Downloading and Running User Programs..............................................................................................25
5.1 How to install Flash Magic:................................................................................................................25
5.2 Download and Run program using Flash Magic into LPC1768:...................................................... 25
6. JTAG Cable for Debugging......................................................................................................................28
6.1 Type:....................................................................................................................................................28
6.2 Contents:............................................................................................................................................. 28
6.3 Power Supply Requirements:............................................................................................................. 28
6.4 Connecting JTAG Cable:....................................................................................................................28
6.5 Verifying correct cable connection:................................................................................................... 29
6.6 How to Debug Program:.....................................................................................................................29
7. Program Downloading and related Output.............................................................................................. 30
8. RTOS And its Codes................................................................................................................................ 34
9.FPGA Programming Steps........................................................................................................................ 48
9.1 Quick starts to create VHDL language applications:....................................................................... 48
9.2 Steps for programming PROM File.................................................................................................... 52
10. FPGA and uC Interrupt performance Example......................................................................................58
10.1 Code for uC:....................................................................................................................................58
11. Experiments:........................................................................................................................................... 64
11.1 Interfacing Flashing of LEDs:........................................................................................................ 64
11.2 Interfacing Buzzer ON-OFF :.........................................................................................................64
11.3 Interfacing Digital Input and Output:.............................................................................................65
11.4 Interfacing ADC:............................................................................................................................ 66
11.5 Interfacing DAC:............................................................................................................................ 67
11.6 Interfacing LED and PWM(RGB):................................................................................................ 68
Page 3 of 84

ADT_V1.1 Lab Manual


11.7 Interfacing Real Time Clock on Serial UART:..............................................................................69
11.8 Interfacing I2C based EEPROM:................................................................................................... 69
11.9 Interfacing LCD Keyboard:............................................................................................................ 71
11.10 Interfacing External Interrupt:...................................................................................................... 71
11.11 Interfacing Stepper Motor:............................................................................................................72
11.12 Interfacing LM 35 (Temperature Sensor)..................................................................................... 73
11.13 (A) Interfacing XIGBEE on Serial UART:..................................................................................74
11.13 (B) Interfacing XIGBEE and Switch:...........................................................................................75
Appendix:......................................................................................................................................................77

Page 4 of 84

ADT_V1.1 Lab Manual

1. Introduction
This is users manual for ADT-V1 Trainer Kit based on LPC1768 micro-controller and XC6SLX4
Spartan6 FPGA. This trainer board is designed to perform lab practical and has a facility to download the
user programs into the on-chip flash memory of the micro-controller.
It is strongly recommended to read this manual carefully before you start using the ADT_V1 board.
CAUTION: This board contains components that are sensitive to Electro-Static Discharge (ESD). The
board must be handled carefully, so as not to subject it to ESD. As far as possible, do not touch any
conducting part on the board - including any component or connector pins - as this may damage parts of the
board permanently. If you want to touch any of the parts, make sure to discharge yourself to earth. Parts
damaged due to ESD are not covered under limited warranty.

WARRANTY: Its 1 year against manufacturing defects only.

Page 5 of 84

ADT_V1.1 Lab Manual

2. Getting Started
About Project:
What is a project?
A project is a file in which Keil uVision5 stores all information related to an application. E.g. it stores
the name of C and/or Assembler source file, memory size to be used and other options for compiler,
assembler and linker.
Opening a project:
To open an existing project file, select Project / Open Project from the menu.
Creating a new project:
To create a new project, select Project / New uVision Project from the menu.
Closing project settings:
To close the project, select Project / Close Project from the menu.

2.1 Quick starts to create C language applications:


k starts to create C language applications:
1. Start the Keil uVision5 program (i.e. the Integrated Development Environment) from
start\Programs\Keil uVision5.
2. From Project menu, select Close project (if any project is open).
3. From Project menu, select New Project. The Open dialog window will be displayed. Select the
desired path where you wish to create this new project. (For example, C:\SPJ). CAUTION: The
path and filename must not contain space or other special characters such as tab, comma, semicolon
etc. In the File name field, type the name of the project, without any extension. For example, you
may type PROG1. Then click on the Open button.
4. The action in the previous step will display the Select device for Target Target 1 dialog
window. Here you have to select the micro-controller you are going to use. The target microcontroller (must be a member of ARM family) is known, You have to load Legacy Device
Database (RTE) and then select the device you may select the appropriate Manufacturer from the
list; and then select the appropriate micro-controller from the device list. If the target microcontroller is not known or if you cannot find it in the list, then you may simply search LPC1768
or select NXP as the manufacturer and LPC1768 as the micro-controller.
Page 6 of 84

ADT_V1.1 Lab Manual


5. Then a dialog box will appear asking for adding Startup.s file in to the project. Click on the Yes to
it.
6. Click on Source Group 1 to display that part of the dialog window. This window will indicate
that IDE has automatically added 1 files in this new project: STARTUP.S The STARTUP.s file is
automatically created by the IDE and is required for all C projects. Now add the file select File /
New then a dialog box will appear, give name to your file with extension ( E.g. PROG1.c ) Then
add files in this project, then right click on the Source Group 1 Folder,click on Add existing
Files to Group Source Group1 select the desired filename and then click on Add button.
Now the Project Settings dialog will indicate that selected file has been added into the project. When
all necessary files have been added to the project, click OK button to create this new project.
7. Now create the Target for the completion of the project, right click on the Target 1 folder in the
project explorer window. then click on options for Target Target 1 ,Then a dialog appears
having 10 parts first is Device and last Utilities. Now select Output and Checked the options
Create Hex File. then go to Linker and check the option Use memory layout from target
dialog.
8. From the Target menu, select Build. This will invoke the Compiler to compile the file PROG1.C;
and further (assuming no errors) invoke the linker to create the .HEX file. If there are any errors or
warnings during the process of compiling, assembling or linking, then those will be displayed in the
output window (below the editor window). If there are errors, then you may correct those by making
appropriate changes to the program; select Save from File menu to save the changes and then again
select Build from Compile menu. Repeat this until there are no errors.
9. You may inspect contents of the folder where your project files reside. When there are no errors and
build has completed successfully and then you will see a file name with same name as the project
name and extension .HEX (in above example, PROG1.HEX). This is the file that you will need to
use to program your micro-controller.

Page 7 of 84

ADT_V1.1 Lab Manual

2.2 Creating C applications for ADT V1.1: In Detail


Want a quick start? Read this section sitting in front of your Computer. Please follow the instructions in
the given example. By the time you finish with the example, you will have acquired enough knowledge
about the features of this software. That will enable you to actually start using the software for your
applications.

2.2.1 Starting the IDE (Keil uVision5):


1. Click on START button and select Programs / Keil_v5 / Keil uVision5. The screen should look
something like this. There are 3 different windows viz. Editor Window, Workspace window and
Output window as shown below.

Work space Window

Editor Window

Output Window

2. From Project menu, select Close project. The screen should look something like this.

Page 8 of 84

ADT_V1.1 Lab Manual

3. Then create new folder in D-drive viz. Blink (You may change name).
4. To create a new project, from Project menu, select New Project, also select folder test from Ddrive & Give file name viz. Blink & say Open

5. Then new window will displayed, here select Legacy Device Database (no RTE) in place of
Softwares Packs & search LPC1768 in search box. .
Page 9 of 84

ADT_V1.1 Lab Manual

6. These screen look like this & say OK


7. Then new window will appear. Here we can add Startup.s file & then Say YES.

Page 10 of 84

ADT_V1.1 Lab Manual

7. When we Say YES then Editor Window will be Empty, here we have to add our source codetext
file as given below. And Save it by appropriate name and with extension .c

You can see the .c file opened in Editor Windows . And type the code in the .c file .

Page 11 of 84

ADT_V1.1 Lab Manual

10. Then write our Source code in Editor Window & save it such as given below,

11. Now we have to configure target. For it Right Click on Target 1 folder in Project Explorer,
Go-to Output Tab, and Check Create HEX Flie and say OK.
Page 12 of 84

ADT_V1.1 Lab Manual

12. Then select Project for creating of hex file of that our project & click on Rebuild all target
files button.

Page 13 of 84

ADT_V1.1 Lab Manual


13.Then our hex file will be created in our folder i.e. Blink process such as shown in output window,

14. Our hex file will be created successfully in our destination folder.

Note: Copy following Keil CSMIS file in the folder of our project and Add Systems_LPC17xx.c
in project.
1. Systems_LPC17xx.c
2. Core_cm3.h
3. Core_cmFunc.h
4. Core_cmInstr.h
5.LPC17xx.h
6. System_LPC17xx.h

Page 14 of 84

ADT_V1.1 Lab Manual

3. Hardware Description
3.1 ADT V1.1:
Unpacking:
You will find following items in the package:

ADT V1.1 board

Serial communication cable (Straight 9-Pin)

Power adapter with cable

SPJ_TOOLS CD-ROM

Power Supply Requirements:


The power adapter works with 230Volts AC. It produces approximately 9 Volts DC, and the ADT V1.1 uses
on-board regulators to provide 5 Volts and 3.3 Volts DC to all components on the board.

Connecting the system:


The serial communication cable supplied with the board should be used to connect the board to a PC
running Windows95/98/NT/ ME/2000/XP/Vista Operating System. Connect one end of the serial cable
to UART0 of ADT V1.1 board and other end to PCs serial port.
Powering ON:
After connecting the serial communication cable as described above, you may insert the power adapter
output jack into the on-board power socket. Plug the power adapter into 230VAC mains outlet and turn it
on. Now press on-board power switch, power-on indication Green LED will turn on.
CAUTION: Please do not connect or disconnect the serial communication cable while the board is
powered ON. Doing so can damage the serial port of the ADT V1.1 board and/or PC.

Page 15 of 84

ADT_V1.1 Lab Manual

4. Connector Details, Jumper and Switch Settings


4.1 ADT V1.1 Block Diagram:
Below figure shows the locations of different components on the ADT V1.1 board.
UART0
(SW1)
ON

UART1

Zig-Bee

16 X 2 LCD

JTAG
Connector

P/S (SW1)
Section

JTAG FPGA
Programming
pins

I2C
EEPROM
and RTC

Stepper
Motor

ADC and LM35


TxD1 (P2.0) (S4.1) ON
Rx1D (P2.1) (S4.2) ON
RGB LED VCC (S4.3) ON

LPC 1768
RGB LED Micro-controller

LEDs and
Switch
Array

Vccr +5V
(SW19)

Figure 1. ADT V1.1


Page 16 of 84

FPGA Spartan
XC6SLX4

ADT_V1.1 Lab Manual

4.2 DIP Switches Details:


S1:
Turn ON this switch to connect NRST and P2.10( PGM pin) to LPC1768.
S4.1:
Turn ON this switch to connect UART1 Tx to P2.0 of LPC1768.
S4.2:
Turn ON this switch to connect UART1 Rx to P2.1 of LPC1768.
S4.3:
Turn ON this switch to connect 3.3V to RGB PWM of LPC1768.
S11.1:
Turn ON this switch to connect Buzzer to P0.26 of LPC1768.
S11.1:
Turn ON this switch to connect DAC/TP2 to DACOut/P0.26 of LPC1768. .
S19.1:
Turn ON 8 LEDs, It connects 3.3V to VCC of LEDs .
S19.2:
Turn ON 8 LEDs, It connects 5V to VCC of LEDs .

4.3 Push-Button Switches Details:


When pressed, the switches are grounded. When Idle, they are pulled high.
Push-Button

Signal Name

SW1(RST/RESET)

Reset to LPC1768

SW2 to SW17: Matrix Keypad

P1.18 to P1.25

SW18

P2.10/ EINT1

SW20

FPGA Interrupt

Page 17 of 84

ADT_V1.1 Lab Manual


SW21

P1.18

SW22

P1.19

SW23

P1.20

SW24

P1.21

SW25

P1.22

SW26

P1.23

SW27

P1.24

SW28

P1.25

4.4 LEDs and Buzzer Details:


All the LEDs are connected by common anode method. That means the positive leg of each LED is
connected to Vcc and negative leg to the port pins of the microcontroller. A logic 0 on the port pin will
make LED ON and logic 1 will make it OFF.
LED
Signal Name
D2/ P.ON

+5V Power ON/OFF

D11

P0.4

D12

P0.5

D13

P0.6

D14

P0.7

D15

P0.8

D16

P0.9

D17

P0.10

D18

P0.11

D19

P0.26/DAC

D20

RGB LED

Buzzer

P0.26

4.5 Connector Details:


UART0:
This is a DB9 female connector, used for RS232 serial communication with the PC:
Pin 2 = UART0 RS232 TxD (output of C)
Pin 3 = UART0 RS232 RxD (input to C)
Pin 4 = RS232 DTR

Page 18 of 84

ADT_V1.1 Lab Manual


Pin 5 = Ground
Pin 7 = RS232 RTS
All other pins of J1/UART0 are unused.
UART1:
This is a 3pin Relimate connector, used for RS232 serial communication with the PC:
Pin 1 = UART1 RS232 TxD (output of C)
Pin 2 = UART1 RS232 RxD (input to C)
Pin 3 = Ground
16x2 LCD:
This is a 16 pin, single line connector, designed for connection to standard, text LCD modules. The
pin/signal correspondence is designed to be matching with that required by such LCD modules.
Pin 1 = GND
Pin 2 = +5V
Pin 3 = Vlcd
Pin 4 = P1.27 (Used as RS of LCD)
Pin 5 = GND
Pin 6 = P1.26 (Used as EN of LCD)
Pin 7 = P0.4 (Used as D0 of LCD)
Pin 8 = P0.5 (Used as D1 of LCD)
Pin 9 = P0.6 (Used as D2 of LCD)
Pin 10 = P0.7 (Used as D3 of LCD)
Pin 11 = P0.8 (Used as D4 of LCD)
Pin 12 = P0.9 (Used as D5 of LCD)
Pin 13 = P0.10 (Used as D6 of LCD)
Pin 14 = P0.11 (Used as D7 of LCD)
Pin 15 = Back lighting
Pin 16 = GND
I2C Connector :
This standard 4 pin I2C connector provides support for interfacing of I2C based peripherals to LPC21xx.
This connector is mounted on middle-bottom side of the board as shown in figure1. 4 pin straight cable can
be used to connect LPC21xx to the board having I2C based peripheral devices.

The pin-out of I2C Connector is given below:


Pin

Signal name
Page 19 of 84

ADT_V1.1 Lab Manual


1

P0.20 (SCL1)

P0.19 (SDA1)

+5V

DGND

Stepper Motor Connector :


This standard 6 pin connector provides support for interfacing Stepper motor to LPC1768. The pin-out of
Stepper motor Connector is given below:
Pin

Signal name

P0.0

P0.1

P0.16

P2.3

Vcc (+5V)

GND

JTAG Connector:
This standard 20 pin JTAG connector provides debugging support for the LPC21xx. This connector is
mounted on top side of the board as shown in figure1. JTAG cables like SJT-S or SJT-U can be connected
to this connector, while other end of the cable can be connected to PC COM port or USB port, respectively.
Debugger software (like the debugger built into Keil uVision5) allows JTAG based debugging. It is also
possible to use third party JTAG based emulators /debuggers. The pin-out of JTAG Connector is given below:
Pin

Signal name

Pin

Signal name

3.3V

3.3V

NTRST

GND

TDI

GND

TMS

GND

TCK

10

GND

11

RTCK

12

GND

Page 20 of 84

ADT_V1.1 Lab Manual


13

TDO

14

GND

15

NRST

16

GND

17

GND

18

GND

19

GND

20

GND

SV3) :
This is 26 pin dual line headers. It brings out I/O and most of the pins of the LPC1768 microcontroller. Further, 5V and GND are also made available on these connectors. These connectors are
intended for use to connect external peripherals.
The pin/signal details of J4 are as below:

Pin

Signal No.

Pin

Signal

P0.20

14

P2.3

2
3
4
5
6
7
8
9
10
11
12
13

P0.19
P0.23
P0.24
P0.18
P2.2
P2.0
P2.1
P0.25
P0.0
P0.26
P0.16
P0.1

15
16
17
18
19
20
21
22
23
24
25
26

P0.20
P0.19
P0.23
P0.24
P0.18
P2.2
P2.0
P2.1
NA
NA
Vcc(+5V)
GND

Page 21 of 84

ADT_V1.1 Lab Manual

J5:
This is 54 pin dual line headers. It brings out I/O and most of the pins of the XC6SLX4 FPGA.
Further, 5V and GND are also made available on these connectors. These connectors are intended for use
to connect external peripherals.
The pin/signal details of IO-A are as below:

Pin
1
2
3
4
5
6
7
8
9
10
11
12

Signal No.
BUFF_P1.16
IO-A2
BUFF_P1.17
IO-A4
BUFF_P1.18
IO-A6
BUFF_P1.19
IO-A8
BUFF_P1.20
IO-A10
BUFF_P1.21
IO-A12

Pin
19
20
21
22
23
24
25
26
27
28
29
30

Signal
BUFF_P1.25
IO-A20
BUFF_P1.26
IO-A22
BUFF_P1.27
IO-A24
BUFF_P1.28
IO-A26
BUFF_P1.29
IO-A28
BUFF_P1.30
IO-A30
Page 22 of 84

Pin
37
38
39
40
41
42
43
44
45
46
47
48

Signal No.
BUFF_P0.18
IO-A38
BUFF_P0.19
IO-A40
BUFF_P0.20
IO-A42
BUFF_P0.21
IO-A44
BUFF_P0.22
IO-A46
BUFF_P1.23
IO-A48

ADT_V1.1 Lab Manual


13
14
15
16
17
18

N47
IO-A14
BUFF_P1.23
IO-A16
BUFF_P1.24
IO-A18

31
32
33
34
35
36

BUFF_P1.31
IO-A32
BUFF_P0.16
IO-A34
BUFF_P0.17
IO-A36

49
50
51
52
53
54

BUFF_P0.11
IO-A50
BUFF_P0.14
+5V
+3.3V
GND

U5:
This is 54 pin dual line headers. It brings out I/O and most of the pins of the XC6SLX4 FPGA.
Further, 5V and GND are also made available on these connectors. These connectors are intended for use
to connect external peripherals.
The pin/signal details of IO-B are as below:

Pin
1
2
3
4
5
6
7
8
9
10

Signal No.
IO-B1
IO-B2
IO-B3
IO-B4
IO-B5
IO-B6
IO-B7
IO-B8
IO-B9
IO-B10

Pin
19
20
21
22
23
24
25
26
27
28

Signal
IO-B19
IO-B20
IO-B21
IO-B22
IO-B23
IO-B24
IO-B25
IO-B26
IO-B27
IO-B28
Page 23 of 84

Pin
37
38
39
40
41
42
43
44
45
46

Signal No.
IO-B37
IO-B38
IO-B39
IO-B40
IO-B41
IO-B42
IO-B43
IO-B44
IO-B45
IO-B46

ADT_V1.1 Lab Manual


11
12
13
14
15
16
17
18

IO-B11
IO-B12
IO-B13
IO-B14
IO-B15
IO-B16
IO-B17
IO-B18

29
30
31
32
33
34
35
36

IO-B29
IO-B30
IO-B31
IO-B32
IO-B33
IO-B34
IO-B35
IO-B36

47
48
49
50
51
52
53
54

IO-B47
IO-B48
IO-B49
IO-B50
IO-B51
+5V
+3.3V
GND

SM 2148 Module Pin outs:

Figure 2. IOA and IOB Connectors Details

5. Downloading and Running User Programs


Page 24 of 84

ADT_V1.1 Lab Manual


The LPC21xx micro-controllers include on-chip flash for storing user program and non-volatile data.
LPC1768 on ADT V1.1 have 512KBytes flash. This flash is In-System-Programmable (ISP). Therefore
it is possible to download user program into on-chip flash of LPC1768, through serial port connected to
PC. For doing so, a certain position of SW3 switch is required. SW3 Switch should be continuously
ON. This section describes how to use the software Flash Magic to download program into LPC1768.

5.1 How to install Flash Magic:


The CD you have received with this board contains Keil uVision5, C Compiler for ARM. Install it. After
installation go to folder C:\Keil uVision5\Utilities. This folder contains 5 zip files. Install Flash Magic
from FlashMagic3.71.zip. Extract the FlashMagic3.71.zip and then run FlashMagic.exe from the
extracted files. (If you have wrong version of Flash Magic already installed, then please uninstall it first
and then install new version).

5.2 Download and Run program using Flash Magic into LPC1768:

After installation of Flash Magic, open it.


In Flash Magic go to Options -> Advanced Options-> Communications. Check High Speed
Communications and keep Maximum Baud Rate as 19200. Click on OK.

Again in Flash Magic go to Options -> Advanced Options-> Hardware Config. Use DTR and
RTS to control RST and P0.14 option should be checked. Click on OK.

Page 25 of 84

ADT_V1.1 Lab Manual


(After doing above mentioned settings, Flash Magic stores it means for the next time just verify if
these setting are proper or not. If they are proper then you can directly follow below mentioned
procedure)

1. Connect the J1/UART0 connector of ADT V1.1 board to COM1 or COM2 of a PC, using the
serial communication cable (supplied with the board).
2. Keep S2 switch in ON position. (You can keep S2 switch continuously ON) Switch ON power to
the ADT V1.1.
3. Do proper settings in Flash Magic (COM Port: COM1 (if other choose it), Baud Rate: 19200,
Device: LPC1768, Interface: None (ISP), Enable Erase blocks used by Hex File, Browse the
file which you want to download) and click on Start button.

Page 26 of 84

ADT_V1.1 Lab Manual

4. Flash Magic will download the program. Wait till Finished comes.
5. After downloading Flash Magic automatically resets the ADT V1.1 board and program executes.
You can see output according to the program.
6. If again you want to Reset the board then press RST switch on SM-2148 board. You can see
output according to the program.
Note: Flash Magic can be used to download the program into other Philips Micro-controllers also. See
the list in Flash Magic itself

Page 27 of 84

ADT_V1.1 Lab Manual

6. JTAG Cable for Debugging


6.1 Type:
SJT-S: Serial JTAG Cable.

6.2 Contents:
The JTAG Cable consists of following parts:

Dongle (a small box with connectors on both ends).

Cable.

The dongle consists of some electronic circuit for interfacing the JTAG port of target processor to the
host computer. The cable is a bunch of wires to connect the dongle with the JTAG port of target.

6.3 Power Supply Requirements:


The JTAG cable draws power from the target board. Thus it does not require a separate power source.

6.4 Connecting JTAG Cable:


SJT-S:
There is a DB9 female connector on one end of the dongle. This directly mates with the PC COM port
which has a DB9 male connector (or you can connect yellow color serial cable, supplied with SJT-S or
ADT V1.1 board, between DB9 female connector on one end of the dongle and PC COM port which
has a DB9 male connector). The other end of the dongle has DB25 female connector. There is a DB25
male connector on one end of the cable. These DB25 female and DB25 male connectors are designed to
mate with each other directly. The other end of the cable has a 20-pin header. This should be connected
to the JTAG connector of the target board.
CAUTION:
The JTAG Cable must not be connected or dis-connected when power is applied to the target board.
Turn off power to the target board, connect the JTAG Cable and then you may turn on power to the
target board.
Connecting the JTAG Cable with incorrect polarity / orientation may permanently damage the ADT
V1.1 board and/or the JTAG Cable. It will also make the warranty void for both the products.

Page 28 of 84

ADT_V1.1 Lab Manual

6.5 Verifying correct cable connection:


When the JTAG Cable is correctly connected to PC as well as the target board, it serves as a link
between the JTAG port of target processor and the PC. This link is used by SPJ - Keil uVision5 software
Tools (e.g. Debugger for ARM micro controllers).
This software tool, Debugger will work correctly only when the JTAG Cable is connected correctly.
For SJT-S:
There is a crude test to verify SJT-S JTAG Cable connection. You may please follow these steps:
1. Connect JTAG Cable between PC COM port and JTAG connector on ADT V1.1, as per
instructions in this manual.
2. Turn ON power to the target board.
3. On the PC, run SPJTerminal software.
4. In the Port Settings, select appropriate COM port (to which the JTAG cable is connected). Select
115200 baud, no parity, 8 bits per char, 1 stop bit and no flow control.
5. Open the COM Port connection.
6. Type character V in the terminal window. i.e. send the character V to the PC COM port.
7. If the JTAG Cable connection is correct, it will send version of JTAG cable. As a result, you will
see that version appearing in the terminal window. This indicates that JTAG Cable connection is
OK.
8. If you dont see any character in the terminal window, probably the JTAG Cable is not connected
appropriately.

6.6 How to Debug Program:


1. Connect SJT-S as mentioned above.
2. Open project in SIDEARM. Rebuild it.
3. Download the same code in the target board.
4. In SIDEARM go to Tools -> Debugger.
5. In Debugger go to Run -> Click on Not connected to target (click here to connect).
6. Device ID starting from 0x4........ will be displayed and program will run.
7. To stop program go to Run -> Stop. Now you can insert break-point and say Run.
8. You can use all the functions visible in Run option.
9. In variable watch window you can see only global variables.
10. If you have declared any global variables then find their addresses from .map file.
11. Insert these addresses in variable watch window and you can see global variables also.
Page 29 of 84

ADT_V1.1 Lab Manual

7. Program Downloading and related Output


Parameter to
be checked

Buzzer

Procedure

1. Download the program Buzzer.


2. Switch S11.1 should on position.
3. The Buzzer will "ON" and "OFF" after few seconds

1. Follow the above procedure for change port setting.


2. Download the program BLINK.
LED
blinking

3. Switch S19.1 should on position to connect it to 3V3.


4. Switch S19.2 should on position to connect it to 5V.
5. Reset module.
6. The LED D11 TO D18 will be blink.
1. Follow the above procedure for change port setting.
2. Download the program Digital Input.
3. Switch S19.1 should on position to connect it to 3V3.

Digi IO

4. Switch S19.2 should on position to connect it to 5V.


5. Reset module.
6. The LED D11 to D18 will be blink one by one when you press
SW21 to SW28.

1. Follow the above procedure for change port setting.


2. Download the program ADC_Temp.
LM 35 (P0.4)

3. Output will be displayed on the terminal with 19200 Baud


rate.
4. Output of LM35 will be display .

Page 30 of 84

ADT_V1.1 Lab Manual


1. Follow the above procedure for change port setting.
2. Download the program ADC .
On chip
ADC P0.5

3. Vary the POT R15and check O/P.


5. Output will be displayed on the terminal with 19200 Baud
rate.

External_Int
errupt

6.
1.
2.
3.
4.

Output of POT will be display .


Download the program Ext_Int.
Switch LEDs should on position.
Press Snap key "SW18.
The LED D11 (Green LED) will be glow when switch will
press.

1. Follow the above procedure for change port setting.


2. Download the program I2C_RTC.
3. Turn OFF switch S1 & Open the SPJ terminal on PC & set
(com port, baud rate= 19200, stop bit=1, data bit=8,
parity=none).
4. Reset the Module.
I2C RTC

5. "Press S to set RTC date time in DD MM YY HH MM SS


format" will displayed on terminal.
6. Now Press "Y" to set date and time.
7. After set date and time it will continue display date and
time on terminal.
8. Now switch "OFF" the board for one minute and then
switch "ON".
9. On terminal you can see the updated date and time.
1. Follow the above procedure for change port setting.
2. Download the program I2C EEPROM.

I2C
EEPROM

3. Open the SPJ terminal on PC & set (com port, baud rate=
19200, stop bit=1, data bit=8, parity=none).
4. Reset the module.
5. It will display 2 option Read and Write. We have to first
select Write. Type something max of 20 character length.
Page 31 of 84

ADT_V1.1 Lab Manual


And reset the board and select Read option.

4x4 keyboard

Stepper
Motor

1. Download the program 4x4 keyboard.


2. Press all the 16 key one by one.
3. The key number will display on UART

1. Download the program Stepper Motor.


2. The stepper motor will run .

1. Follow the above procedure for change port setting.


2. Download the program LCD.
3. Press RESET to run the program.
LCD 16X2

4. "SPJ EMBEDDED TECHNOLOGIES" displayed on the


16x2 character LCD display.
5. You can set the resolution by using POT R1.
6. If data not display to LCD then check RS, EN, RS pin.

1. Follow the above procedure for change port setting.


2. Turn On S4.3 to connect PWM to Vcc
3. Download the program PWM.
PWM
4. Press RESET to run the program.
5. D20 (RED-GREEN-BLUE) Color of LED will ON.
6. Check waveform on test points PWM1, PWM2, PWM3 ,it
will be square waveform.

UART0

1. Follow the above procedure for change port setting.


2. Download the program for UART0.
3. Turn ON switch S1 & Open the terminal on PC & set (com
port, baud rate= 19200, stop bit=1, data bit=8,
parity=none).
4. Reset Board for giving output.
5. "Hello displayed on the terminal.
6. Turn OFF Switch S1.
7. If found any problem check MAX IC and its continuity
using schematic.
Page 32 of 84

ADT_V1.1 Lab Manual

UART1

DAC

Xbee

Xbee_Switch

1. Follow the above procedure for change port setting.


2. Download the program for UART1.
3. Turn ON switch S4.1 and S4.2 & Open the terminal on PC
& set (com port, baud rate= 19200, stop bit=1, data bit=8,
parity=none).
4. Reset Board for giving output.
5. "Hello displayed on the terminal.
6. Turn OFF switch S2.
7. If found any problem check MAX IC and its continuity.
1.
2.
3.
4.
5.

Download the program DAC.


Switch S11.2should on position.
Connect CRO on DAC Test point.
Output can be observed on D19 LED
The output will be displayed on CRO like as Triangular or
Sine waveform.

1. Follow the above procedure for change port setting.


2. Download the program for Xbee.
3. Turn ON switch S4.1 and S4.2 & Open the terminal on PC &
set (com port, baud rate= 19200, stop bit=1, data bit=8,
parity=none).
4. Reset Board for giving output.
5. "Xbee displayed on the terminal.
6. Writing on UART (Terminal) and it will display on ternimal
off other Xbee board of same Pin ID.
7. If found any problem check MAX IC and its continuity.

1.Download the program Xbee_Switch.


2.Turn the S4.1 and S4.2 switch .
3.Press the Sw21 and the LEDs array will turn ON of other
broad
4.Take one R named and C named Xbee Broad with same code

Page 33 of 84

ADT_V1.1 Lab Manual

8. RTOS And its Codes


The RTX kernel message objects are simply pointers to a block of memory where the relevant
information is stored. There is no restriction regarding the message size or content. The RTX kernel
handles only the pointer to this message.
Sending 8-bit, 16-bit, and 32-bit values
Because the RTX kernel passes only the pointer from the sending task to the receiving task, we can use
the pointer itself to carry simple information like passing a character from a serial receive interrupt
routine. An example can be found in the serial.c interrupt driven serial interface module for the Traffic
example. You must cast the char to a pointer like in the following example:
os_mbx_send (send_mbx, (void *)c, 0xffff);
Sending fixed size messages
To send fixed size messages, you must allocate a block of memory from the dynamic memory pool, store
the information in it, and pass its pointer to a mailbox. The receiving task receives the pointer and
restores the original information from the memory block, and then releases the allocated memory block.
Fixed Memory block memory allocation functions
RTX has very powerful fixed memory block memory allocation routines. They are thread safe and
fully reentrant. They can be used with the RTX kernel with no restriction. It is better to use the fixed
memory block allocation routines for sending fixed size messages. The memory pool needs to be
properly initialized to the size of message objects:
32-bit values: initialize to 4-byte block size.
_init_box (mpool, sizeof(mpool), 4);

any size messages: initialize to the size of message object.


_init_box (mpool, sizeof(mpool), sizeof(struct message))

Page 34 of 84

ADT_V1.1 Lab Manual

Create New RTX Application


This section describes how to create a new application that uses the RTX kernel.
ZIn the Create New Project window, select a new directory for your project and enter a name for
your project.
In the Select Device for Target window, select your target ARM device and click OK. Allow
Vision to copy and add the device startup file to your project. This creates a basic Vision project.
Now setup the project to use the RTX kernel. To do this, select Project > Options for Target.
Then select RTX Kernel for the Operating system and click OK.
Copy the RTX configuration file for your target device from
the \Keil\ARM\RL\RTX\Config\ directory and rename it toRTX_Config.c:
for ARM7/ARM9 devices, copy the configuration file for your specific device. If the file does
not exist for your specific device, then copy the RTX_Conf_LPC21xx.c as a template and modify it
to suit your device.
for Cortex-M devices, copy RTX_Conf_CM.c configuration file.
Modify the device startup file for ARM7/ARM9 devices to enable SWI_Handler function (no
change required for Cortex-M devices):
Comment out the following line from the startup file:
SWI_Handler B SWI_Handler

Add the following line to the startup file:


IMPORT

SWI_Handler

This change prevents the code from sitting in a loop when a SWI interrupt occurs. The change allows the
right function to run when a SWI interrupt occurs.
Copy the retarget.c file from \Keil\ARM\Startup\ to your project directory, and add it to your
project. The main purpose of this file is to avoid the use of semihosting SWIs. Thus the file must
contain the following:

Page 35 of 84

ADT_V1.1 Lab Manual


#include <rt_misc.h>
#pragma import(__use_no_semihosting_swi)
void _ttywrch(int ch) {
// Not used (No Output)
}
void _sys_exit(int return_code) {
label: goto label; /* endless loop */
}
Depending on your application, you might have to retarget more functions. For example if you use
the RL-FlashFS library, you can obtain retarget.c from the \Keil\ARM\RL\FlashFS\SRC\ directory.
Now the project is setup to use the RTX kernel.
Note
For MicroLIB run-time library you do not need a retarget.c in your project.
Now you must configure the RTX kernel for the needs of your application by making the required
changes in theRTX_Config.c file.
Create the application source files if they do not already exist. Add these source files to the project.
You can do this in the project workspace of Vision by right clicking on the Source Group and
selecting Add Files to Group.
When you write programs for RL-RTX, you can define RTX tasks using the __task keyword. You
can use the RTX kernel routines whose prototypes are declared in RTL.h.
1.

Build your application using Project > Build Target.

2.
If you project builds successfully, you can download it to your hardware or run it using the
Vision Simulator. You can alsodebug the application using Debug > Start Debug Session.

Page 36 of 84

ADT_V1.1 Lab Manual

Configuring RL-RTX
The RTX kernel is easy to customize for each application you create. This section describes how
you can configure the RTX kernel's features for your applications. It contains:
Configuration Options
The RTX kernel must be configured for the embedded applications you create. All configuration settings
are found in the RTX_Config.c file, which is located in
the \Keil\ARM\RL\RTX\Config directory. RTX_Config.cis configured differently for the different
ARM devices. Configuration options in RTX_Config.c allow you to:
Specify the number of concurrent running task.
Specify the number of tasks with user-provided stack
Specify the stack size for each task
Enable or disable the stack checking
Enable or disable running tasks in privileged mode
Specify the CPU timer number used as the system tick timer
Specify the input clock frequency for the selected timer
Specify the timer tick interval
Enable or disable the round-robin task switching
Specify the time slice for the round-robin task switching
Define idle task operations
Specify the number of user timers
Specify code for the user timer callback function
Specify the FIFO Queue size
Specify code for the runtime error function
There is no default configuration in the RL-RTX library. Hence, you must add
the RTX_Config.cconfiguration file to each project you create.
To customize the RTX kernel's features, you must change the configurable settings in RTX_Config.c.

Idle Task Customization


When no tasks are ready to run, the RTX kernel executes the idle task with the name os_idle_demon().
By default this task is an empty end-less loop that does nothing. It only waits until another task
becomes ready to run.
You may change the code of os_idle_demon() to put the CPU into a power-saving or idle
mode. MostRTX_Config.c files define the macro _idle_() that contains the code to put the CPU into
a power-saving mode.
Example:

Page 37 of 84

ADT_V1.1 Lab Manual


/*--------------------------- os_idle_demon ---------------------------------*/
__task void os_idle_demon (void) {
/* The idle demon is a system task. It is running when no other task is */
/* ready to run (idle situation). It must not terminate. Therefore it */
/* should contain at least an endless loop.
*/
for (;;) {
}

_idle_(); /* enter low-power mode */

}
Note:
On some devices, the IDLE blocks debugging via the JTAG interface. Therefore JTAG debuggers
such as ULINK may not work when you are using CPU power-saving modes.
For using power-saving modes, some devices may require additional configuration (such as clock
configuration settings).
Error Function Customization
Some system error conditions can be detected during runtime. If RTX kernel detects a runtime error, it
calls the os_error() runtime error function.
void os_error (U32 err_code) {
/* This function is called when a runtime error is detected. */
OS_TID err_task;
switch (err_code) {
case OS_ERR_STK_OVF:
/* Identify the task with stack overflow. */
err_task = isr_tsk_get();
break;
case OS_ERR_FIFO_OVF:
break;
case OS_ERR_MBX_OVF:
break;
}
for (;;);
}

Page 38 of 84

ADT_V1.1 Lab Manual


The error code is passed to this function as a parameter err_code:
Error Code

Description

OS_ERR_STK_O
VF
OS_ERR_FIFO_
OVF
OS_ERR_MBX_
OVF

The stack checking has detected a stack overflow for the


currently running task.
The ISR FIFO Queue buffer overflow is detected.
The mailbox overflow is detected for isr_mbx_send() function.

The runtime error function must contain an infinite loop to prevent further program execution. You can
use an emulator to step over infinite loop and trace into the code introducing a runtime error. For the
overflow errors this means you need to increase the size of the object causing an overflow.

Create New RTX_Config file (for ARM7/ARM9 library)


RL-ARM provides several versions of the RTX_Config.c file for ARM7/ARM9 RTX Kernel
library. Each one configures the RTX kernel for a specific ARM device variant that RL-ARM supports.
However the ARM family of devices is growing quickly, and it is possible that RL-ARM does not
contain the configuration file for the device you use. In this case, you can take the RTX_Config.c file
for the NXP device as a template and modify it for your particular ARM device.
RTX Kernel library for Cortex-M has only one configuration file RTX_Conf_CM.c, which is
common for all Cortex-M device variants.
HW Resources Required
In order to run the RTX kernel, the following hardware resources are required from an ARM device:
Peripheral Timer for generating periodic ticks. It is better to use a peripheral timer with an autoreload function. RTX also supports timers with manual timer (or counter) reload. However, this can
generate jitter and inaccuracy in the long run. The RTX kernel needs a count-up timer. If the timer used
is a count-down timer, you need to convert the timer value.
Timer Interrupts to interrupt the execution of a task and to start the system task scheduler.
Forced Interrupts to force a timer interrupt when isr_ functions are used. If an isr_ function is
called, the kernel forces the timer interrupt immediately after the interrupt ends. The forced timer
interrupt activates the task scheduler. It is possible that a task has become ready. If this task has a higher
priority than the currently running task, a task switch must occur.
All hardware dependent definitions are extracted from the code and defined with configuration macros.
This makes it possible to customize the configuration without modifying the code.

Page 39 of 84

ADT_V1.1 Lab Manual


Note:
The RTX configuration files are located in the \Keil\ARM\RL\RTX\Config directory.
Alternate Tick Timer Configuration (for Cortex-M library)

RTX Library version for Cortex-M devices uses SysTick timer as RTX tick timer. The SysTick
timer is Cortex-M core timer, thus common for all Cortex-M device variants. Some new dual core
devices, such as LPC4300 devices, do not implement the SysTick timer in both cores. In this case, an
alternate tick timer must be used for the core without SysTick timer.
The following functions provide an interface for an Alternate Tick Timer:
os_tick_init()
initializes hardware timer as system tick timer,
os_tick_irqack()
acknowledges hardware timer interrupt,
OS_Tick_Handler()
handles RTX tick interrupts and updates task scheduler.
Configuration
To configure an alternate peripheral timer as system tick timer, you have to:
1. implement the os_tick_init() and os_tick_irqack() functions in the RTX_Config.c configuration
file.
2. replace the alternate timer interrupt vector with the OS_Tick_Handler in the Interrupt Vector
Table in startup file.
Note:
An RTX_Blinky_RIT example, located in \Keil\ARM\Boards\MCB1700 directory, is a demo
example, configured for alternate tick timer in Cortex-M3.
Low Power RTX Configuration
The Low Power RTX extension allows using power-saving modes efficiently and building RTX
applications for power constrained devices such as battery powered devices.
The operation of the OS task scheduler in Low Power mode is different than normal operation. Instead of
executing periodic system tick interrupts when all active tasks are suspended, the system enters a powerdown mode. It calculates how long it can stay in power-down mode and disables power for peripherals
and the CPU. The wake-up timer must remain powered. The time is responsible to wake-up the system
after the power-down period expires.
The following functions provide a Low Power RTX extension:
os_suspend()
suspends OS task scheduler,

Page 40 of 84

ADT_V1.1 Lab Manual


os_resume()
resumes OS task scheduler.
Configuration
The Low Power RTX is controlled from the idle task. The peripheral wake-up timer must be initialized
before the system enters an endless loop.
The function os_suspend() calculates the timeout until the first suspended task becomes ready, and
returns the timeout to the user.
for (;;) {
sleep = os_suspend();
The user sets-up a peripheral timer to sleep timeout and starts the timer. The timeout is measured in
system ticks.
if (sleep) {
/* Setup the wake-up timer ... */
When the wake-up timer is set-up and running, the user puts the system in power-down mode. The
wake-up timer must run also in power-down mode. All other peripherals and the CPU may power-down
to reduce power.
/* Power-down the system ... */
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__WFE();
The wake-up timer, when expired, generates the interrupt and wakes-up the system. Hence, it must run
also in power-down mode. The system resumes operation and needs to call the function os_resume().
This function restores the RTX and re-enables the OS task scheduler.
/* After Wake-up */
sleep = (tc - LPC_WWDT->TV) / 250;
}
os_resume(sleep);
If, for any reason, the system does not wake up immediately after the wake-up interrupt, the
actual sleep time is checked and adjusted.
RTX_LowPower demo examples configured for low power RTX:
Usage of the WFE instruction for entering sleep mode is demonstrated in the RTX_LowPower
example located in the directory \Keil\ARM\Boards\Keil\MCBSTM32F200.
Usage of the WFI instruction for entering sleep mode and early wake-up mechanism is demonstrated
in RTX_LowPower example located in the directory \Keil\ARM\Boards\MCB1000\MCB11U10.
Page 41 of 84

ADT_V1.1 Lab Manual

First Example RTX Application


This section demonstrates an example of using the RTX kernel for a simple application. The
example is located in the folder \Keil\ARM\RL\RTX\Examples\RTX_ex1. The application must
perform two activities. The first activity must continuously repeat 50 ms after the second activity
completes. The second activity must repeat 20 ms after the first activity completes.
Hence, you can implement these activities as two separate tasks, called task1 and task2:
1. Place the code for the two activities into two separate functions (task1 and task2). Declare the
two functions as tasks using the keyword __task (defined in RTL.H) which indicates a RTX task.
__task void task1 (void) {
.... place code of task 1 here ....
}
__task void task2 (void) {
.... place code of task 2 here ....
}
2. When the system starts up, the RTK kernel must start before running any task. To do this, call
the os_sys_init function in the C main function. Pass the function name of the first task as the
parameter to the os_sys_init function. This ensures that after the RTX kernel initializes, the task
starts executing rather than continuing program execution in themain function.
In this example, task1 starts first. Hence, task1 must create task2. You can do this using
the os_tsk_create function.
__task void task1 (void) {
os_tsk_create (task2, 0);
.... place code of task 1 here ....
}
__task void task2 (void) {
.... place code of task 2 here ....
}
void main (void) {
os_sys_init (task1);
}

3. Now implement the timing requirements. Since both activities must repeat indefinitely, place the
code in an endless loop in each task. After the task1 activity finishes, it must send a signal to
Page 42 of 84

ADT_V1.1 Lab Manual


task2, and it must wait for task2 to complete. Then it must wait for 50 ms before it can perform
the activity again. You can use the os_dly_wait function to wait for a number of system intervals.
The RTX kernel starts a system timer by programming one of the on-chip hardware timers of the
ARM processors. By default, the system interval is 10 ms and timer 0 is used (this is
configurable).
You can use the os_evt_wait_or function to make task1 wait for completion of task2, and you
can use the os_evt_setfunction to send the signal to task2. This examples uses bit 2 (position 3)
of the event flags to inform the other task when it completes.
task2 must start 20 ms after task1 completes. You can use the same functions in task2 to wait and
send signals to task1. The listing below shows all the statements required to run the example:

/* Include type and function declarations for RTX. */


#include <rtl.h>
/* id1, id2 will contain task identifications at run-time. */
OS_TID id1, id2;
/* Forward declaration of tasks. */
__task void task1 (void);
__task void task2 (void);
__task void task1 (void){
/* Obtain own system task identification number. */
id1 = os_tsk_self();
/* Create task2 and obtain its task identification number. */
id2 = os_tsk_create (task2, 0);
for (;;) {
/* ... place code for task1 activity here ... */
/* Signal to task2 that task1 has completed. */
os_evt_set(0x0004, id2);
/* Wait for completion of task2 activity. */
/* 0xFFFF makes it wait without timeout. */
/* 0x0004 represents bit 2. */
os_evt_wait_or(0x0004, 0xFFFF);
/* Wait for 50 ms before restarting task1 activity. */
os_dly_wait(5);
}
}
Page 43 of 84

ADT_V1.1 Lab Manual

__task void task2 (void) {


for (;;) {
/* Wait for completion of task1 activity. */
/* 0xFFFF makes it wait without timeout. */
/* 0x0004 represents bit 2. */
os_evt_wait_or(0x0004, 0xFFFF);
/* Wait for 20 ms before starting task2 activity. */
os_dly_wait(2);
/* ... place code for task2 activity here ... */
/* Signal to task1 that task2 has completed. */
os_evt_set(0x0004, id1);
}
}
void main (void) {
/* Start the RTX kernel, and then create and execute task1. */
os_sys_init(task1);
}

4. Finally, to compile the code and link it with the RTX library, you must select the RTX operating
system for the project. From the main menu, select Project > Options for Target. Select
the Target tab. Select RTX Kernel for theOperating system. Build the project to generate the
absolute file. You can run the object file output from the linker either on your target or on the
Vision Simulato

Page 44 of 84

ADT_V1.1 Lab Manual

9.FPGA Programming Steps


Here in ADT V1.1 we are using FPGA Spartan 6( XC6SLX4). For programming it we are using
Xillinx 14.5 ISE, which have all the tools and library to generate .bit file and simulate the VHDL code
written.
This tool create and simulates RTL schematics, Technology schematics, mapping, Routing and
program file generation.

9.1 Quick starts to create VHDL language applications:


1. Start the ISE Project Navigator program (i.e. the Integrated Development Environment) from
START-> All Programs-> Xilinx Design tools -> ISE Design Suite 14.5 -> ISE Design Tools ->
Project Navigator.

2. From FILE menu, select Close project (if any project is open)

Page 45 of 84

ADT_V1.1 Lab Manual


3. Now for open the old project, we have to go to FILE menu -> Open Project. Then select the
appropriate file name of files type as .xise. And click on open.
4. Now to open the New Project, we have to select File Menu -> New Project. Then give the
appropriate Name, Location, Working Directory and Select HDL as Top-level source type and
click on NEXT.

5. Now in New Project Wizard ,we have to configure Project settings. Here we have to set all
details as shown below

Page 46 of 84

ADT_V1.1 Lab Manual


Set Evaluation Development Broad as None Specified,
Set Product Category as All.
Set Family as Spartan6.
Set Device as XC6SLX4
Set Package as TQG144
Set Speed as -3
Set Synthesis tool as XST(VHDL/Verilog)
Set Simulator as Isim (VHDL/Verilog)
Set Preferred language as VHDL
Uncheck the Manual compile Code
Set VHDL Source Analysis Standard as VHDL-93
Then, click on NEXT and then Finish.
6. Now we have to open a new VHDL Module, For it do Right Click on Device ( i.e. xc6slx4-3tqg144)
present in Project Explorer window, and click on New Source.

7. Now in Select file type of New Source Wizard console Select the option VHDL Module, Give
appropriate Name file with the extension .vhd and Click on NEXT.

Page 47 of 84

ADT_V1.1 Lab Manual

8. Then a new window will appear, where we have to define all the required pins, direction and size for
your hardware design ( or in Entity ) and Click NEXT, then a Summary windows appears, check the pins
definition and Click FINISH.

Now we can see our pins in entity definition.

Page 48 of 84

ADT_V1.1 Lab Manual

9.2 Steps for programming PROM File.


1. Do the complete compilation process for Xillinx ISE for generating .bit file

2. Select Project name in Behavioral in implementation pane.


3. In design pane, click on Generate target PROM/ACE File.

Page 49 of 84

ADT_V1.1 Lab Manual

4. It will start running synthesize,implement design,generate programming file. And open impact
window.

5. Click OK and impact window opens.


6. Double Click boundary scan in impact flows.

Page 50 of 84

ADT_V1.1 Lab Manual

17. Right click on console as shown below. And right click and select Initialize tool chain.

18. Click on Yes on pop showing Auto Assign Configuration file

Page 51 of 84

ADT_V1.1 Lab Manual

19. Select file with extension .bit files:

20. After getting the Device Identify Succeeded click on Yes option for Adding SPI or PROM

Page 52 of 84

ADT_V1.1 Lab Manual

21.Click on Apply option for Device Programming Properties and OK:

Page 53 of 84

ADT_V1.1 Lab Manual


21. Right click on Device and select Program

22. Program Succeeded will display on console..

Page 54 of 84

ADT_V1.1 Lab Manual

10. FPGA and uC Interrupt performance Example


10.1 Code for uC:
#include <stdio.h>
#include <LPC214x.h>
#include "Timer.h"
#include "VIC.h"
#include "UART0.h"
unsigned char timer_mode = 0;
unsigned int toggle_mode = 0;
unsigned char Eint1Detect = 0;
unsigned long int Int_Count = 0,Int_Count_Temp = 0;
int volatile j;
//unsigned char FPGA_Count[19];
unsigned long int FPGA_Count=0;
void Eint1ISR(void)__irq;
void Timer0ISR(void)__irq;
void InitEint1(void)
{
PINSEL0 |= 0x20000000 ;
EXTMODE |= 2;
EXTPOLAR = 0;
EXTINT = 0x02;

// Initialize EINT0 Interrupt Pin

//Edge sensitive mode on EINT1


//Falling Edge Sensitive
// Clear EINT1 interrupt flag

}
void Init_VIC_INT(void)
{
VICVectAddr0 = (unsigned long)Eint1ISR;
VICVectCntl0 = 0x20|EINT1_INT;
//bit 5 is enabled the slot to produce unique
interrupt address for enabled timer0 interrupt
VICIntEnable |= (1<<EINT1_INT); //enable timer0 interrupt
}
void Init_VIC_Timer(void)
{
VICVectAddr1 = (unsigned long)Timer0ISR;
VICVectCntl1 = 0x20|TIMER0_INT;
interrupt address for enabled timer0 interrupt
VICIntEnable |= (1<<TIMER0_INT);
}

//bit 5 is enabled the slot to produce unique


//enable timer0 interrupt

int main (void);


Page 55 of 84

ADT_V1.1 Lab Manual


int main (void)
{
unsigned int volatile p;
unsigned int byte1=0,byte2=0,byte3=0,byte4=0;
//IO1DIR |= 0x00010000 ;
IO1DIR |= 0x32000000;
IO1DIR = (IO1DIR &~ 0x00FF0000) ;
Input

// Configure P0.16 to P0.23 as

VPBDIV = 0x01;
InitUart0();
Init_VIC_Timer();
Init_VIC_INT();
printf("Test\n");
TIMER_Init ();
InitEint1();

// Initialize Timer0
// Initialize EINT0

while(1)
{
if(toggle_mode==1)
{
Int_Count = Int_Count_Temp;
Int_Count_Temp=0;
IO1CLR |= 0x30000000;
IO1SET |= 0x02000000 ;
// Set Ack to FPGA as 1
for(p=0;p<10;p++);
byte1 = ((IO1PIN & 0x00FF0000)>>16);
IO1SET |= 0x10000000;
IO1CLR |= 0x20000000;
for(p=0;p<10;p++);
byte2 = ((IO1PIN & 0x00FF0000)>>16);
IO1SET|= 0x20000000;
IO1CLR |= 0x10000000;
for(p=0;p<10;p++);
byte3 = ((IO1PIN & 0x00FF0000)>>16);
IO1SET|= 0x30000000;
for(p=0;p<10;p++);
byte4 = ((IO1PIN & 0x00FF0000)>>16);
IO1CLR |= 0x02000000;
// Set Ack for FPGA as 0
FPGA_Count = (byte1) | (byte2 << 8) | (byte3 << 16) |(byte4 << 24) ;
printf("FPGA_Count = %d Int_Count = %d\n",FPGA_Count,Int_Count);
toggle_mode = 0;
Page 56 of 84

ADT_V1.1 Lab Manual


}
}
}
void Timer0ISR(void)__irq
{
toggle_mode=1;
T0IR = 0xff;
VICVectAddr= 0 ;
}
void Eint1ISR(void)__irq
{
Int_Count_Temp++;
EXTINT = 0x02;
interrupt flag
VICVectAddr= 1 ;
}

// Clear EINT0

Output:
1. Connect UART to PC.
2. Download hex file and after that Program the FPGA.
3. Observe the number of interrupts Scanned by uC and FPGA on serial terminal at every second.
10.2 Code for FPGA using Xilinx:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.std_logic_unsigned.all;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity Freq_Int is
Port ( Int_in : in STD_LOGIC;
Ack : in STD_LOGIC;
addr : in STD_LOGIC_VECTOR(1 downto 0);
data : inout STD_LOGIC_VECTOR(7 downto 0);
Unused : in STD_LOGIC_VECTOR(13 downto 0);
Clk : in STD_LOGIC;
Clk_Gen : out STD_LOGIC);
Page 57 of 84

ADT_V1.1 Lab Manual


end Freq_Int;
architecture Behavioral of Freq_Int is
signal Cnt : STD_LOGIC_VECTOR(31 downto 0):= x"00000000";
signal Count : STD_LOGIC_VECTOR(31 downto 0) := x"00000000";
signal OneSecFlag : STD_LOGIC := '0';
signal ResetCnt : STD_LOGIC := '0';
begin
P1:process(Clk,Cnt)
variable i : integer range 0 to 2500 :=0;
variable j : integer range 0 to 50000000 :=0;
begin
if(Clk= '1' and Clk'Event) then
i := i + 1 ;
j := j + 1 ;
if(i < 62) then
Clk_Gen <= '1';
else
Clk_Gen <= '0';
if (i = 125) then
i:= 0;
end if;
end if;
if(j <50000000) then
OneSecFlag <= '0';
else
Count <= Cnt ;
j := 0;
OneSecFlag <= '1';
end if;
end if;
end process P1 ;
process(OneSecFlag,Int_in)
begin
-if(OneSecFlag= '1' and OneSecFlag'Event) then
-Count <= Cnt ;
-ResetCnt <= '1';
-else
-ResetCnt <= '0';
-end if ;
-if(ResetCnt = '1') then
-Cnt <= x"00000000";
-else
if(OneSecFlag = '1') then
Cnt <= x"00000000";
else
Page 58 of 84

ADT_V1.1 Lab Manual


if(Int_in= '1' and Int_in'Event) then
Cnt <= Cnt + '1' ;
end if ;
end if ;
end process ;
P2:process(Ack,addr,Count)
begin
if(Ack = '1') then
case addr(1 downto 0) is
when "00" =>
data(7 downto 0) <= Count(7 downto 0) ;
when "01" =>
data(7 downto 0) <= Count(15 downto 8) ;
when "10" =>
data(7 downto 0) <= Count(23 downto 16) ;
when "11" =>
data(7 downto 0) <= Count(31 downto 24) ;
when others =>
data(7 downto 0) <= "ZZZZZZZZ" ;
end case;
else
data(7 downto 0) <= "ZZZZZZZZ" ;
end if ;
end process P2;
end Behavioral;

Page 59 of 84

ADT_V1.1 Lab Manual

Output on Terminal:.

Page 60 of 84

ADT_V1.1 Lab Manual

11. Experiments:
11.1 Interfacing Flashing of LEDs:
This program is available in the CD at:
ADT_TOOLS\Source_Codes\Blink:
Connections:
Keep SW19.2 switch in ON position.
8 LEDs (D11 to D18) present on ADT are connected to P0.4,P0.5,P0.6,P0.7,P0.8,P0.9,P0.10 and P0.11
respectively by Common Anode method.

Procedure:
This program is available in the CD at:
ADT_TOOLS\Source_Codes\Blink:
To Edit / Compile/ Generate Hex file: Refer Program Downloading Procedure
Output:
You can see blinking of LEDs.
Note: Keep SW19.2 switch in OFF position to save power, after execution of program.

11.2 Interfacing Buzzer ON-OFF :


This program is available in the CD at:
ADT_TOOLS\Source_Codes\Buzzer:
Connections:
Keep S11.1 switch in ON position.
Page 61 of 84

ADT_V1.1 Lab Manual


Buzzer is connected to P0.26.

Procedure:
This program is available in the CD at:
ADT_TOOLS\Source_Codes\Buzzer:

To Edit / Compile/ Generate Hex file: Refer Program Downloading Procedure


Output:
Buzzer will turn ON and OFF.
Note: Keep S11.1 switch in OFF position, after execution of program.

11.3 Interfacing Digital Input and Output:


This program is available in the CD at:
ADT_TOOLS\Source_Codes\Digital_IO:
Connections:
Keep S19.2 switch in ON position.
Push-button switches SW21 to SW8 are connected from P1.18 to P1.25.
LEDs D9 to D12 are connected to P0.18 to P0.25 and D11 to D18 are connected from P0.4 to P0.11.

Page 62 of 84

ADT_V1.1 Lab Manual

Procedure:
This program is available in the CD at:
ADT_TOOLS\Source_Codes\Digital_IO:
To Edit / Compile/ Generate Hex file:Refer Program Downloading Procedure
To download and run this program:
Output:
After pressing any switch from SW21 to SW28, its corresponding LED (D11 to D18) will become ON
otherwise it will be OFF.

11.4 Interfacing ADC:


Connections:
To give analog input from Potentiometer R15 present in Analog Input region on ADTV1.1. Analog input
range is from 0 to 1023.

Page 63 of 84

ADT_V1.1 Lab Manual

Procedure:
This program is available in the CD at:
ADT_TOOLS\Source_Codes\ADC:
To Edit / Compile/ Generate Hex file:Refer Program Downloading Procedure
To download and run this program:
Output:
You can see output on Hyper Terminal.
Therefore Open Hyper Terminal. Go to Start->All Programs->Accessories->Communications>Hyper Terminal->Assign the Respective port-> Settings. Do proper settings (Baud Rate: 19200, Data
Bits: 8, Stop Bits: 1, Echo: Off, Parity: None, Com Port: Com 1 (if other choose it)). Click on OK. Go to
Port -> Open. If required Reset the ADT board. Now vary the R15 POT and hence see the change in
voltage on Hyper Terminal.

11.5 Interfacing DAC:


Connections:
Connect one pin of oscilloscope to TP2/DAC and another to GND.

Page 64 of 84

ADT_V1.1 Lab Manual


Procedure:
This program is available in the CD at:
ADT_TOOLS\Source_Codes\DAC:
To Edit / Compile/ Generate Hex file:Refer Program Downloading Procedure
To download and run this program:
Output:
You can see ramp wave on oscilloscope.
Note: Keep S11.2 switch in OFF position, after execution of program.

11.6 Interfacing LED and PWM(RGB):


Connections:
Keep S4.3 switch in ON position.

Procedure:
This program is available in the CD at:
ADT_TOOLS\Source\Interfacing LED with PWM(RGB):
To Edit / Compile/ Generate Hex file:Refer Program Downloading Procedure
To download and run this program:
Output:
You can see RED,BLUE,GREEN color blinking on RGB Led.
Note: Keep S4.3 switch in OFF position, after execution of program.

Page 65 of 84

ADT_V1.1 Lab Manual

11.7 Interfacing Real Time Clock on Serial UART:


Connections:
No switches are there to turn ON/OFF I2C RTC:

Procedure:
This program is available in the CD at:
ADT_TOOLS\Source\I2C RTC:

To Edit / Compile/ Generate Hex file:Refer Program Downloading Procedure


To download and run this program:
Output:
You can see output on Hyper Terminal.
Therefore Open Hyper Terminal. Go to Start->All Programs->Accessories->Communications>Hyper Terminal->Assign the Respective port-> Settings. Do proper settings (Baud Rate: 19200, Data
Bits: 8, Stop Bits: 1, Echo: Off, Parity: None, Com Port: Com 1 (if other choose it)). Click on OK. Go to
Port -> Open. If required Reset the ADT board.
On terminal after reset, press Shift-S to set DD MM YY HH MM SS format and press enter.
To save the RTC press Shift-Y,now you can see the RTC getting updated.

11.8 Interfacing I2C based EEPROM:


Connections:
No switches are there to turn ON/OFF I2C EEPROM:
Page 66 of 84

ADT_V1.1 Lab Manual

Procedure:
This program is available in the CD at:
ADT_TOOLS\Source\I2CEEPROM:
To Edit / Compile/ Generate Hex file:Refer Program Downloading Procedure
To download and run this program:
Output:
You can see output on Hyper Terminal.
Therefore Open Hyper Terminal. Go to Start->All Programs->Accessories->Communications>Hyper Terminal->Assign the Respective port-> Settings. Do proper settings (Baud Rate: 19200, Data
Bits: 8, Stop Bits: 1, Echo: Off, Parity: None, Com Port: Com 1 (if other choose it)). Click on OK. Go to
Port -> Open. If required Reset the ADT board.
It will display 2 option Read and Write. We have to first select Write. Type something max of 20
character length. And reset the board and select Read option.

Page 67 of 84

ADT_V1.1 Lab Manual

11.9 Interfacing LCD Keyboard:


Connections:
16 Keys (SW2 to SW17) present in 4x4 Matrix Keypad region on ADT are connected to P1.18 to P1.25.

Procedure:
This program is available in the CD at:
ADT_TOOLS\Source\LCD Keypad:
To Edit / Compile/ Generate Hex file:Refer Program Downloading Procedure
To download and run this program:
Output:
In this program after pressing any key from SW2 to SW17, its code will be displayed on 16x2 Text LCD.

11.10 Interfacing External Interrupt:


Connections:
To connect SW19.2 switch to EINT1 of LPC1768, keep it in ON position

Page 68 of 84

ADT_V1.1 Lab Manual

Procedure:
This program is available in the CD at:
ADT_V1.1\Source\ EINT1
To Edit / Compile/ Generate Hex file:Refer Program Downloading Procedure
To download and run this program:

Output:
EINT1 is configured as Low-active, Level Sensitive. Therefore if SW18 switch is pressed then D11 LED
will glow for that much of time only.
Note: Keep SW19.2 switch in OFF position, after execution of program.

11.11 Interfacing Stepper Motor:


Connections:
No Switches are there to Stepper Motor is connected to P0.28, P0.29, P0.30 and P0.31 through LEDs D7
to D10.
Connect the Stepper motor at connector X3.

Page 69 of 84

ADT_V1.1 Lab Manual

Procedure:
This program is available in the CD at:
ADT_V1.1\Source\ Stepper_Motor
To Edit / Compile/ Generate Hex file:Refer Program Downloading Procedure
To download and run this program:

Output:
You can see stepper motor moving in a particular direction and corresponding phase changes you can
observe on LEDs D7 to D10.

11.12 Interfacing LM 35 (Temperature Sensor)


Connections:
To interface LM35 (present in Analog Input region on ADT Board) with P0.24 .

Page 70 of 84

ADT_V1.1 Lab Manual

Procedure:
This program is available in the CD at:
ADT_V1.1\Source\ ADC_Temperature
To Edit / Compile/ Generate Hex file:Refer Program Downloading Procedure
To download and run this program:
Output:
You can see output on Hyper Terminal.
Therefore Open Hyper Terminal. Go to Start->All Programs->Accessories->Communications>Hyper Terminal->Assign the Respective port-> Settings. Do proper settings (Baud Rate: 19200, Data
Bits: 8, Stop Bits: 1, Echo: Off, Parity: None, Com Port: Com 1 (if other choose it)). Click on OK. Go to
Port -> Open. If required Reset the ADT board.
You can see the temperature on Hyper Terminal changing if you give some heat(even rubbing the sensor
produces heat).

11.13 (A) Interfacing XIGBEE on Serial UART:


Connections:(S2 Xigbee)
Mount Xigbee on Xigbee socket/U3 .Switch ON S4.1 and S4.2(for UART1)
Cxx Indicates Co-Ordinator Xigbee.
Rxx Indicates Router Xigbee.
You should use two different xigbees(Rxx and Cxx)(Ex. R1 and C1) on two different ADT boards.

Page 71 of 84

ADT_V1.1 Lab Manual

Procedure:
This program is available in the CD at:
ADT_V1.1\Source\ Xigbee
To Edit / Compile/ Generate Hex file:Refer Program Downloading Procedure
To download and run this program:
Output:
You can see output on Hyper Terminal.
Therefore Open Hyper Terminal. Go to Start->All Programs->Accessories->Communications>Hyper Terminal->Assign the Respective port-> Settings. Do proper settings (Baud Rate: 19200, Data
Bits: 8, Stop Bits: 1, Echo: Off, Parity: None, Com Port: Com 1 (if other choose it)). Click on OK. Go to
Port -> Open. If required Reset the ADT board.
Press reset on both boards type some thing on keyboard of PC that respective key pressed is transmitted
from that PC to another PC using Xigbee.

11.13 (B) Interfacing XIGBEE and Switch:


Connections:(S2 Xigbee)
Mount Xigbee on Xigbee socket/U3 .Switch ON S4.1 and S4.2(for UART1)
Cxx Indicates Coordinator Xigbee.
Rxx Indicates Router Xigbee.
You should use two different xigbees(Rxx and Cxx)(Ex. R1 and C1) on two different ADT boards.
Procedure:
Page 72 of 84

ADT_V1.1 Lab Manual


This program is available in the CD at:
ADT_V1.1\Source\ Xigbee_Switch
To Edit / Compile/ Generate Hex file:Refer Program Downloading Procedure
To download and run this program:
Output:
Turn on switch SW19.2 and also S4.1,S4.2 of both ADT boards and if required give reset to the board.
Now press switch SW21 of one board,LEDs (D11 to D18) of another board will blink till you press that
switch.
Note: After execution of the program switch off Switches SW19.2 and S4.1/2.

Page 73 of 84

ADT_V1.1 Lab Manual

Appendix:
LPC Xpresso
1. Go to Start -> All Program -> LPCXpresso V7.8.0_426

2. Give the path for the Workspace where you want to save all the project .

Now Click on OK or if we want to change the directory of the workspace Click on Browse and
give the path.

Page 74 of 84

ADT_V1.1 Lab Manual

3. Above IDE will open.


4. On for Closing the Currently open project. Go to Click on Project and then Close Project.

Page 75 of 84

ADT_V1.1 Lab Manual

5. Now for Opening new project we have to Click on File then New then Project.

6. Then, A new Pop-Up Window will appear New Project. There we have to select C/C++. In that
folder Select LPCXpresso C Project. And Click on Next.

Page 76 of 84

ADT_V1.1 Lab Manual

7. Now select the Series of our LPC micro-controller ( Like for LPC1768 we have selected LPC21) and
then select C Project and Click on Next.

Page 77 of 84

ADT_V1.1 Lab Manual


8. Now give the name to the project and check Use Default Location for selecting our workspace as
location.

9. Now select the Micro- controller we are using in the project Click on Next

Page 78 of 84

ADT_V1.1 Lab Manual


10. After adding the micro- controller in the project Check on Enable CRP in the target image. And
Click on Finish.

11. Here our new project is created. Now we can see 3 files are by default present in the src folder.

12. Now open main.c file and write your code in it. And Save it.
13. Now for getting proper .HEX file as build output, Right click on Project folder -> and go to
Properties.
Page 79 of 84

ADT_V1.1 Lab Manual

14. Now go to C/C++ Build and then Settings.

Page 80 of 84

ADT_V1.1 Lab Manual

15. Now in Tool Settings open the list of MCU Compilerand


set Optimization as None(-O0)
Open Managed Linker Script as REDLIB (none)
And Click on Apply.

Page 81 of 84

ADT_V1.1 Lab Manual

16. Now go to Build Steps and click on Edit for Command option.

17. Then, copy the following Command in place of the default commands.
arm-none-eabi-objcopy -O ihex "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.hex"

Page 82 of 84

ADT_V1.1 Lab Manual

18. Click on OK then Apply And then OK.

Page 83 of 84

ADT_V1.1 Lab Manual


19. Now build the program write in the project, We have to click on Build or Go to Project then
Click Build All.

20. If after build No Error is there and .HEX file is created, then damp then .HEX file using Flash magic .

Page 84 of 84

You might also like