0% found this document useful (0 votes)
68 views40 pages

Arm Processor Lab Manual - Sep 2024

The ARM Processor Lab Manual (BECL504) outlines the educational objectives, outcomes, and practical experiments for Electronics and Communication Engineering students at BMS Institute of Technology and Management. It emphasizes the understanding and application of ARM Cortex M3 microcontroller programming in Assembly and C language, along with interfacing external devices. The manual includes detailed instructions for lab conduct, experiments, and assessment criteria for students.

Uploaded by

aditthi2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views40 pages

Arm Processor Lab Manual - Sep 2024

The ARM Processor Lab Manual (BECL504) outlines the educational objectives, outcomes, and practical experiments for Electronics and Communication Engineering students at BMS Institute of Technology and Management. It emphasizes the understanding and application of ARM Cortex M3 microcontroller programming in Assembly and C language, along with interfacing external devices. The manual includes detailed instructions for lab conduct, experiments, and assessment criteria for students.

Uploaded by

aditthi2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

ARM PROCESSOR LAB MANUAL BECL504

BMS INSTITUTE OF TECHNOLOGYAND MANAGEMENT


Avalahalli, Doddaballapura main road, Yelahanka, Bangalore-560064

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

ARM PROCESSOR LAB MANUAL (BECL504)


V Semester ECE
Department Vision

To provide quality education in the field of Electronics &


Communication Engineering to meet global standards

Department Mission

1. Impart Sound Theoretical and Practical Concepts


2. Promote Inter-disciplinary Research.
3. Inculcate Professional Ethics.

Name: ……………………………………………………………
USN: ……………………….…………………………………….
Batch & Semester: …………….…………………………………
Programme:..……………………………………………………..

1
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

Programme Educational Objectives

Graduates of the programme will:

PEO1: Work as professionals in the area of Electronics, Communication and allied


Engineering fields

PEO2: Pursue higher studies and involve in the interdisciplinary research work

PEO3: Exhibit ethics, professional skills and leadership qualities in their profession.

Programme Specific Outcomes

Graduates will be able to:

PSO1. Demonstrate the knowledge of electronic devices, circuits, micro-nano


electronics and other fundamental courses to exhibit competency in the
domain of VLSI design.

PSO 2. Comprehend the gathered knowledge and technological advancements in the


field of communication and signal processing.

PSO 3. Exhibit the skills gathered to analyze, design, develop software applications
and hardware products in the field of embedded systems and allied areas.

2
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

Programme Outcomes

1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals,


and an engineering specialization for the solution of complex engineering problems.

2. Problem analysis: Identify, formulate, research literature, and analyse complex engineering problems
reaching substantiated conclusions using first principles of mathematics, natural sciences, and
engineering sciences.

3. Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for
public health and safety, and cultural, societal, and environmental considerations.

4. Conduct investigations of complex problems: The problems that cannot be solved by


straightforward application of knowledge, theories and techniques applicable to the engineering
discipline that may not have a unique solution.

5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools, including prediction and modelling to complex engineering activities, with
an understanding of the limitations.

6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional
engineering practice.

7. Environment and sustainability: Understand the impact of the professional engineering solutions in
societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.

8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering practice.

9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.

10. Communication: Communicate effectively on complex engineering activities with the engineering
community and with t h e society at large, such as, being able to comprehend and write effective
reports and design documentation, make effective presentations, and give and receive clear
instructions.

11. Project management and finance: Demonstrate knowledge and understanding of t h e engineering
and management principles and apply these to one’s own work, as a member and leader in a team, to
manage projects and in multidisciplinary environments.

12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.

3
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

Instructions to students
1. Students must bring updated observation book, lab record and manual along with necessary
stationaries, no borrowing from others.
2. Students must handle the PC’s and interfacing components carefully, as they are expensive.
3. Before entering to lab, must prepare for viva for which they are going to conduct experiment.
4. After the completion of the experiment should return the components to the respective lab
instructors.
5. Before leaving the lab, should switch off the power supply and arrange the chairs properly.

Lab In-charges

1. Dr. Suryakanth B M Assistant Professer Dept. of ECE

2. Mr. Shivarudraiah B Assistant Professer Dept. of ECE

Lab Insturctor

1. Mr. Shivamallu Instructor Dept. of ECE

4
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

B.E ELECTRONICS AND COMMUNICATION ENGINEERING


Choice Based Credit System (CBCS)
SEMESTER – V
ARM Processor Lab (0:0:1) 1
(Effective from the Academic Year 2024-25 for 2022 Scheme)
Course Code BECL504 CIE Marks 50
Teaching Hours/Week (L:T:P) 0:0:1 SEE Marks 50
Total Number of Contact Hours 24 Exam Hours 03
Course objectives:
This course will enable students to:
1. Understand the instruction set of ARM Cortex M3, a 32-bit microcontroller and the software
tool required for programming in Assembly and C language.
2. Program ARM Cortex M3 using the various instructions in assembly level language for
different applications.
3. Interface external devices and I/O with ARM Cortex M3.
4. Develop C language programs and library functions for embedded system applications.
Preamble:
This course provides insights into ARM assembly programming and also comprehensive
programming using embedded C language.
Laboratory Experiments
PART-A: Conduct the following Study experiments to learn ALP using ARM Cortex M3 Registers
using an Evaluation board and the required software tool.

