0% found this document useful (0 votes)
36 views

mc 2022 scheme lab manual

The document is a laboratory manual for the Microcontroller course (BCS402) at C Byregowda Institute of Technology, detailing general lab guidelines, course objectives, and a list of programming exercises using ARM microcontrollers. It includes an introduction to microprocessors and microcontrollers, their evolution, types, advantages, and classifications based on various criteria. The manual also outlines the use of Keil uVision4 IDE for project creation and programming in ARM assembly and C languages.

Uploaded by

sindhubv512
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

mc 2022 scheme lab manual

The document is a laboratory manual for the Microcontroller course (BCS402) at C Byregowda Institute of Technology, detailing general lab guidelines, course objectives, and a list of programming exercises using ARM microcontrollers. It includes an introduction to microprocessors and microcontrollers, their evolution, types, advantages, and classifications based on various criteria. The manual also outlines the use of Keil uVision4 IDE for project creation and programming in ARM assembly and C languages.

Uploaded by

sindhubv512
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

C BYREGOWDA INSTITUTE OF TECHNOLOGY

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt. of Karnataka

Laboratory Manual

MICROCONTROLLER(BCS402)
IV Semester (CBCS Scheme)

Prepared by

LALITHA M,
Asst. Prof, Dept. of CSE

VANISHREE,
Asst. Prof, Dept. of CSE

Department of Computer Science and Engineering


C BYREGOWDA INSTITUTE OF TECHNOLOGY
An ISO 9001:2015 certified Institute
Kolar-Srinivaspur Road, Kolar- 563101
2024-25
General Lab Guidelines:
Conduct yourself in a responsible manner at all times in the laboratory. Intentional
misconduct will lead to the exclusion from the lab.
Do not wander around, or distract other students, or interfere with the laboratory
experiments of other students.
Read the handout and procedures before starting the experiments. Follow all written
and verbal instructions carefully. If you do not understand the procedures, ask the
instructor or teaching assistant.
Attendance in all the labs is mandatory, absence permitted only with prior permission
from Class teacher.
The workplace has to be tidy before, during and after the experiment.
Do not eat food, drink beverages or chew gum in the laboratory.
Every student should know the location and operating procedures of all Safety
equipment including First Aid Kit and Fire extinguisher.
-
Uniform and ID card are must.
Strictly follow the procedures for conduction of experiments.
Records have to be submitted every week for evaluation.
Chairs and stools should be kept under the workbenches when not in use.
After the lab session, switch off every supply, disconnect and disintegrate the
experiments and return the components.
Keep your belongings in designated area.
Never use damaged instruments, wires or connectors. Hand these parts to the instructor/
teaching assistant.
Sign the log book when you enter/leave the laboratory.

-
Don't touch open wires unless you are sure that there is no voltage. Always disconnect
the plug by pulling on the connector body not by the cable. Switch off the supply while
you make changes to the experiment.
leave the experiment table unattended when the experimental setup supply is on.
Students are not allowed to work in laboratory alone or without presence of the teaching
staff/ instructor.
No additional material should be carried by the students during regular labs.
Avoid stepping on electrical wires or any other computer cables.
MICROCONTROLLER LABORATORY SEMESTER IV

Course Learning Objectives: This course (BCS402) will enable students to:

Develop and test Assembly Language Program (ALP) using ARM7TDMI/LPC2148.


Conduct the experiments on an ARM7TDMI/LPC2148 evaluation board using
evaluation version of Embedded 'C' & Keil Uvision-4 tool/compiler.

Programs List:

