Arm Processor Lab Manual - Sep 2024
Arm Processor Lab Manual - Sep 2024
Department Mission
Name: ……………………………………………………………
USN: ……………………….…………………………………….
Batch & Semester: …………….…………………………………
Programme:..……………………………………………………..
1
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504
PEO2: Pursue higher studies and involve in the interdisciplinary research work
PEO3: Exhibit ethics, professional skills and leadership qualities in their profession.
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
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.
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
Lab Insturctor
4
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504
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.
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
AREA myDATA,DATA
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
AREA myDATA,DATA
Count EQU 10
Sum EQU 0
AREA MYCODE,CODE
ENTRY
EXPORT __main
__main
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
ENTRY
EXPORT __main
__main
MOVT.W R0,#0X1234
CMP R1,#00
BNE Label
END
10
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504
AREA myDATA,DATA
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 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.
Features:
12
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504
• 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
14
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504
General Description:
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.
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.
15
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504
Chapter 2
16
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504
Chapter 3
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:
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.
µ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:
17
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504
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)
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
19
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504
20
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504
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
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.
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
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
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.
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.
30
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504
# 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
#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 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
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.
#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;
}
34
BMS Institute of Technology and Management | Dept of ECE
ARM PROCESSOR LAB MANUAL BECL504
A 39 P1.22
B 37 P1.23
C 38 P1.24
D 39 P1.25
#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;
}
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
#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
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 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 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
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.
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