1. ALP to multiply two 16-bit binary numbers.


2. ALP to find the sum of first 10 integer numbers.
3. ALP to find number of 0’s and 1’s in a32-bit data.
4. ALP to find whether given 16-bit number is even or odd.
5. ALP to write data to RAM.
PART-B: Conduct the following experiments on an ARM CORTEX M3 evaluation board using
evaluation version of Embedded 'C' & Keil uVision-4 tool/compiler.

1. Interface a simple Switch and display its status through Relay, Buzzer and LED.
2. Display “Hello World” message using Internal UART.
3. Interface and Control a DC Motor.
4. Interface a Stepper motor and rotate it in clockwise and anti-clockwise direction.
5. Interface a DAC and generate Triangular and Square waveforms.
6. Demonstrate the use of an external interrupt to toggle an LED On/Off.
7. Display the Hex digits 0 to F on a 7-segment LED interface, with an appropriate delay in between.

Course outcomes: The students will be able to:

5
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

CO1: Understand the instruction set of 32-bit microcontroller ARM Cortex M3, and the software
tool required for programming in Assembly and C language.
CO2: Develop assembly language programs using ARM Cortex M3 for different applications.
CO3: Interface external devices and I/O with LPC1768 Microcontroller using embedded C
language.
Conduction of Practical Examination:
Question paper pattern:
• The question paper will have two experiments to be conducted.
• Each full question will be for 50 marks.
Conduction of the experiments carries 70% of the total marks. Write-up and Viva carries 15% each
of the total marks.
Alternate Assessment Tools (AATs) suggested:
Open Ended Experiments: Students need to explore experiments beyond the syllabus.

Web links/e-resources:
• https://www.exploreembedded.com/wiki/Category:LPC1768_Tutorials

6
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

PART – A

7
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

1. ALP to multiply two 16 bit binary numbers

AREA DATA1,DATA, READWRITE

RESULT DCD 0X00

AREA myDATA,DATA

Value1 EQU 0002

Value2 EQU 0005

AREA MYCODE,CODE

ENTRY

EXPORT __main

__main

LDR r0,=Value1

LDR r1,=Value2

MUL r2,r1,r0

LDR R3,=RESULT

STR R2,[R3]

stop B stop

END

8
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

2. ALP to find the sum of the first 10 integer numbers.

AREA myDATA,DATA

Count EQU 10

Sum EQU 0

AREA MYCODE,CODE

ENTRY

EXPORT __main

__main

LDR r0, =Count

LDR r1, =Sum

LDR r2, =1

myloop

ADD r1,r2,r1

ADD r2,r2,#1

SUBS r4,r0,r2

BNE myloop

ADD r1,r2,r1

stop B stop

END

9
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

3. ALP to find the number 0’s and 1’s in a 32 bit data.

AREA program, CODE,READONLY

ENTRY

EXPORT __main

__main

MOVW.W R0,#0x5678; Register Rd

MOVT.W R0,#0X1234

MOV R1,#32; Counter register

Label MOVS R0,R0,LSR #1; Logical right shift of number

ADDCS R3,R3,#1; R3 holds number of ones

ADDCC R4,R4,#1; R4 holds number of zeroes

SUB R1,R1,#1; decrementing counter value

CMP R1,#00

BNE Label

END

10
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

4. ALP to find determines whether the given 16 bit is even or odd.

AREA myDATA,DATA

Value1 EQU 1231

AREA MYCODE,CODE

ENTRY

EXPORT __main

__main

LDR r0,=Value1

TST r0,#1

END

11
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

Chapter 1

INTRODUCTION

The LPC-1768 is an ARM Cortex-M3 based microcontrollers for embedded applications


featuring a high level of integration and low power consumption. The ARM Cortex-M3 is a next
generation core that offers system enhancements such as enhanced debug features and a higher level
of support block integration.

The LPC-1768 operate at CPU frequencies of up to 100 MHz. The LPC1768 operates at CPU
frequencies of up to 120 MHz. The ARM Cortex-M3 CPU incorporates a 3-stage pipeline and uses a
Harvard architecture with separate local instruction and data buses as well as a third bus for
peripherals. The ARM Cortex-M3CPU also includes an internal prefetch unit that supports
speculative branching.

The peripheral complement of the LPC-1768 includes up to 512 kB of flash memory, up to


64 kB of data memory, Ethernet MAC, USB Device/Host/OTG interface, 8-channel general purpose
DMA controller, 4 UARTs, 2 CAN channels, 2 SSP controllers, SPI interface, 3 I2C-bus interfaces,
2-input plus 2-output I2S-bus interface, 8-channel 12-bit ADC, 10-bit DAC, motor control PWM,
Quadrature Encoder interface, four general purpose timers, 6-output general purpose PWM, ultra-low
power Real-Time Clock (RTC) with separate battery supply, and up to 70 general purpose I/O pins.
The LPCLPC-1768 are pin-compatible to the 100-pin LPC236x ARM7-based microcontroller series.

Features:

• ARM Cortex-M3 processor, running at frequencies of up to 100 MHz (LPC-1768) A Memory


Protection Unit (MPU) supporting eight regions is included.