1. Using Keil software, observe the various Registers, Dump, CPSR, with a simple Assembly
Language Programs (ALP).
2. Develop and simulate ARM ALP for Data Transfer, Arithmetic and Logical operations
(Demonstrate with the help of a suitable program).
3. Develop an ALP to multiply two 16-bit binary numbers.
4. Develop an ALP to find the sum of first 10 integer numbers.
5. Develop an ALP to find the largest/smallest number in an array of 32 numbers.
6. Develop an ALP to count the number of ones and zeros in two consecutive memory locations.
7. Simulate a program in C for ARM microcontroller using KEIL to sort the numbers in
ascending/descending order using bubble sort.
8. Simulate a program in C for ARM microcontroller to find factorial of a number.
9. Simulate a program in C for ARM microcontroller to demonstrate case conversion of characters
from upper to lowercase and lower to uppercase.
Demonstrate enabling and disabling of Interrupts in ARM.
SL. EXP. PAGE
CONTENTS
NO No. NO.
Using Keil software, observe the various Registers, Dump, CPSR, with
1 - 1
a simple Assembly Language Programs (ALP).

2 1 Develop and simulate ARM ALP for Data Transfer, Arithmetic and 8
Logical operations (Demonstrate with the help of a suitable program).
Develop an ALP to multiply two 16-bit binary numbers.
3 2 9
Develop an ALP to find the sum of first 10 integer numbers.
4 3 10
Develop an ALP to find the largest/smallest number in an array of 32
5 4 11
Numbers.
Develop an ALP to count the number of ones and zeros in two consecutive
6 5 12
memory locations.
Simulate a program in C for ARM microcontroller using KEIL to
7 6 14
sort the numbers in ascending/descending order using bubble sort.
Simulate a program in C for ARM microcontroller to find factorial of a
8 7 16
number
Simulate a program in C for ARM microcontroller to demonstrate case
9 8 18
conversion of characters from upper to lowercase and lower to uppercase.

10 9 Demonstrate enabling and disabling of Interrupts in ARM.. 21


INTRODUCTION
Evolution of Microprocessor:
The microprocessor forms the brain of the Central Processing Unit (CPU).
Microprocessor is an engine which can compute various operations fabricated on a single chip.
The internal architecture of microprocessor determines what operations can be performed on a
microprocessor and how it can be performed.

The first microprocessor was introduced in the year 1971. It was introduced by Intel and
was named Intel 4004.Intel 4004 is a 4 bit microprocessor and it was not a powerful
microprocessor. It can perform addition and subtraction operation on 4 bits at a time.

However it was 8080 was the first microprocessor to make it to Home computers.
It was introduced during the year 1974 and it can perform 8 bit operations. Then during the
year 1976, Intel introduced 8085 processors which is nothing but an update of 8080
processors.8080 processors are updated by adding two Enable/Disable Instructions, Three
added interrupt pins and serial I/O pins.

Intel introduced 8086 pins during the year 1976. The major difference between 8085 and
8086 processor is that 8085 is an 8 bit processor, but 8086 processor is a 16 bit
processor. The greatest advantage of the above processors are that it do not contain Floating
point instructions. Here floating point refers to the radix point or decimal point. For example:
123.456 is a floating point representation. Processors such as 8085 and 8086 do not support
such representations and instructions.

Intel later introduced 8087 processor which was the first math co-processor and later the
8088 processor which was incorporated into IBM personal computers. As the years progressed
lots of processors from 8088,80286,80386,80486,Pentium II, Pentium III, Pentium IV and now
Core2Duo,Dual Core and Quad core processors are the latest in the market.
Types of microprocessors:

Complex instruction set microprocessor

The processors are designed to minimize the number of instructions per program and
ignore the number of cycles per instructions. The compiler is used to translate a high
level language to assembly level language because the length of code is relatively short
and an extra RAM is used to store the instructions. These processors can do tasks like
downloading, uploading and recalling data from memory. Apart from these tasks these
microprocessor can perform complex mathematical calculation in a single command.
Example: IBM 370/168, VAX 11/780.

Reduced instruction set microprocessor

These processor are made according to function. They are designed to reduce the
execution time by using the simplified instruction set. They can carry out small things in
specific commands. These processors complete commands at faster rate. They require
onlyone clock cycle to implement a result at uniform execution time. There are number
of registers and less number of transistors. To access the memory location LOAD and
STORE instructions are used. Example: Power PC 601, 604, 615, 620

