Ece3162 Mplabmanual 2023
Ece3162 Mplabmanual 2023
EXPERIMENT
NO NO
10 ARM 7 C PROGRAMMING - II 30
ECE 3162: MICROPROCESSOR LAB [0062]
COURSE OBJECTIVES
CO1: Write ARM7 assembly language, embedded C programs and simulate using Keil
IDE
CO2: Demonstrate interfacing ARM7 with peripheral devices
CO3: Identify an embedded system to implement using 8 bit or 32-bit microcontrollers
CO4: Integrate and apply the knowledge of electronics, microcontrollers, software tools
and technology to implement the embedded system.
CO5: Demonstrate the developed project effectively as a member of the project team.
INSTRUCTIONS TO THE STUDENTS
1. Students should carry the Lab Manual and Observation Book to every lab session.
2. Be on time and follow the institution dress code.
3. You should try to analyze and understand the solved problems and then try to solve all
the exercise problems of the experiment in the lab.
4. Maintaining an observation copy is compulsory for all, where in the results of all the
problems solved in the lab should be properly noted down.
5. You have to get your results verified and observation copies checked by the instructor
before leaving the lab for the day.
6. You should maintain a folder of all the programs you do in the lab in the computer you
use by your registration number. You are also advised to keep a back-up of it.
7. Use of external storage media during lab is not allowed.
8. Maintain the timings and the discipline of the lab.
EVALUATION PLAN
• Internal Assessment Marks : 60% (60 marks)
✓ Continuous evaluation component (for each experiment):10 marks
✓ Assessment is based on, preparation, conduction of each experiment, exercise problems,
maintaining the observation note and answering the questions related to the experiment.
✓ Total marks of the10 experiments scaled to 60 marks
Note: Follow code of conduct (punctual, discipline, and sincere)
• End semester assessment: 40 %(40 marks)
✓ Write up: 12 marks
✓ Conduction: 12 marks
✓ Results: 8 marks
✓ Viva –Voce: 8 marks
• Mini Project assessment: 100% (100 marks)
✓ Presentation of project idea: 20 marks
✓ Progress presentation: 30 marks
✓ Report: 20 marks
✓ Working project demonstration: 30 marks
Final grading will be the average of Mini-project (100 marks) and Regular labs (100 marks)
1
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
Expt. No. 1
INTRODUCTION TO ARM7 ASSEMBLY LANGUAGE
PROGRAMMING (ADDRESSING MODES)
Aim: To understand basics of ARM7 programming and simulation
1.To get familiar with ARM7 programming
Note: For the above program try following with immediate data:
a) line3: 0Xffff, line4: 8_25765, line5:825 and conclude
b) line3: 0x3E8, line4: 8_275, line5:16000 and conclude
c) line3: 0xC000003F, line4: 8_275, line5:16000 and conclude
d) Replace MVN instruction with MOV.
2. Program to use EQU, and Access address/data from data / code Memory
2
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
Note: Use LTORG between line8 and 9 and check the difference.
3
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
Exercise:
Write a program to read one byte, one half-word and on word at data memory locations
starting from 0x40000000 (enter during runtime) and store these data back at data memory
locations starting from 0x4000001C.
Note:
a. Use ROR, RRX, and ASR.
b. Can rotate left instruction be used?
6.Program to understand SWP instruction
4
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
Expt. No. 2
INTRODUCTION TO ARM7 ASSEMBLY LANGUAGE
PROGRAMMING (DATA PROCESSING-I)
Aim: To understand data processing
1.Program to check whether the number is even or odd.
Exercise:
Write a program to perform logical operations on two 48 bit numbers
6
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
Exercise:
1. Write a program to check whether or not read number is positive.
2. Write a program to separate an array ten numbers into even array and odd array.
3. Write a program to count number of 1’s present in a word.
4. Write a program to arrange N half-words in descending order.
5. Write a program to verify that word read from memory is nibble-wise palindrome
(ex: 0x1221 is nibble-wise palindrome)
6. Write a program to verify that byte read from memory is bit-wise palindrome (ex:
b_10111101 is bit-wise palindrome)
Expt. No. 3
INTRODUCTION TO ARM7 ASSEMBLY LANGUAGE
PROGRAMMING (DATA PROCESSING-II)
Aim: To understand data processing (Arithmetic operations)
1.Program with different arithmetic instructions.
Note: Include S at the end in ADD, ADC, SUB, SBC,RSB, RSC and BIC of the above
program and observe the CPSR register and data memory.
2.Program to add two 16-bit numbers
Exercise:
a) Write a program add two four digit Binary Coded Decimal numbers.
10
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
Expt. No. 4
ASSEMBLY LANGUAGE PROGRAMMING GPIOs TO INTERFACE LEDS,
SWITCHES BUZZER AND RELAY
Aim: To program general purpose input output pins of Arm7 to interface switches,
LEDs and Buzzer
1.Program to display ring count on (P0.16-P0.23 pins) LEDs (Active low )
Exercise:
a) Write an Assembly Language Program (ALP) to display 8-bit Johnson’s count.
b) Write an ALP to display Mod-16 up count on LED circuit.
c) Write an ALP to display 8-bit BCD up count on LED circuit.
11
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
Exercise:
d) Write a program to interface with switches to perform following operations:
If SW8 is pressed, turn on, one LED, if SW7 is pressed, turn on, 2 LEDs, if
SW6 is pressed, turn on, 4 LEDs and turn on, 8 LEDs if SW5 is pressed.
12
13
Expt. No. 5
INTERFACING STEPPER MOTOR AND DC MOTOR
Aim: Assembly language programming to interface Stepper and DC motors
1. Program to rotate stepper motor anticlockwise (Full stepping with single coil
energized at a time). It is full stepping (step angle 1.8o per step). Note: Short JP13
Note:
i. Full stepping can be achieved by energizing two adjacent coils at a time(step
angle 1.8o per step).
ii. Half stepping can be achieved by alternately energizing two coils at a time and
then one coil at a time (step angle 0.9o per step)
Exercise:
a) Write an alp to rotate the stepper motor clockwise to have step angle of 0.9o per
step.
b) Write an alp to rotate stepper motor anticlockwise for 180o.
Exercise:
c)Write an alp to control the speed of the DC motor ( for some time low speed , then for
some time medium speed , high speed and repeat)
15
Expt. No. 6
INTERFACING SEVEN SEGMENT LEDS AND HEX KEYPAD
Aim: Assembly language programming to interface Seven segment LEDs and Hex
keypad.
1.Program to interface Seven Segment Display (Short Jumper JP2 (right two pins))
2. Program to interface hex keypad and seven segment display. Value of the key pressed
displayed on the seven segment display
16
17
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
Exercise:
c) Write a program to display square of a number pressed from the hex keypad on to
seven segment display.
d) Write a program to use hex keypad and seven segment display as a simple calculator
that performs single digit addition, subtraction, multiplication and division.
18
Expt. No. 7
INTERFACING EXTERNAL DAC AND PROGRAMMING
INTERNAL DAC AND ADC
Aim: To interface external, 8-bit Digital to Analog Converter(DAC) and programming
internal 10 bit, DAC and Analog to Digital Converter (ADC)
1.Program to interface external DAC to generate a square waveform (Short JP3)
Exercise:
a) Write an ALP to generate (i) Ramp wave (ii) Triangle wave (iii) Stair case wave of
10 steps
b) Write an ALP to generate sinewave [ Use the formula (1+sinθ)*128, with θ varying
in steps of 15o , Maximum DAC input value is 0xFF].
2. Programming internal DAC to generate a ramp waveform using internal DAC (10
bit). To see waveform: Open JP9 (at ADC module) and Observe the Analog output
waveform by connecting Oscilloscope (CRO) probe to right side pin of JP9.
19
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
20
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
e) Write a program to interface seven segment display to show the readings with the
resolution of 0.1 Volts for input analog voltage
21
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
Expt. No. 8
ASSEMBLY LANGUAGE PROGRAMMING FOR ARM 7 INTERRUPTS
Aim: To program arm 7 interrupts like EINT0, EINT1, Timer0 and UART0
1. Program to understand External Hardware Interrupt1 (EINT1). Short Jumper JP12.
After programming press the switch, SW12.
22
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
Exercise:
a) Write an ARM7 ALP to program EINT0 (P0.16) to perform same as done in the
above program
b) Write an ARM7 ALP to display the count of events on EINT1, on seven segment
LED.
c) Write an ALP to generate following waveforms using DACR, based on interrupts
on EINT1:
No Interrupt Sinewave
First Interrupt Square wave
Second Interrupt Saw tooth wave
Third Interrupt Triangular wave
Fourth Interrupt and so on Repeat sine wave
2. Program for Timer0 Interrupt to display every second count on LEDs.
23
Exercise:
d) Write a program to display every second count in decimal on seven segment display
e) Write a program to display any 4 waveforms one after the other every 5 seconds
24
Exercise:
f) Write a program to display the ASCII hex equivalent of the character received by
the ARM7 kit sent from the computer keyboard on the LED/ seven segment LED
unit
g) Should be able to program any task such as generation of desired waveform of
desired amplitude/frequency, controlling the speed of motors, controlling display
units based on the command/s sent from the computer keyboard.
25
Expt. No. 9
ARM 7 C PROGRAMMING - I
Aim: To program ARM7 in C programming language
1.Program to display up count with a delay of 1 second on LED display unit using Timer.
Exercise:
a) Write a program to generate (i) down count (ii) ring count (iii) Johnson’s count (iv)
decimal count
2.Program to read input from switches(P1.16-P1.23) and display corresponding LED
of LED unit.
Exercise:
b) Write a C program to interface with switches to perform following operations:
If SW8 is pressed one LED, if SW7 is pressed display 2 LEDs, if SW6 is
pressed display 4 LEDs and, display 8 LEDs if SW5 is pressed.
c) Write a C program to interface Buzzer
26
27
28
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
Exercise:
d) Write a C program to interface stepper motor/ DC motor clockwise/anticlockwise
and control the speed.
e) Write a C program to interface hex keypad and seven segment LEDs to display data
corresponding to the key pressed.
f) Write a C program to interface hex keypad and LCD to display data corresponding
to the key pressed.
g) Write a C program to display waveforms using internal DAC to display on the CRO.
29
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
Expt. No. 10
ARM 7 C PROGRAMMING - II
Aim: To program ARM7 interrupts, and PWM in C programming language
1. C-program to turn on or off the LED based in the external hardware interrupt1.
Note: After programming press the switch, SW12 (Short JP12).
30
Department of Electronics and Communication Engineering MIT Manipal
ECE 3162: MICROPROCESSOR LAB [0062]
3.Program to generate duty cycle using PWM interrupt. This program generates 1 msec
square wave.
Exercise:
a) Write a program to control the directions of stepper motor and DC motor using
EINT1.
b) Write a c program to display count of hardware interrupt1 on seven segment LEDs
c) Write a c program to display waveforms based on hardware interrupts usind DACR
d) Write a c program to display two digit decimal upcount on seven segment LEDs
every second.
31