• ARM Cortex-M3 built-in Nested Vectored Interrupt Controller (NVIC).
• Up to 512 kB on-chip flash programming memory. Enhanced flash memory accelerator
enables high-speed 120 MHz operation with zero wait states.
• In-System Programming (ISP) and In-Application Programming (IAP) via on-chip boot
loader software.
• On-chip SRAM includes:
❖ 32/16 kB of SRAM on the CPU with local code/data bus for high-performance CPU
access
❖ Two/one 16 kB SRAM blocks with separate access paths for higher throughput. These
SRAM blocks may be used for Ethernet, USB, and DMA memory, as well as for general
purpose CPU instruction and data storage.
• Eight channel General Purpose DMA controller (GPDMA) on the AHB multilayer matrix that
can be used with SSP, I2S-bus, UART, Analog-to-Digital and Digital-to-Analog converter
peripherals, timer match signals, and for memory-to-memory transfers.
• Multilayer AHB matrixes interconnect provides a separate bus for each AHB master.AHB
masters include the CPU, General Purpose DMA controller, Ethernet MAC, and the USB
interface. This interconnect provides communication with no arbitration delays.
• Split APB bus allows high throughput with few stalls between the CPU and DMA.
• Serial interfaces:

12
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

❖ Ethernet MAC with RMII interface and dedicated DMA controller.


❖ USB 2.0 full-speed device/Host/OTG controller with dedicated DMA controller and
on-chip PHY for device, Host, and OTG functions.
❖ Four UARTs with fractional baud rate generation, internal FIFO, and DMA support.
❖ One UART has modem control I/O and RS-485/EIA-485 support, and one UART has
IrDA support.
❖ CAN 2.0B controller with two channels.
❖ SPI controller with synchronous, serial, full duplex communication and programmable
data length.
❖ Two SSP controllers with FIFO and multi-protocol capabilities. The SSP interfaces
can be used with the GPDMA controller.
❖ Three enhanced I2C bus interfaces, one with an open-drain output supporting full I2C
specification and Fast mode plus with data rates of 1 Mbit/s, two with standard port
pins. Enhancements include multiple address recognition and monitor mode.
❖ I2S (Inter-IC Sound) interface for digital audio input or output, with fractional rate
control. The I2S-bus interface can be used with the GPDMA. The I2S-bus interface
❖ Supports 3-wire and 4-wire data transmit and receive as well as master clock
input/output.
• Other peripherals:
❖ 70 (100 pin package) General Purpose I/O (GPIO) pins with configurable pull-
up/down resistors. All GPIOs support a new, configurable open-drain operating mode.
The GPIO block is accessed through the AHB multilayer bus for fast access and
located in memory such that it supports Cortex-M3 bit banding and use by the General
Purpose DMA Controller.
❖ 12-bit Analog-to-Digital Converter (ADC) with input multiplexing among eight pins,
conversion rates up to 200 kHz, and multiple result registers. The 12-bit ADC can be
used with the GPDMA controller.
❖ 10-bit Digital-to-Analog Converter (DAC) with dedicated conversion timer and DMA
support.
❖ Four general purpose timers/counters, with a total of eight capture inputs and ten
compare outputs. Each timer block has an external count input. Specific timer events
can be selected to generate DMA requests.
❖ One motor control PWM with support for three-phase motor control
❖ Quadrature encoder interface that can monitor one external quadrature encoder.
❖ One standard PWM/timer block with external count input.
❖ RTC with a separate power domain and dedicated RTC oscillator. The RTC block
❖ includes 20 bytes of battery-powered backup registers.
❖ WatchDog Timer (WDT). The WDT can be clocked from the internal RC oscillator,
the RTC oscillator, or the APB clock.
❖ ARM Cortex-M3 system tick timer, including an external clock input option.
❖ Repetitive interrupt timer provides programmable and repeating timed interrupts.
❖ Each peripheral has its own clock divider for further power savings.

• Standard JTAG test/debug interface for compatibility with existing tools. Serial Wire Debug
and Serial Wire Trace Port options.
• Emulation trace module enables non-intrusive, high-speed real-time tracing of instruction
execution.

13
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

• Integrated PMU (Power Management Unit) automatically adjusts internal regulators to


minimize power consumption during Sleep, Deep sleep, Power-down, and Deep power-down
modes.
• Four reduced power modes: Sleep, Deep-sleep, Power-down, and Deep power-down.
• Single 3.3 V power supply (2.4 V to 3.6 V).
• Four external interrupt inputs configurable as edge/level sensitive. All pins on Port 0 and Port
2 can be used as edge sensitive interrupt sources.
• Non-maskable Interrupt (NMI) input.
• Clock output function that can reflect the main oscillator clock, IRC clock, RTC clock, CPU
clock, and the USB clock.
• The Wake-up Interrupt Controller (WIC) allows the CPU to automatically wake up from any
priority interrupt that can occur while the clocks are stopped in deep sleep,Power-down, and
Deep power-down modes.
• Processor wake-up from Power-down mode via any interrupt able to operate during Power-
down mode (includes external interrupts, RTC interrupt, USB activity, Ethernet wake-up
interrupt, CAN bus activity, Port 0/2 pin interrupt, and NMI).
• Brownout detect with separate threshold for interrupt and forced reset.
• Power-On Reset (POR).
• Crystal oscillator with an operating range of 1 MHz to 25 MHz.
• 4 MHz internal RC oscillator trimmed to 1 % accuracy that can optionally be used as a system
clock.
• PLL allows CPU operation up to the maximum CPU rate without the need for a high-
frequency crystal. May be run from the main oscillator, the internal RC oscillator, or the RTC
oscillator.
• USB PLL for added flexibility.
• Code Read Protection (CRP) with different security levels.
• Unique device serial number for identification purposes.
• Available as LQFP100 (14 mm x 14 mm x 1.4 mm), TFBGA1001 (9 mm x 9 mm x 0.7 mm),
and WLCSP100 (5.074 x 5.074 x 0.6 mm) package.