Super scalar microprocessor

These processors can perform many tasks at a time. They can be used for ALUs and
multiplier like array. They have multiple operation unit and perform tasts my executing
multiple commands.

Application specific integrated circuit

These processors are application specific like for personal digital assistant computers.
They are designed according to proper specification.

Digital signal multiprocessor

These processors are used to convert signals like analog to digital or digital to analog.
The chips of these processors are used in many devices such as RADAR SONAR home
theatres etc.

Advantages of microprocessor

High processing speed


Compact size
Easy maintenance
Can perform complex mathematics
Flexible
Can be improved according to requirement
Disadvantages of microprocessors

Overheating occurs due to overuse


Performance depends on size of data
Large board size than microcontrollers
Most microprocessors do not support floating point operations

Evolution of Micro Controller


The Micro controller was developed by Intel in 1980. The 8051 is one of the most
popular 8 bit micro controllers and combines an instruction set that allows tight coding of
small particularlyI/O application with enough power and a large enough program space that it
can be used with C Language.

The development of 16 and 32 bit microprocessors contributed to the growth of powerful


personal computers that are used in all walks of life. Because of their processing power and
speed, these 16 and 32 bit microprocessors have also found their way into the design of
standalone products such as electronic instruments which require sophisticated control
capability. In the evolution of microprocessor capability, instead of focusing upon larger word
widths and address spaces. The present emphasis 'is upon exceedingly fast real time control.
Thedevelopment of microcontrollers has focused upon the integration of the facilities needed to
support fast control into a single chip.

Intel has introduced standard 8-bit microcontroller 8048 in 1976. The same company has
continued to drive the evolution of single chip microcontrollers. In the year 1980, Intel has
introduced the 8051 microcontroller, with higher performance than 8048. With the advantages
-bit microcontroller, 8051
family. Quickly gained the position of the second generation world standard
microcontrollers.

Because of the advanced semiconductor technology, it has become possible to integrate


more than 1.00.000 transistors onto a single silicon chip. Intel has made use of this advanced
process technology and developed a new generation of single chip 16 bit microcontrollers
called the MCS-96 (8096 family). The 8096 family offers the highest level of system
integration ever achieved on a single chip microcontroller with l,20,000 transistors. This 8096
microcontroller has 16 bit CPU, 8K bytes of program memory. 232 bytes of data memory and
both analog and digital type of 1/ O features.

The Motorola Microcontroller family was first introduced to the market in 1978 and is built in
the same pattern of the microprocessor 6800. Even though the Microcontroller 6801 family was
designed similar to the microprocessor 6800, its design and instruction set have been modified
to suit the control applications.

The microcontroller 6801 family includes on-chip Input/output ports, an Asynchronous


serial communication device and 16 bit timer modules. The Microcontrollers 6801. 6803, 6805.
6811 are available from Motorola Company. The 6811 microcontroller family have different
version with ROM, RAM, EPROM, and EEPROM. These versions are denoted by suffix
characters and numbers.

Block diagram of 8051 microcontroller

Pin diagram of 8051 microcontroller

Classification According to Memory Architecture:


Memory architecture of microcontroller are two types, they are namely:

1. Harvard Memory Architecture Microcontroller: The point when a microcontroller


unit has a dissimilar memory address space for the program and data memory, the
microcontroller has Harvard memory architecture in the processor.
2. Princeton Memory Architecture Microcontroller: The point when a microcontroller
has a common memory address for the program memory and data memory, the
microcontroller has Princeton memory architecture in the processor.

Classification According to Memory Devices


Embedded memory microcontroller: When an embedded system has a
microcontroller unit that has all the functional blocks available on a chip is called an
embedded microcontroller. For example, 8051 having program & data memory, I/O
ports, serial communication, counters and timers and interrupts on the chip is an
embedded microcontroller.