14
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

General Description:

VTCM3_2provides a hardware platform for developing embedded system using LPCLPC-


1768 device.

These features make VTCM3_3board ideal for instrumentation, communication and other
demanding application areas where flexibility and in-circuit hardware upgradeability is of
paramount important.

VTCM3_3board comes with complete drivers for windows98/Me/2000/XP/2007.LPC-LPC-


1768 code examples and windows DLL interface which can be used to interface it to most
common programming language.

It comes with complete Kiel development software and sample codes. It is also ideal for
classroom training in colleges and universities. Engineers can upgrade their hardware
development Skills using ARM CORTEX-M3.

VTCM3_3board consists of the following:-


• VTCM3_3board fitted in soft wooden box.
• USB Cable for Hex File downloading and 5v dc power for VTCM3_3 board .
• Inbuilt ADC, DAC, RTC
• RESET, ISP Program buttons.
• Eight digital input and Eight Digital output.
• 16X2 LCD Display.
• Four digit seven segment display.
• 20 pin box Header for JATAG debugging.
• I/O pin made available through 20pin, 26pin and 30 pin Box headers.
• Technical/Operational Manual with hardware Schematics and Sample Programs.
• Software CD.

15
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

Chapter 2

LPC 1768 Pin out and Instruction Set

2.0 LPC1768 Pin-Out Diagram

16
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

Chapter 3

Create application using KEIL µVision5

3.1 Create Application Using µVision5.

This chapter describes the Build Mode of µVision and explains the user interface; outlines the options
for generating and maintaining projects, including output file options, and highlights configuration
options for optimum code quality.

The required steps for creating application programs are listed below:

1. Create Project File explains how to create a µVision5 project file.


2. Select Device describes how tool settings, peripherals, and dialogs are customized.
3. Set Options for Target explains how to specify relevant parameters for your target.
4. Create Source File describes how to add new files to the project.
5. Configure a Target

Configure Cortex-M Target describes how to change the startup-code and how to use the
library retarget file for Cortex-M devices. In addition, this is a brief explanation of CMSIS.

6. Create File Group explains how to structure the code files for a better overview.
7. Specify Memory Layout describes how to change file and group attributes.
8. Build Project describes the build-options.

3.2 Package Installer:

1. Select Project - NewµVision Project from the µVision menu.


This opens a standard Windows dialog, which prompts you for the new project file

3.3 Create Project File

µVision5 maintains the files that belong to a project in one project file. It takes only a few steps to
create a new project file with µVision4:

1. Select Project - New Project from the µVision5 menu.


This opens a standard Windows dialog, which prompts you for the new project file name.

17
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

2. Create a new folder Test.

3. Switch to the new folder and type the project name Test1. µVision4 automatically adds the
extension .uvproj.
4. Click Save & Select Device for Target ‘Target 1’ is opened, select NXP
When you create a new project, µVision4 asks you to select a microcontroller. This step
customizes the µVision4 environment with pre-configured options and sets the tool options,
peripherals, and dialogs for that particular device. The Select Device for Target dialog shows
the µVision Device Database.

Select the microcontroller you use. For this example, choose the NXP(founded by philips)

Select the device LPC-1768 and click OK as shown above

5 Now Manage Run Time Environment window will open as shown in the fig below.

❖ Expand CMSIS option and select the CORE by selecting the check box.

18
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

❖ Expand Device option and select the Startup, GPIO,PIN and GPDMA by selecting
the check box.

6 Now the Target is created. Right Click on Target1 and Select Option for Target
‘Target1’…..
OR Press Alt+F7

7 Now the Option for Target ‘Target1’window will open.

a. Select the Xtal (MHz):12.0 in Target Menu

19
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

b. Select Create HEX File Check box in Output menu

20
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

c. Enter R/W Base address as 0x10000000 in Linker Menu.

21
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

8 Click on new document for writing the program & save the code with .c extension in desired
folder.

22
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

9 Expand the Target 1 in the Project folder

10 Right click on the source Group1 & select Add Files to Group ‘Source Group 1’. Select the
file from the folder where project is saved & click on add.

3.4 Build Project

Build the project once the coding is done and check for errors. For building the project click F7 or
click on below shown option.

23
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

1. Translate and link the source files of the application with a click on one of the
build-buttons located in the Build Toolbar.
2. Errors or warnings are displayed in the Build Output Window. Double-click on a message
to jump to the line where the incident occurred.

3. Once you have generated your application successfully, you can start debugging.

24
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

Chapter 4

Down loading Hex File to LPC 1768