External Memory Microcontroller: When an embedded system has a


microcontrollerunit that has not all the functional blocks available on a chip is called an
external memory microcontroller. For example, 8031 has no program memory on the
chip is an external memory microcontroller.

Classification According to Instruction Set


CISC: CISC is a Complex Instruction Set Computer. It allows the programmer to use
one instruction in place of many simpler instructions.

RISC: The RISC is stands for Reduced Instruction set Computer, this type of
instruction sets reduces the design of microprocessor for industry standards. It allows
each instruction to operate on any register or use any addressing mode and
simultaneous access of program and data.

Classification According to Number of Bits


The 16-bit microcontroller performs greater precision and performance as compared to
8-bit. For example 8 bit microcontrollers can only use 8 bits, resulting in a final range
of 0×00 0xFF (0-255) for every cycle. In contrast, 16 bit microcontrollers with its 16
bit data width has a range of 0×0000 0xFFFF (0-65535) for every cycle. A longer
timer most extreme worth can likely prove to be useful in certain applications and
circuits. It can automatically operate on two 16 bit numbers. Some examples of 16-bit
microcontroller are 16-bit MCUs are extended 8051XA, PIC2x, Intel 8096 and
Motorola MC68HC12 families.

The 32-bit microcontroller uses the 32-bit instructions to perform the arithmetic and
logic operations. These are used in automatically controlled devices including
implantable medical devices, engine control systems, office machines, appliances and
other types of embedded systems. Some examples are Intel/Atmel 251 family, PIC3x.

ARM (ADVANCED RISC MACHINE)

The ARM processor is a 32-bit RISC processor, meaning it is built using the RISC
(reduced instruction set computer) ISA (instruction set architecture). ARM processors are
microprocessors and are widely used in many of the mobile phones sold each year, as many as
98% of mobile phones. They are also used in PDAs (personal digital assistants), digital media
and music layers, hand-held gaming systems, calculators, and even computer drives. The first
ARM processor- based computer was the Acorn Archimedes, released in 1987. Apple
Computer became involved with helping to improve the ARM technology in the late 1980s,
with their work resulting in the ARM6 technology in 1992. Later, Acorn used the ARM6-based
ARM 610 processor in their RISC PC's in 1994. Today, the ARM architecture is licensed to
many companies, including Apple, Cirrus Logic, Intel, LG, Microsoft, NEC, Nintendo, Nvidia,
Sony, Samsung, Texas Instruments, and many more. The latest developed ARM processor
families include ARM11 and Cortex. ARM processors capable of 64-bit processing are
currently in development.

ARM processor features include:

Load/store architecture.
An orthogonal instruction set.
Mostly single-cycle execution.
Enhanced power-saving design.
64 and 32-bit execution states for scalable high performance.
Hardware virtualization support.

ARM Holdings offers users the following types of processors:


Cortex-A: built for advanced operating systems and exhibits the highest
possibleperformance;
Cortex-R: caters perfectly to the needs of real-time applications and provides its
userswith the fastest response times;
Cortex-M: mainly built for microcontrollers;
SecurCore: takes care of security applications;
Machine Learning: for ML application purposes.
PROJECT CREATION IN KEILUV4 IDE:

Create a project folder before creating NEW project.

Open Keil uVision4 IDE software by double clicking on icon.


Go to then to uVision and save it with a name in the
respective project folder, already you created.
Select the device as In that (Big then press OK.
Go to file, select NEW to open new editor window.
Save the file in .s format.
dd
.s file which is saved earlier and click on Add,
OK. Close the window.
Write the program on the editor window starting with , area filename, code,
Save the program.
Go to project, (to check errors).
G to click on or stop debug to get the output.

To check the step by step output press F11.


1. Develop and simulate ARM ALP for Data Transfer, Arithmetic and Logical operations
(Demonstrate with the help of a suitable program).

A) DATA TRANSFER

LABEL MNEMONIC FIELD COMMENTS FILED


FIELD
AREA MULTIPLY, CODE, READONLY
ENTRY ; Mark first instruction to execute
MOV R1,#0X12 ; STORE FIRST NUMBER IN R0
MOV R2,#0X32 ; STORE SECOND NUMBER IN R1
MOV R3,R1 ; DATA TRANSFER
MVN R4,R3 ; DATA TRANSFER WITH NEGATIVE
MOV R5,R2 ;DATA TRANSFER
MVN R6,R5 ; DATA TRANSFER WITH NEGATIVE
HERE B HERE
END ; MARK END OF FILE

Output:

R1 0x00000012
R2 0x00000032
R3 0x00000012
R4 0xFFFFFFED
R5 0x00000032
R6 0xFFFFFFCD
B) ARITHMETIC OPERATIONS

LABEL MNEMONIC FIELD COMMENTS FILED


FIELD
AREA MULTIPLY, CODE, READONLY
ENTRY ; Mark first instruction to execute
MOV R1,#0X12 ; STORE FIRST NUMBER IN R0
MOV R2,#0X32 ; STORE SECOND NUMBER IN R1
ADD R3,R2,R1 ;ADDITION
ADC R4,R2,R1 ;ADDITION WITH CARRY
SUB R5,R2,R1 ;SUBTRACTION
SBC R6,R2,R1 ;SUBTRACTION WITH CARRY
RSB R7,R2,R1 ;REVERSE SUBTRACTION
RSC R8,R2,R1 ;REVERSE SUBTRACTION WITH CARRY
HERE B HERE
END ; MARK END OF FILE

Output:

R1 0x00000012
R2 0x00000032
R3 0x00000044
R4 0x00000044
R5 0x00000020
R6 0x0000001F
R7 0xFFFFFFE0
R8 0xFFFFFFDF

C) LOGICAL OPERATIONS
LABEL MNEMONIC FIELD COMMENTS FILED
FIELD
AREA MULTIPLY, CODE, READONLY
ENTRY ; Mark first instruction to execute
MOV R1,#0X12 ; STORE FIRST NUMBER IN R0
MOV R2,#0X32 ; STORE SECOND NUMBER IN R1
ORR R3,R2,R1 ;LOGICAL OR OPERATION
AND R4,R2,R1 ;LOGICAL AND OPERATION
EOR R5,R2,R1 ;LOGICAL EOR OPERATION
BIC R6,R2,R1 ;LOGICAL BIT CLEAR OPERATION
HERE B HERE
END ; MARK END OF FILE

Output:

R1 0x00000012
R2 0x00000032
R3 0x00000032
R4 0x00000012
R5 0x00000020
R6 0x00000020
2. ALP TO MULTIPLY TWO 16BIT NUMBERS

LABEL MNEMONIC FIELD COMMENTS FILED


FIELD
AREA MULTIPLY, CODE, READONLY
ENTRY ; Mark first instruction to execute
MOV R1,#0X6400 ; STORE FIRST NUMBER IN R0
MOV R2,#0X3200 ; STORE SECOND NUMBER IN R1
MUL R3,R1,R2 ; MULTIPLICATION
HERE B HERE
END ; MARK END OF FILE

OUTPUT
3. ALP TO FIND THE SUM OF FIRST 10 INTEGER NUMBERS

LABEL MNEMONIC FIELD COMMENTS FILED


FIELD
AREA INTSUM, CODE, READONLY
ENTRY ; Mark first instruction to execute
MOV R1,#10 ; LOAD 10 TO REGISTER
MOV R2,#0 ; EMPTY R2 REGISTER TO STORE RESULT
LOOP ADD R2,R2,R1 ; ADD THE CONTERNT OF R1 WITH RESULT AT R2
SUBS R1,#0X01 ; DECREMENT R1 BY 1
BNE LOOP ; REPEAT TILL R1 GOES TO ZERO
HERE B HERE
END