4.1 Click on the Flash Magic Icon installed over desktop

Click on Select Device Button, expand ARM Cortex option & select the device LPC-1768

25
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

4.2 Select the COM Port Name, follow these Steps for knowing the PORT Name
a. Insert one end of the USB cable to the USB Port and Other end to kit.
b. Right Click on My Computer option from the desktop and select Manage Option as
shown in the below figure.

c. Click on Manage button and select the Device Manager Option as shown below

26
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

d. Expand Ports option on the right hand side to see the Serial port name of the USB
Connected. For Example : USB Serial Port(COM8)

e. Once the PORT name is known Select from COM Port dropdown, Set the Baud
Rate and Oscillator (MHz) to 115200 and 12.0 respectively & check the Erase Flash+Code
Rd prot Used by Hex file.

27
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

f. Select the program from the desktop machine on click of Browse button

28
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

g. Once the program is selected click on the Start Button for downloading the code. Program
is downloaded through USB Port & check for the desired Output.

h. Now Press the Reset Button on VTCM3_B_1 kit and check for the desired output.

PART - B

29
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

Chapter 5

Hardware Details and Programs

1. Relay Configurations:
A relay is an electrically operated switch. Many relays use an electromagnet to operate a
switching mechanism mechanically, but other operating principles are also used. Relays are
used where it is necessary to control a circuit by a low-power signal (with complete electrical
isolation between control and controlled circuits), or where several circuits must be controlled
by one signal. The first relays were used in long distance telegraph circuits, repeating the
signal coming in from one circuit and re-transmitting it to another. Relays were used
extensively in telephone exchanges and early computers to perform logical operations.
K1 is an electromagnetic relay which is connected to P0.25 through Dip
switch. We need to send logic ‘1’ to switch on relay.J9 is three pin PBT terminal used to
connect external device to relay. Table shows connections for Relay.

Relay connection table.

Relay coil LPC-1768 LPC-1768


Pin No Port No
Relay 07 P0.25

BUZZER & SPEAKER Pin Configuration.


A buzzer or beeper is an audio signaling device, which may
be mechanical, electromechanical, or piezoelectric. Typical uses of buzzers and beepers
include alarm devices, timers and confirmation of user input such as a mouse click or
keystroke. LS1 is a small 12mm round buzzer that operates around the audible 2kHz range.
We drove it through Q8 which in turn connected to P3.25.We need to send Logic ‘1’ to
generate beep.

A speaker is a device which converts electrical signal to audible signal.J7 is a two pin RMC
where we are connecting external speaker. We drove it through Q5 which in turn connected
to P3.25 via Jumper JP2.We need to send Logic ‘1’ to generate Tone.

Speaker /Buzzer pin connection Table.

Speaker/ LPC-1768 LPC-1768


Buzzer Pin Pin No Port No
1 27 P3.25

30
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

1. Write an Embedded C Program using ARM CORTEX M3 to interface a simple Switch


and display its status through Relay, Buzzer and LED

# include <LPC17XX.h>
#define key1 (1<<14)
#define key2 (1<<15)
#define key3 (1<<16)
#define led (1<<4)
#define relay (1<<25)
#define buzz (1<<25)
#define key_pin LPC_GPIO1 -> FIOPIN
int main(void)
{
LPC_GPIO0-> FIODIR|=led;
LPC_GPIO0 -> FIOCLR=led ;
LPC_GPIO0 -> FIODIR |=relay ;
LPC_GPIO0 -> FIOCLR=relay ;
LPC_GPIO3-> FIODIR |=buzz ;
LPC_GPIO3-> FIODIR =buzz ;
LPC_GPIO1-> FIODIR =~(key1/key2/key3) ;
LPC_GPIO1-> FIOSET =~(key1/key2/key3) ;
while(1)
{
if(!(key_pin&key1))
LPC_GPIO0 -> FIOSET=led ;
else
LPC_GPIO0 -> FIOCLR=led ;
if(!(key_pin&key2))
LPC_GPIO0 -> FIOSET=relay;
else
LPC_GPIO0 -> FIOCLR=relay;
if(!(key_pin&key3))
LPC_GPIO3 -> FIOSET=buzz;
else
LPC_GPIO3 -> FIOCLR=buzz;
}
}

31
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

2. Write an Embedded C Program to display “Hello World” message using Internal


UART

#include "LPC17xx.h"
#define FOSC 12000000 /* oscillator frequency */
#define FCCLK (FOSC * 8) /* master clock frequency <= 100Mhz */
/* FOSC an integer multiple of */
#define FCCO (FCCLK * 3) /* PLL frequency (275Mhz to 550Mhz) */
/* Same as FCCLK, or which even multiples */
#define FPCLK (FCCLK / 4) /* peripheral clock frequency, FCCLK 1/2, 1/4 Or
FCCLK, the same*/
#define UART0_BPS 115200 /* Serial communication baud rate 9600 */
void UART0_Init (void)
{
unsigned int usFdiv;
/* UART0 */
LPC_PINCON->PINSEL0 |= (1 << 4) | (1 << 6); /* Pin P0.2 used as TXD0 (Com0) */
/* Pin P0.3 used as RXD0 (Com0) */
LPC_UART0->LCR = 0x83; /* allows you to set the baud rate */
usFdiv = (FPCLK / 16) / UART0_BPS; /* set the baud rate */
LPC_UART0->DLM = usFdiv / 256;
LPC_UART0->DLL = usFdiv % 256;
LPC_UART0->LCR = 0x03; /* Lock the baud rate */
LPC_UART0->FCR = 0x06;
}

int UART0_SendByte (int ucData)


{
while (!(LPC_UART0->LSR & 0x20));
return (LPC_UART0->THR = ucData);
}

int UART0_GetChar (void)


{
while (!(LPC_UART0->LSR & 0x01));
return (LPC_UART0->RBR);
}

int main(void)
{
unsigned int rep;
UART0_Init();
while(1)
{
rep=UART0_GetChar();
UART0_SendByte(rep);
}
}
32
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

3. DC Motor Pin Configuration

DC (direct current) motor rotates continuously. It has two terminals positive and negative.
Connecting DC power supply to these terminals rotates motor in one direction and reversing
the polarity of the power supply reverses the direction of rotation.

The speed of Dc motor can maintained at a constant speed for a given load by using “Pulse
Width Modulation (PWM)” technique. By changing the width of the pulse of applied to dc
motor, the power applied is varied thereby DC motor speed can be increased or decreased.
Wider the pulse Faster is the Speed, Narrower is the Pulse, and Slower is the Speed

U9 is L293 driver IC used to drive the dc motor. It has enable lines which is used to switch
on the DC motor. It is connected to P4.28. Logic ‘1’ enables the driver and logic ‘0’ disables
the driver.P4.28 and P4.29 are used for Motor 1 direction and speed control.

DC Motor Pin connection table.

Motor Motor LPC-1768 LPC-1768


Selection Direction Pin No Port No
P4.28=1 &
DCM0-Clk 82
P4.29=0
Motor 85 P4.28=0 &
DCM1-Aclk
P4.29=1
DCM_EN 65 P2.8=1

3. Write an Embedded C Program using ARM CORTEX M3 to Interface and Control a


DC Motor

#include<LPC17XX.H>
#define KEY_PIN LPC_GPIO1 -> FIOPIN
#define KEY_STOP (1<<14)
#define KEY_INC (1<<15)
#define KEY_DEC (1<<16)
#define KEY_CW (1<<17)
#define KEY_CCW (1<<18)
void delay(unsigned int count)
{
unsigned int j=0,i=0;
for(j=0;j<count;j++)
{
for(i=0;i<12000;i++);
}
}
int main(void)
{
uint8_t count = 0,match=5;

33
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

uint32_t dir=0x02;
LPC_GPIO4 -> FIODIR |= 0X30000000;
LPC_GPIO2 -> FIODIR |= (1<<8);
LPC_GPIO2 -> FIOCLR |= (1<<8);
LPC_GPIO1 -> FIODIR &= ~(KEY_STOP|KEY_INC|KEY_DEC|KEY_CW|KEY_CCW);
LPC_GPIO1 -> FIOSET |=(KEY_STOP|KEY_INC|KEY_DEC|KEY_CW|KEY_CCW);
while(1)
{
if(!(KEY_PIN & KEY_STOP))
{
LPC_GPIO4 -> FIOPIN = 0x30000000;
LPC_GPIO2 -> FIOPIN = 0x00000100;
}
if(!(KEY_PIN & KEY_CCW))
{
LPC_GPIO4 -> FIOPIN = 0x10000000;
LPC_GPIO2 -> FIOPIN = 0x10000100;
}

if(!(KEY_PIN & KEY_CW))


{
LPC_GPIO4 -> FIOPIN = 0x20000000;
LPC_GPIO2 -> FIOPIN = 0x00000100;
}
if(!(KEY_PIN & KEY_INC))
{
if( match<10 ) match += 1;
while(!(KEY_PIN & KEY_INC));
}
if(!(KEY_PIN & KEY_DEC))
{
if(match>=1)match-=1;
while(!(KEY_PIN & KEY_DEC));
}
delay(10);
count++;
if(count >= match)
LPC_GPIO2 -> FIOCLR = (1<< 8);
else
LPC_GPIO2 -> FIOSET = (1<< 8);
if(count>10) count = 0;
}
}

34
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

4. Stepper Motor Configuration:


A stepper motor is a special type of electric motor that moves in increments, or steps, rather
than turning smoothly as a conventional motor does. Typical increments are 0.9 or 1.8
degrees, with 400 or 200 increments thus representing a full circle. The speed of the motor is
determined by the time delay between each incremental movement.
U8 is a Driver Buffer (ULN2003) device connected to LPC-1768 Device and can be used for
driving Stepper Motor. On the LPC-1768, P1.22 to P1.25 is used to generate the pulse
sequence required to run the stepper Motor. Also, the Stepper Motor is powered by its own
power supply pin (COM), which is connected to a 12V supply. Table shows connections for
stepper Motor.

Stepper Motor Pin connection table.


Stepper LPC-1768 LPC-1768
Motor Coil Pin No Port No

A 39 P1.22
B 37 P1.23
C 38 P1.24
D 39 P1.25

4. Write an Embedded C Program using ARM CORTEX M3 to Interface a Stepper motor


and rotate it in clockwise and anti-clockwise direction