OUTPUT
4. ALP TO FIND THE LARGEST/SMALLEST NUMBER IN AN ARRAY OF 32
NUMBERS.

LABEL MNEMONIC FIELD COMMENT FIELD


FIELD
AREA LAR_SMAL, READONLY
ENTRY
MOV R5,#06 ; COUNTER VALUE E.G 7 NUMBERS
MOV R1,#0X40000000 ; START OF THE DATA MEMORY
MOV R2,#0X4000001C ; RESULT LOCATION
LDR R3,[R1] ; GET THE FIRST DATA
LOOP ADD R1,R1,#04 ; MEMORY POINTER UPDATED TO FETCH 2ND
DATA
LDR R4,[R1] ; GET SECOND NUMBER
CMP R3,R4 ; COMPARE BOTH NUMBERS
BLS LOOP1 ;BHI for large; IF 1ST> 2ND THAN LOOP1
MOV R3,R4
LOOP1 SUBS R5,R5,#01 ; DECREMENT THE COUNTER
CMP R5,#00
BNE LOOP
STR R3,[R2]
STOP B STOP
END
OUTPUT
NOTE: BLO instruction for Descending

BHI instruction for Ascending


5. ALP TO COUNT THE NUMBER OF ONES AND ZEROS IN TWO
CONSECUTIVE MEMORYLOCATIONS.

LABEL MNEMONIC COMMENT FIELD


FIELD FIELD
AREA ONEZERO , CODE, READONLY
ENTRY ;MARK FIRST INSTRUCTION TO EXECUTE
MOV R2,#0 ; COUNTER FOR ONES
MOV R3,#0 ; COUNTER FOR ZEROS
MOV ; LOADS THE VALUE
R6,#0X00000002
MOV R1,#32 ; 32 BITS COUNTER
MOV R0,R6 ; GET THE 32 BIT VALUE
LOOP0 MOVS R0,R0,ROR ; RIGHT SHIFT TO CHECK CARRY BIT (1'S/0'S)
#1
BHI ONES ; IF C=1 GOTO ONES BRANCH OTHERWISE
NEXT
ZEROS ADD R3,R3,#1 ; IF C= 0 THEN INCREMENT THE COUNTER
BY 1(R3)
B LOOP1 ; BRANCH TO LOOP1
ONES ADD R2,R2,#1 ; IF C=1 THEN INCREMENT THE COUNTER BY
1(R2)
LOOP1 SUBS R1,R1,#1 ; COUNTER VALUE DECREMENTED BY 1
BNE LOOP0 ; IF NOT EQUAL GOTO TO LOOP0 CHECKS
32BIT
STOP B STOP
END
OUTPUT
6. SIMULATE A PROGRAM IN C FOR ARM MICROCONTROLLER
USING KEIL TO SORT THE NUMBERS IN
ASCENDING/DESCENDING ORDER USING BUBBLE SORT.

ASCENDING ORDER USING BUBBLE SORT