#include<LPC17XX.H>
#define MOTOR_CTRL_DIR LPC_GPIO1 -> FIODIR
#define MOTOR_CTRL_SET LPC_GPIO1 -> FIOSET
#define MOTOR_CTRL_CLR LPC_GPIO1 -> FIOCLR
#define MOTOR_MASK 0x03C00000
#define KEY_DIR LPC_GPIO1 -> FIODIR
#define KEY_SET LPC_GPIO1 -> FIOSET
#define KEY_CLR LPC_GPIO1 -> FIOCLR
#define KEY_PIN LPC_GPIO1 -> FIOPIN
#define KEY_START (1<<14)
#define KEY_STOP (1<<15)
#define KEY_INC (1<<16)
#define KEY_DEC (1<<17)
#define KEY_CW (1<<18)
#define KEY_CCW (1<<19)
#define BUZZ (1<<25)
void motor_write(uint32_t data)
{
uint32_t temp;
temp=(data<<22) & MOTOR_MASK;
MOTOR_CTRL_CLR |= MOTOR_MASK;
MOTOR_CTRL_SET |= temp;
}

void delay (unsigned int count)

35
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

{
unsigned int j=0,i=0;
for(j=0;j<count;j++)
{
for(i=0;i<12000;i++);
} }
int main(void)
{
unsigned int del=10;
uint32_t stpval =0x01;
unsigned char dir =0;
unsigned char run =1;
MOTOR_CTRL_DIR |= MOTOR_MASK;
KEY_DIR&= ~(KEY_START|KEY_STOP|KEY_INC|KEY_DEC|KEY_CW|KEY_CCW);
KEY_SET|= (KEY_START|KEY_STOP|KEY_INC|KEY_DEC|KEY_CW|KEY_CCW);
LPC_GPIO3 -> FIODIR |= BUZZ;
LPC_GPIO3 -> FIOCLR |= BUZZ;

delay(3000);
motor_write(stpval);
while(1)
{
if(!(KEY_PIN &KEY_START))
run=1;
if(!(KEY_PIN &KEY_STOP))
run=0;
if(!(KEY_PIN &KEY_CW))
dir=0;
if(!(KEY_PIN &KEY_CCW))
dir=1;
if(!(KEY_PIN &KEY_INC))
if(del != 10)
del=del-1;
if(!(KEY_PIN &KEY_DEC))
if(dir != 100)
del=del+1;
if(run==1)
{ if(dir==0)
{ if(stpval==8)
stpval=1;
else stpval <<=1; }
else if(stpval==1)
stpval=8;
else stpval >>=1; }
motor_write(stpval);
delay(del);
} }

36
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

5. DAC Features
• 10-bit digital to analog converter • Resistor string architecture
• Buffered output • Selectable speed vs. power
• Maximum update rate of 1 MHZ.

As VTCM3_3 board comes with one DAC output for generation different wave forms. AOUT
(P0.26) is connected to TEST point TP1. The generated waveforms can be viewed through
TP1 (DAC) and TP2 (GND) by connecting CRO.

5.1 Write an Embedded C Program using ARM CORTEX M3 to interface a DAC and
generate Square waveform
#include<lpc17xx.h>
int main(void)
{
uint32_t m;
LPC_PINCON->PINSEL1=(1<<21);
LPC_GPIO3->FIODIR=0X02000000;
while(1)
{
LPC_GPIO3->FIOCLR=0X02000000;
LPC_DAC->DACR=(1<<6);
for(m=1024;m>1;m--);
LPC_DAC->DACR=(1023<<6);
for(m=1024;m>1;m--);
} }

5.2 Write an Embedded C Program using ARM CORTEX M3 to interface a DAC and
generate Triangular waveforms
#include <LPC17xx.H> /* NXP LPC17xx definitions
int main (void)
{
uint32_t i = 0;
uint32_t m;
LPC_PINCON->PINSEL1 = (1<<21); //Select AOUT function for P0.26
LPC_GPIO3->FIODIR = 0x02000000; //set direction of the buzzer
while(1)
{
LPC_GPIO3->FIOCLR =0x02000000; //clr buzzer sound
for(i = 0; i < 1024; i++)
{ LPC_DAC->DACR = (i << 6);
for(m = 10; m > 1; m--); }
for(i = 1024; i > 0; i--)
{ LPC_DAC->DACR = (i << 6);
for(m = 10; m > 1; m--); }
}
}

37
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

6. Write an Embedded C Program to demonstrate the use of an external interrupt


to toggle an LED On/Off.

#include <lpc17xx.h>
#define PINSEL_EINT0 20
#define PINSEL_EINT1 22
#define LED1 (1 << 4) //p0.4
#define LED2 (1 << 5) //p0.5
#define SBIT_EINT0 0
#define SBIT_EINT1 1
#define SBIT_EXTMODE0 0
#define SBIT_EXTMODE1 1
#define SBIT_EXTPOLAR0 0
#define SBIT_EXTPOLAR1 1

void EINT0_IRQHandler(void)
{
LPC_SC->EXTINT = (1<<SBIT_EINT0); /* Clear Interrupt Flag */
LPC_GPIO0->FIOPIN ^= LED1; //Toggle the LED1 everytime INTR0 is generated
}