#include<reg51.h>
Void main()
{
Unsigned long
array[]={0x22222222,0x99999999,0x33333333,0x55555555,0xAAAAAAAA,0x11111111}
Unsigned long temp,I,j;
For(I=0;I<5;I++)
{
For(j=0;j<5;j++)
{
If(array[j]>array[j+1])
{
Temp=array[j+1];
Array[j+1]=array[j];
Array[j]=temp;
}
}
}

Output=array
[0] 0x11111111
[1] 0x22222222
[2] 0x33333333
[3] 0x55555555
[4] 0x99999999
[5] 0xAAAAAAAA
DESCENDING ORDER USING BUBBLE SORT

#include<reg51.h>
Void main()
{
Unsigned long
array[]={0x22222222,0x99999999,0x33333333,0x55555555,0xAAAAAAAA,0x11111111}
Unsigned long temp,I,j;
For(I=0;I<5;I++)
{
For(j=0;j<5;j++)
{
If(array[j]<array[j+1])
{
Temp=array[j+1];
Array[j+1]=array[j];
Array[j]=temp;
}
}
}

Output=array
[0] 0xAAAAAAAA
[1] 0x99999999
[2] 0x55555555
[3] 0x33333333
[4] 0x22222222
[5] 0x11111111
7. SIMULATE A PROGRAM IN C FOR ARM MICROCONTROLLER TO FIND
FACTORIAL OF A NUMBER

#include<reg51.h>
Void main()
{
Unsigned int num=5,fact=1;
While (num>0)
{
fact=fact*num;
num--;
}
P1=fact;
While(1);
}

Output

LOCAL WINDOW
NUM 0x0000
FACT 0x0078

Port window

Parallel port
7 0
P1 0x78
pin 0x78
8. SIMULATE A PROGRAM IN C FOR ARM MICROCONTROLLER TO DEMONSTRATE
CASE CONVERSION OF CHARACTERS FROM UPPER TO LOWERCASE AND LOWER TO
UPPERCASE.

#include<LPC214x.H>
char toLower(char ch);
char toUpper(char ch);

void UART_Init(void){
PINSEL |=0x00000005;
V0LCR=0x83;
V0DLL=0x61;
V0DLM=0x00;
V0LCR=0x03;
}

void UART_sendChar(char c) {
while(|V0LSR & 0x20));
V0THR= c;
}

void UART0_ReceiveChar(void) {
while(|V0LSR & 0x01));
return V0RBR;
}

void UART0_sendstring(const char * str) {


while(*str);
UART0_Sendchar(*str++);
}
}

void UART0_Receivestring(char * str, int maxLength) {


char c;
int i=0;
while (i<maxLengh-1){
c=UART0_Receivechar();
\ \
break
}
str[i++]=c;
UART0_sendChar(c );
}
\
}

void toLowerstring(char * str) {


while(*str){
*str= toLower( * str);
str++;
}
}

void toUpperrstring(char * str) {


while(*str){
*str= toUpper( * str);
Str++;
}
}

int main() {
char str[100];
UART0_Init();

UART0_receivestring(str, sizeof(str));
\r\
toLowerString(str);
UART0_SendString(str);
\r\

UART0_receivestring(str, sizeof(str));
\r\
ToUpperString(str);
UART0_SendString(str);
\r\
return 0;
}

char toLower(char ch) {

-
} else {
return ch;
}
}

char toUpper(char ch) {

-
} else {
return ch;
}
}
9. DEMONSTRATE ENABLING AND DISABLING OF INTERRUPTS IN ARM..
#include<LPC214x.H>
Int i;
irq void Ext_ISR(void) // Interrupt Service Routine-ISR
//The _irq keyword tells the compiler that the function is an interrupt routine
{
IO1DIR |= 0x00010000;
IO1CLR |= 0x00010000;
For(i=0; i<3000000;i++);
IO1SET |= 0x00010000;
EXTINT |= 0x4; //clear interrupt
Vicvectaddr = 0; // End of interrupt execution
}
Void init_ext_interrupt() // Initialize Interrupt
{
EXTMODE = 0x4; //Edge sensitive mode on
EINT2 EXTPOLAR &= ~(0x4); //Falling Edge Sensitive
PINSEL0 = 0x80000000; //Select Pin function P0.15 as EINT2
/* initialize the interrupt vector */
Vicintselect &= ~ (1<<16); // EINT2 selected as
IRQ 16 Vicvectaddr5 = (unsigned int)Ext_ISR; //
address of the ISR Vicvectcntl5 = (1<<5) | 16;
// Basically Vector Address Register store the address of the function i.e. ISR and used to assign or
enable vector IRQ slot..Pointer Interrupt Function (ISR)
Vicintenable = (1<<16); // EINT2 interrupt
enabled EXTINT &= (0x4);
}
Int main (void)
{
Init_ext_interrupt(); // initialize the external
interrupt While(1);
}

You might also like