void EINT1_IRQHandler(void)
{
LPC_SC->EXTINT = (1<<SBIT_EINT1); /* Clear Interrupt Flag */
LPC_GPIO0->FIOPIN ^= LED2; //Toggle the LED2 everytime INTR1 is generated
}

int main()
{
LPC_SC->EXTINT = (1<<SBIT_EINT0) | (1<<SBIT_EINT1);
/* Clear Pending interrupts */
LPC_PINCON->PINSEL4 = (1<<PINSEL_EINT0) | (1<<PINSEL_EINT1);
/* Configure P2_10,P2_11 as EINT0/1 */
LPC_SC->EXTMODE = (1<<SBIT_EXTMODE0) | (1<<SBIT_EXTMODE1);
/* Configure EINTx as Edge Triggered*/
LPC_SC->EXTPOLAR = (1<<SBIT_EXTPOLAR0)| (1<<SBIT_EXTPOLAR0);
/* Configure EINTx as Falling Edge */
LPC_GPIO0->FIODIR = (LED1 | LED2); /* Configure LED pins as OUTPUT */
LPC_GPIO0->FIOPIN = 0x00;
NVIC_EnableIRQ(EINT0_IRQn); /* Enable the EINT0,EINT1 interrupts */
NVIC_EnableIRQ(EINT1_IRQn);
LPC_GPIO3->FIODIR = 0x02000000; //set direction of the buzzer
while(1)
{
LPC_GPIO3->FIOCLR =0x02000000;//clr buzzer sound
}
}

38
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

7. Hardware Configurations - SEVEN SEGMENT DISPLAY

LED Pin Configuration: VTCM3_3board provides eight individual SMD led’s connected to
LPC-1768 device through 74HC151driver IC. D1 to D8 are connected to general purpose I/O
pins on LPC-1768 device as shown in table(14) When LPC-1768 device drives Logic ‘1’ the
corresponding LED turns on.

LED Pin connection table.

LED D1 D2 D3 D4 D5 D6 D7 D8
LPC-1768
81 80 79 78 77 76 48 49
Pin No
LPC-1768
P0.4 P0.5 P0.6 P0.7 P0.8 P0.9 P0.10 P0.11
Port No

SEVEN SEGMENT DIPLAY Pin Configuration:


D11, D12, D13 and D14 are Common Cathode segments connected to LPC-1768 device so
that each segment is individually controlled by a general purpose I/O pin. When the LPC-
1768 device drives logic ‘0’ the corresponding segment turns on. See fig and table for more
details.

D9 D10 D11 D12


Seven Segment Pin connection table.

Seven
Segment g f a b p c d e
Data Lines
LPC-1768 Pin
75 74 73 70 69 68 67 66
No
LPC-1768
P2.0 P2.1 P2.2 P2.3 P2.4 P2.5 P2.6 P2.7
Port No

SEVEN SEGMENT Selection Pin Configurations:

As VTCM3_3 board comes with 4 digit seven segment unit. Displays connected to the
microcontroller usually occupy a large number of valuable I/O pins, which can be a big
39
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504

problem especially if it is needed to display multi digit numbers. The problem is more than
obvious if, for example, it is needed to display four digit numbers (a simple calculation shows
that 32 output pins are needed in this case). The solution to this problem is called
MULTIPLEXING. This is how an optical illusion based on the same operating principle as a
film camera is made. Only one digit is active at a time, but they change their state so quickly
making impression that all digits of a number are simultaneously active. Each digit can made
active using switching transistors Q1, Q2, Q3 and Q4 and these on switched on and off by
selection lines which are in turn connected to LPC-1768 ports. Table shows the details of
seven segment selection lines.

Seven Segment Selection table.

Seven Segment Disp1 Disp2 Disp3 Disp4


Selection Lines (D9) (D10) (D11) (D12)
LPC-1768 Pin No 40 43 44 45
LPC-1768 Port No P1.26 P1.27 P1.28 P1.29

7. Write an Embedded C Program using ARM CORTEX M3 to display the Hex digits 0 to F
on a 7-segment LED interface, with an appropriate delay in between.
#include <lpc17xx.h>
#define DIG1 (1<<26)
#define BUZZ (1<<25)
unsigned char data7[ ] ={0x88,0XEB,0X4C,0X49,0X2B,0X19,0X18,0XCB,
0X08,0X0B,0X09,0X38,0X9C,0X68,0X1C,0X1E};
int main (void)
{
unsigned int i,j;
unsigned int count=0;
LPC_GPIO2->FIODIR=0X000000FF;
LPC_GPIO2->FIOPIN=0X000000FF;
LPC_GPIO1->FIODIR|=0X3C000000;
LPC_GPIO1->FIOPIN&=~(0X3C000000);
LPC_GPIO3->FIODIR|=BUZZ;
LPC_GPIO3->FIOCLR=BUZZ;

while(1)
{
++count;
if(count>0x000F) count=0;
for(i=0;i< 4000;i++)
{
LPC_GPIO2->FIOPIN=data7[count &0X000F];
LPC_GPIO1->FIOSET=DIG1;
for(j=0;j<500;j++);
LPC_GPIO1->FIOCLR=DIG1;
}
}
}

40
BMS Institute of Technology and Management | Dept of ECE

You might also like