DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi...

77
DMI COLLEGE OF ENGINEERING (AFFILIATED TO ANNA UNIVERSITY CHENNAI 600 025) PALANCHUR, CHENNAI 602 123. DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING EC6711 EMBEDDED LABORATORY MANUAL B.E. SEVENTH SEMESTER REGULATION (2013)

Transcript of DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi...

Page 1: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

DMI COLLEGE OF ENGINEERING

(AFFILIATED TO ANNA UNIVERSITY – CHENNAI 600 025)

PALANCHUR, CHENNAI – 602 123.

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

EC6711 – EMBEDDED LABORATORY MANUAL

B.E. – SEVENTH SEMESTER

REGULATION (2013)

Page 2: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

INDEX

S.NO LIST OF EXPERIMENTS PAGE

NO.

1. Study of ARM Evaluation system 7

2. Flashings of LEDs 10

3. Interfacing LED and PWM 11

4. Interfacing ADC and DAC 13

5. Interfacing Real Time clock and serial port 18

6. Interfacing stepper motor and temperature sensor 22

7. Interfacing EEPROM and interrupt 26

8. Implementing ZIGBEE protocol with ARM 32

9. Interrupt performance characteristics of ARM and FPGA

40

10. Mail Box 46

CONTENT BEYOND THE SYLLABUS

11 Interfacing Bluetooth Module 50

12 Interfacing GPS Module 53

Page 3: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,
Page 4: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 1

Vision of the Department

To develop committed and competent technologists in electronics and communication

engineering to be on par with global standards coupled with cultivating the innovations and

ethical values.

Mission of the Department

DM 1: To be a centre of excellence in teaching learning process promoting active learning with

critical thinking.

DM 2: To strengthen the student’s core domain and to sustain collaborative industry interaction

with internship and incorporating entrepreneur skills.

DM 3: To prepare the students for higher education and research oriented activities imbibed with

ethical values for addressing the social need.

PROGRAM EDUCATIONAL OBJECTIVES (PEOs):

PEO1. CORE COMPETENCY WITH EMPLOYABILITY SKILLS: Building on

fundamental knowledge, to analyze, design and implement electronic circuits and systems

in Electronics and Communication Engineering by applying knowledge of mathematics

and science or in closely related fields with employability skills.

PEO2. PROMOTE HIGHER EDUCATION AND RESEARCH AND

DEVELOPMENT: To develop the ability to demonstrate technical competence and

innovation that initiates interest for higher studies and research.

PEO3. INCULCATING ENTREPRENEUR SKILLS: To motivate the students to

become Entrepreneurs in multidisciplinary domain by adapting to the latest trends in

technology catering the social needs.

PEO4. ETHICAL PROFESSIONALISM: To develop the graduates to attain

professional excellence with ethical attitude, communication skills, team work and

develop solutions to the problems and exercise their capabilities.

Page 5: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 2

PROGRAM OUTCOMES (POs)

The Program Outcomes (POs) are described as.

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

fundamentals and an engineering specialization to the solution of complex engineering

problems.

2. Problem Analysis: Identify, formulate, review research literature, and analyze

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 the public health and safety, and the cultural, societal, and

environmental considerations.

4. Conduct investigations of complex problems: Use research-based knowledge and

research methods including design of experiments, analysis and interpretation of data,

and synthesis of the information to provide valid conclusions.

5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and

modern engineering and IT tools including prediction and modeling 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.

Page 6: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 3

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 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

the engineering 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 lifelong learning in the broadest context of technological

change.

PROGRAM SPECIFIC OUTCOMES (PSOs):

PSO1. Analyze and design the analog and digital circuits or systems for a given

specification and function.

PSO2. Implement functional blocks of hardware-software co-designs for signal

processing and communication applications.

PSO3. Design, develop and test electronic and embedded systems for applications with

real time constraint and to develop managerial skills with ethical behavior to work in a

sustainable environment.

Page 7: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 4

INSTRUCTIONS TO STUDENTS FOR WRITING THE RECORD

In the record, the index page should be filled properly by writing the corresponding

experiment number, experiment name, date on which it was done and the page number.

On the right side page of the record following has to be written:

1. Title: The title of the experiment should be written in the page in capital letters.

2. In the left top margin, experiment number and date should be written.

3. Aim: The purpose of the experiment should be written clearly.

4. Apparatus/Tools/Equipments/Components used: A list of the Apparatus/Tools/

Equipments/ Components used for doing the experiment should be entered.

5. Theory: Simple working of the circuit/experimental set up/algorithm should be written.

6. Procedure: Steps for doing the experiment and recording the readings should be briefly

described(flow chart/ Circuit Diagrams / programs in the case of computer/processor

related experiments)

7. Results: The results of the experiment must be summarized in writing and should be

fulfilling the aim. On the Left side page of the record following has to be recorded: a) Circuit/Program: Neatly drawn circuit diagrams for the experimental set up.

b) Design: The design of the circuit components for the experimental set up for

selecting the components should be clearly shown if necessary.

3. Observations:

i) Data should be clearly recorded using Tabular Columns.

ii) Unit of the observed data should be clearly mentioned

iii) Relevant calculations should be shown. If repetitive calculations are needed, only show a

sample calculation and summarize the others in a table.

Page 8: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 5

EC6711 EMBEDDED LABORATORY L T P C

0 0 3 2

LIST OF EXPERIMENTS:

1. Study of ARM evaluation system 2. Interfacing ADC and DAC. 3. Interfacing LED and PWM. 4. Interfacing real time clock and serial port. 5. Interfacing keyboard and LCD. 6. Interfacing EPROM and interrupt. 7. Mailbox. 8. Interrupt performance characteristics of ARM and FPGA. 9. Flashing of LEDS. 10. Interfacing stepper motor and temperature sensor. 11. Implementing zigbee protocol with ARM.

TOTAL: 45 PERIODS

Page 9: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 6

Course outcomes:

CO 1 Student will be able to write programs in ARM for a specific Application

CO 2 Student will be Interface memory and Write programs related to memory operations

CO 3 Analyse the performance of interrupt

CO 4 Write programmes for interfacing keyboard, display, motor and sensor.

CO 5 Formulate a mini project using embedded system

CO PO, PSO Mappings.

Course Code

and Course

name

CO Program Outcomes PSO

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

EC6711

Embedded

Laboratory

CO 1 3 - - - - 3 2 3 2 3 2 3 3 2 2

CO 2 3 - - - - 2 3 2 3 3 2 3 3 2 2

CO 3 3 - - - - 1 2 3 2 3 3 2 3 3 3

CO 4 3 - - - - 3 2 3 2 3 3 2 3 3 3

CO 5 3 - - - - 2 3 3 2 3 3 2 3 3 3

Average 3 - - - - 2 2.4 2.8 2 3 3 2.4 3 3 3

Page 10: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 7

INDEX

S.NO LIST OF EXPERIMENTS PAGE

NO.

1. Study of ARM Evaluation system 12

2. Flashings of LEDs 15

3. Interfacing LED and PWM 17

4. Interfacing ADC and DAC 20

5. Interfacing Real Time clock and serial port 27

6. Interfacing Keyboard and LCD 32

7. Interfacing stepper motor and temperature sensor 37

8. Interfacing EEPROM and interrupt 44

9. Implementing ZIGBEE protocol with ARM 53

10. Interrupt performance characteristics of ARM and FPGA

59 11. Mail Box

64

CONTENT BEYOND THE SYLLABUS

12. Interfacing Bluetooth Module 67

13. Interfacing GPS Module 70

Page 11: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 8

INTRODUCTION TO KEIL ΜVISION4 SOFTWARE The μVision4 IDE is a Windows-based software development platform that combines a robust

editor, project manager, and makes facility. μVision4 integrates all tools including the C

compiler, macro assembler, linker/locator, and HEX file generator. μVision4 helps expedite the

development process of your embedded applications by providing the following:

Full-featured source code editor,

Device database for configuring the development tool setting,

Project manager for creating and maintaining your projects,

Integrated make facility for assembling, compiling, and linking your embedded

applications,

Dialogs for all development tool settings,

True integrated source-level Debugger with high-speed CPU and peripheral simulator,

Advanced GDI interface for software debugging in the target hardware and for

connection to Keil ULINK,

Flash programming utility for downloading the application program into Flash ROM,

Links to development tools manuals, device datasheets & user’s guides.

The μVision4 IDE offers numerous features and advantages that help you quickly and

successfully develop embedded applications. They are easy to use and are guaranteed to help you

achieve your design goals.

Page 12: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 9

INTRODUCTION TO FLASH MAGIC

NXP Semiconductors produce a range of Microcontrollers that feature both on-chip Flash

memory and the ability to be reprogrammed using In-System Programming technology. Flash

Magic is Windows software from the Embedded Systems Academy that allows easy access to all

the ISP features provided by the devices. These features include:

Erasing the Flash memory (individual blocks or the whole device)

Programming the Flash memory

Modifying the Boot Vector and Status Byte

Reading Flash memory

Performing a blank check on a section of Flash memory

Reading the signature bytes

Reading and writing the security bits

Direct load of a new baud rate (high speed communications)

Sending commands to place device in Bootloader mode

Flash Magic provides a clear and simple user interface to these features and more as described in

the following sections. Under Windows, only one application may have access the COM Port at

any one time, preventing other applications from using the COM Port. Flash Magic only obtains

access to the selected COM Port when ISP operations are being performed. This means that other

applications that need to use the COM Port, such as debugging tools, may be used while Flash

Magic is loaded. Note that in this manual third party Compilers are listed alphabetically. No

preferences are indicated or implied.

Page 13: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 10

ARM 7 LPC2148TRAINER KIT

ARM 7 LPC2148 Trainer Kit designed for educational training purpose and the embedded

device from NXP. This document is a User’s guide which describes the complete hardware

design of the ARM 7 LPC2148 Trainer Kit.

Features:

Device daughter card, easy and flexible to upgrade the device.

Four 10 pin individual digital or analog I/O ports are available.

One16 pin digital I/O port is available.

Inbuilt LEDs are available for PWM output.

Inbuilt push to on switch for Reset.

Inbuilt push to on switch for External Interrupt.

USB ISP programmer inbuilt. And On board Serial to USB bridge is available

Page 14: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 11

FRC CABLE CONNECTION

Page 15: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 12

EXP.NO: 1 Study of ARM

Aim:

To study ARM Processor

Apparatus Required:

ARM Trainer Kit

Block Diagram of ARM Processor:

Theory:

The LPC2141/2/4/6/8 microcontrollers are based on a 32/16 bit ARM7TDMI-S CPU with

real-time emulation and embedded trace support, that combines the microcontroller with embedded

high speed flash memory ranging from 32 kB to 512 kB. A 128-bit wide memory interface and a

unique accelerator architecture enable 32-bit code execution at the maximum clock

Page 16: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 13

rate. For critical code size applications, the alternative 16-bit Thumb mode reduces code by more

than 30 % with minimal performance penalty.

Due to their tiny size and low power consumption, LPC2141/2/4/6/8 are ideal for

applications where miniaturization is a key requirement, such as access control and point-of-sale.

A blend of serial communications interfaces ranging from a USB 2.0 Full Speed device, multiple

UARTs, SPI, SSP to I2Cs, and on-chip SRAM of 8 kB up to 40 kB, make these devices very

well suited for communication gateways and protocol converters, soft modems, voice

recognition and low end imaging, providing both large buffer size and high processing power.

Various 32-bit timers, single or dual 10-bit ADC(s), 10-bit DAC, PWM channels and 45 fast

GPIO lines with up to nine edge or level sensitive external interrupt pins make these

microcontrollers particularly suitable for industrial control and medical systems.

ARCHITECTURAL OVERVIEW

The LPC2141/2/4/6/8 consists of an ARM7TDMI-S CPU with emulation support, the

ARM7 Local Bus for interface to on-chip memory controllers, the AMBA Advanced High-

performance Bus (AHB) for interface to the interrupt controller, and the ARM Peripheral Bus

(APB, a compatible superset of ARM’s AMBA Advanced Peripheral Bus) for connection to on-

chip peripheral functions. The LPC2141/24/6/8 configures the ARM7TDMI-S processor in little-

endian byte order.

AHB peripherals are allocated a 2 megabyte range of addresses at the very top of the 4

gigabyte ARM memory space. Each AHB peripheral is allocated a 16 kB address space within

the AHB address space. LPC2141/2/4/6/8 peripheral functions (other than the interrupt

controller) are connected to the APB bus. The AHB to APB bridge interfaces the APB bus to the

AHB bus. APB peripherals are also allocated a 2 megabyte range of addresses, beginning at the

3.5 gigabyte address point. Each APB peripheral is allocated a 16 kB address space within the

APB address space.

The connection of on-chip peripherals to device pins is controlled by a Pin Connect

Block (see chapter "Pin Connect Block" on page 58). This must be configured by software to fit

specific application requirements for the use of peripheral functions and pins.

Page 17: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 14

ARM7TDMI-S PROCESSOR

The ARM7TDMI-S is a general purpose 32-bit microprocessor, which offers high performance

and very low power consumption. The ARM architecture is based on Reduced Instruction Set

Computer (RISC) principles, and the instruction set and related decode mechanism are much

simpler than those of micro programmed Complex Instruction Set Computers. This simplicity

results in a high instruction throughput and impressive real-time interrupt response from a small

and cost-effective processor core.

Pipeline techniques are employed so that all parts of the processing and memory systems can

operate continuously. Typically, while one instruction is being executed, its successor is being

decoded, and a third instruction is being fetched from memory.

The ARM7TDMI-S processor also employs a unique architectural strategy known as THUMB,

which makes it ideally suited to high-volume applications with memory restrictions, or

applications where code density is an issue.

The key idea behind THUMB is that of a super-reduced instruction set. Essentially, the ARM7TDMI-S processor has two instruction sets:

• The standard 32-bit ARM instruction set.

• A 16-bit THUMB instruction set.

The THUMB set’s 16-bit instruction length allows it to approach twice the density of standard

ARM code while retaining most of the ARM’s performance advantage over a traditional 16-bit

processor using 16-bit registers. This is possible because THUMB code operates on the same 32-

bit register set as ARM code.

THUMB code is able to provide up to 65% of the code size of ARM, and 160% of the

performance of an equivalent ARM processor connected to a 16-bit memory system.

The ARM7TDMI-S processor is described in detail in the ARM7TDMI-S Datasheet that can be

found on official ARM website.

Result:

The study of ARM Processor is completed.

Page 18: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 15

EXP.NO: 2 Flashing of LEDs

Aim:

To write a program for Flashing LEDs.

Apparatus Required: ARM Trainer Kit

LED Card

PC

Software Required:

Keil μVision4

Flash Magic

Theory:

Light Emitting Diodes (LEDs) are popularly used display components used to indicate

the On and OFF state of system. These are also used to realize various counters like binary

counters experimentally. These LEDs can be easily interfaced with the port pins of any

Microcontroller by using current limiting resistors of the order of 220 Ohms.

The diagram below shows the interfacing of LED array ot the Port1 pins of LPC20148

ARM 7 microcontroller. This program blinks the LEDs continuously with a small delay. The

LEDs are connected to the Port 0 Pins P0.00 to P0.07 and the these Pins are configured as

general Purpose output pins.

Page 19: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 16

Program:

#include <LPC214X.H> void DELAY(unsigned long VALUE); unsigned char A = 0x01; int main() {

IO0DIR = 0x000000FF; while(1) {

/* Port0 00-07 as output*/

/* Infinite loop*/

IO0SET |= A;

/* Port0 00-07 High

*/

DELAY(1000000); IO0CLR |= A;

/* Port0 00-07 High

*/

A <<=1; if(A==0x00) A=0x01; DELAY(1000000);

} } void DELAY(unsigned long VALUE) {

while(VALUE>0) {

VALUE--; }

}

Result:

Thus the Flashing of LEDs are verified and executed.

Page 20: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 17

EXP.NO: 3 Interfacing LED and PWM

Aim:

To write a program for Interfacing LED and PWM

Apparatus Required: ARM Trainer Kit

LED Card

PC

Software Required:

Keil μVision4

Flash Magic

Interfacing LED and PWM:

Program:

#include<LPC214x.h> /* ******************************************************************************

**************** * Function : PwmInit * Description : Routine for 120 Khz Frequency Generation * Parameters : None

Page 21: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 18

****************************************************************************** ****************

*/

void INIT_ADC(void); int READ_ADC(void);

unsigned int PWM=0;

void PwmInit() {

PINSEL0 = 0X00008000; // Enable PWM2 -- P0.7 PWMLER = 0X00000004; // Set latch register PWMPR = 0X00000000; // Prescale 0 PWMMR0 = 0X000003FF; // 120 KHz Frequency

PWMMCR = 0X00000002; // Set only Match0 control PWMPCR = 0X00000400; PWMTCR = 0X00000009;

}

int main() {

PwmInit(); INIT_ADC(); //IO0DIR = 0x000000FF; //IO0CLR &= 0x000000FF; while(1) { PWM = READ_ADC(); if(PWM>0x000003FF) PWM=0x000003FF; PWMMR2 = PWM; PWMTCR = 0X00000000; PWMTCR = 0X00000009;

} }

void INIT_ADC() {

PINSEL1 |= 0x01000000; AD0CR = 0x00200602;

} int READ_ADC() {

int VAL; AD0CR |= 0x01000000;

/* Start A/D Conversion

*/

do {

Page 22: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 19

VAL = AD0DR1; /* Read A/D Data Register */ }

while (!(VAL & 0x80000000)); /* Wait for end of A/D Conversion */

AD0CR &= ~0x01000000; /* Stop A/D Conversion */

VAL >>=6; VAL = VAL & 0x3FF; return(VAL);

}

Result:

Thus the interfacing of LED and PWM is executed.

Page 23: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 20

EXP.NO: 4 Interfacing ADC and DAC

Aim:

To write a program for Interfacing ADC and DAC.

Apparatus Required: ARM Trainer Kit

ADC and DAC Card

PC

Software Required: Keil μVision4

Flash Magic

Interfacing Analog to Digital Converter –

ADC Theory:

LPC2148 controller has two on n-chip ADCs. In the present program the ADC0 with channel 3 is used and configured to convert the analog input signal into its equivalent digital output. The configuring of on chip ADC is given below.

The ARM7 LPC21xx processor is interfaced to the 2x16 LCD module in 8-bit mode. The interface diagram is shown. The eight data pins are connected with eight data bits (P1.16 – P1.23 pins to bits D0 -D7), address bit (RS – P0.23), read / write bit (R/W – P0.22) and control signal (E – P0.21) to make LCD display complete. The pins D0, D1, D2, D3 are left free without any connections.

Page 24: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 21

16X 2LCD is a 16 pin module. In which pins 1 & 16 are grounded, 2 & 15 are given to

Vcc and 3rd pin is given to potentiometer in order adjust the contrast of LCD. Pin 4, 5 & 6 corresponds to RS, R/W & EN respectively. Pins 8 to 15 are data lines from D0 to D7 respectively. Here the LCD is used in 8 bit mode. i.e., 8 bits are used to transfer the data with MSB first and LSB next. Port 0 pins i.e. from P0.09 to 11, are used for both data and control signals. The interfacing diagram of 16X2 LCD is shown.

Program:

FOR ADC

#include <LPC214x.H> #include <STRING.H>

void DELAY(unsigned int); void INIT_GPIO(void); void INIT_PLL(void); void LCDSTR(unsigned char ADDRESS,char *MSG); void LCD_DATA(unsigned char); void LCD_CMD(unsigned int); void LCD_INIT(void); int READ_ADC(void); void INIT_ADC(void); void CONVERT_ADC(unsigned int);

unsigned int E = 0x00000800; // P1.21 ENABLE LCD unsigned int RW = 0x00000400; // P1.22 READ/WRITE LCD unsigned int RS = 0x00000200; // P1.23 REGISTER SELECT LCD

unsigned int TEMP=0,ADC=0; unsigned long temp_adv=0,temp_sum=0; unsigned int count=0;

int main() {

INIT_PLL(); INIT_GPIO(); LCD_INIT();

INIT_ADC(); LCDSTR(0x00000080," ADC "); LCDSTR(0x000000C0,"VOLTAGE = ");

while(1) {

for(count=0;count<10000;count++) {

temp_sum = temp_sum+READ_ADC(); }

temp_adv=temp_sum/10000;

Page 25: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 22

TEMP=temp_adv; temp_sum=0; ADC = 1000*(TEMP*(3.901/1024)); LCD_CMD(0x000000CA);

CONVERT_ADC(ADC); }

} void DELAY(unsigned int VALUE) {

unsigned int i,j; for(i=0;i<VALUE;i++)

{ for(j=1;j<1200;j++);

} }

void INIT_GPIO() {

IO0DIR =0x00000E00; IO1DIR =0X00FF0000;

// P0.8 ----- P0.15 // P1.21 --- P1.23

LCD DATA LCD CONTROL

} void INIT_PLL() {

PLL0CFG=0x00000024; // TO GENERATE 60 MHZ CCLK

PLL0CON=0x00000001; PLL0FEED=0x000000AA;

// UPDATE THE PLL REGISTER

PLL0FEED=0x00000055; while(!(PLL0STAT & 0x00000400)); // CHECK WHETHRT THE CCLK

IS GENERATED EXAXT VALUE PLL0CON=0x00000003; PLL0FEED=0x000000AA;

// CONNECT PLL

// UPDATE THE PLL REGISTER PLL0FEED=0x00000055; VPBDIV=0x00000002;

// PCLK=1/2*CCLK

} void LCD_DATA(unsigned char VALUE) {

unsigned int b,TEMP; TEMP = VALUE; for(b=0;b<16;b++)

{ TEMP = TEMP<<1;

} IO1SET = TEMP; IO1CLR = ~TEMP; IO0CLR = RW; IO0SET = RS; IO0SET = E;

Page 26: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 23

DELAY(50); IO0CLR = E;

} void LCD_CMD(unsigned int LCMD) {

unsigned int b; for(b=0;b<16;b++)

{ LCMD = LCMD<<1;

} IO1SET = LCMD; IO1CLR = ~LCMD; IO0CLR = RW; IO0CLR = RS; IO0SET = E; DELAY(50); IO0CLR = E;

} void LCDSTR(unsigned char ADDRESS,char *MSG)

{ unsigned char COUNT,LENGTH;

LCD_CMD(ADDRESS); LENGTH = strlen(MSG);

for(COUNT=0;COUNT<LENGTH;COUNT++) {

LCD_DATA(*MSG); MSG++;

} }

void LCD_INIT() {

LCD_CMD(0x00000038); LCD_CMD(0x0000000C); LCD_CMD(0x00000001); LCD_CMD(0x00000006);

} void INIT_ADC() {

PINSEL1 |= 0x01000000; AD0CR = 0x00200602;

}

int READ_ADC() {

int VAL; AD0CR |= 0x01000000; /* Start A/D Conversion */ do

Page 27: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 24

{ VAL = AD0DR1;

/* Read A/D Data Register

*/

} while (!(VAL & 0x80000000)); /* Wait for end of A/D Conversion

*/ AD0CR &= ~0x01000000; /* Stop A/D Conversion

*/

VAL >>=6; VAL = VAL & 0x3FF; return(VAL);

} void CONVERT_ADC(unsigned int ADC)

{ unsigned int CNT1,CNT2,CNT3,CNT4;

unsigned char DATA1,DATA2,DATA3,DATA4; CNT1 = ADC % 10000/1000;

CNT2 = ADC % 1000/100; CNT3 = ADC % 100/10; CNT4 = ADC % 10/1;

DATA1 = CNT1 | 0x30; DATA2 = CNT2 | 0x30; DATA3 = CNT3 | 0x30; DATA4 = CNT4 | 0x30;

LCD_DATA(DATA1); LCD_DATA('.'); LCD_DATA(DATA2);

LCD_DATA(DATA3); LCD_DATA(DATA4);

return; }

Interfacing of Digital to Analog Converter- DAC Theory:

Page 28: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 25

A digital to analog converter is a device for converting a digital signal into an analog

signal (current or voltage). Digital to analog converters are the interface between the abstract digital world and the analog real world. Simple switches, a network of resistors, current source or capacitors many be used to implement this conversion. A DAC inputs a binary number and output an analog voltage or current signal.

The Microchip Technology Inc. MCP4921 is 2.7 – 5.5V, low power, 12-Bit Digital to Analog Converter (DAC) with SPI interface. The MCP4921 DAC to provides high accuracy and low noise performance for industrial applications where calibration or compensation of signals is required.

With an SPI connection there is always one master device (usually a microcontroller) which controls the peripheral devices. Typically there are three lines common to all the devices.

Master In Slave Out (MISO) – The Slave line for sending data to the master Master Out Salve In (MOSI) – The master Line for sending data to the peripherals Serial Clock (SCK) – The Clock pulses which synchronize data transmission generated by the master Slave Select Pin – The pin on each device that the master can be used to enable and disable specific devices.

When device’s Slave Select pin is low, it communicates with the master. When it’s high , it ignores the master. In SPI, the clock signal is controlled by the master devices LPC2148. All data is clocked in and out using this pin. These lines need to be connected to the relevant pins on the LPC21xx processor. Any unused GIO pin can be used for CS, instead pull this pin high. Conversion speed is the time it takes for the DAC – SPI connections with LPC21xx have four I/O lines (P0.4 – P0.7) required. The analog output is generated by using these four lines.

Program:

FOR DAC (Sin Wave)

#include<lpc214x.h> #include"math.h"

unsigned int t;

void Delay(unsigned long b) {

while (--b!=0); }

int main() {

int value=0x3ff; PINSEL1 = 0X00080000;

while(1) {

Page 29: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 26

value = 512+400*sin(t*0.01745); DACR = value<<6; if(++t==360)t=0;

} }

Result:

Thus interfacing ADC and DAC are executed.

Page 30: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 27

EXP.NO: 5 Interfacing Real Time Clock and Serial Port

Aim:

To write a program for Interfacing Real Time Clock and Serial Port

Apparatus Required: ARM Trainer Kit

LCD Card

PC

Software Required:

Keil μVision4

Flash Magic

Theory:

The ARM7 LPC21xx processor is interfaced to the 2x16 LCD module in 8-bit mode. The interface diagram is shown. The eight data pins are connected with eight data bits (P1.16 – P1.23 pins to bits D0 -D7), address bit (RS – P0.23), read / write bit (R/W – P0.22) and control signal (E – P0.21) to make LCD display complete. The pins D0, D1, D2, D3 are left free without any connections.

16X 2LCD is a 16 pin module. In which pins 1 & 16 are grounded, 2 & 15 are given to Vcc and 3rd pin is given to potentiometer in order adjust the contrast of LCD. Pin 4, 5 & 6 corresponds to RS, R/W & EN respectively. Pins 8 to 15 are data lines from D0 to D7 respectively. Here the LCD is used in 8 bit mode. i.e., 8 bits are used to transfer the data with MSB first and LSB next. Port 0 pins i.e. from P0.09 to 11, are used for both data and control signals. The interfacing diagram of 16X2 LCD is shown.

Page 31: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 28

Program:

For Real Time Clock:

#include <LPC214x.H> #include <STRING.H>

void DELAY(unsigned int); void INIT_GPIO(void); void LCDSTR(unsigned char ADDRESS,char *MSG); void LCD_DATA(unsigned char); void LCD_CMD(unsigned int); void LCD_INIT(void); void SETTIME(void);

unsigned int E = 0x00000800; // P1.21 ENABLE LCD unsigned int RW = 0x00000400; // P1.22 READ/WRITE LCD unsigned int RS = 0x00000200; // P1.23 REGISTER SELECT LCD

void SETTIME(void) {

CCR = 0x02; HOUR = 0; MIN = 0; SEC = 0; CCR = 0x11;

}

int main() {

SETTIME(); INIT_GPIO(); LCD_INIT();

LCDSTR(0x00000080,"REAL TIME CLOCK "); LCDSTR(0x000000C0," "); while(1) {

LCD_CMD (0x000000C3); LCD_DATA(HOUR/10 + '0'); LCD_DATA(HOUR%10 + '0'); LCD_DATA(':') ; LCD_DATA(MIN/10 + '0'); LCD_DATA(MIN%10 + '0'); LCD_DATA(':') ; LCD_DATA(SEC/10 + '0'); LCD_DATA(SEC%10 + '0');

}

Page 32: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 29

}

void DELAY(unsigned int VALUE) {

unsigned int i,j; for(i=0;i<VALUE;i++)

{ for(j=1;j<1200;j++);

} }

void INIT_GPIO() {

IO0DIR =0x00000E00; // P0.8 ----- P0.15

LCD DATA

} void LCD_DATA(unsigned char VALUE) {

unsigned int b,TEMP; TEMP = VALUE;

for(b=0;b<16;b++) {

TEMP = TEMP<<1; }

IO1SET = TEMP; IO1CLR = ~TEMP; IO0CLR = RW; IO0SET = RS; IO0SET = E; DELAY(50); IO0CLR = E;

} void LCD_CMD(unsigned int LCMD) {

unsigned int b; for(b=0;b<16;b++)

{ LCMD = LCMD<<1;

} IO1SET = LCMD; IO1CLR = ~LCMD; IO0CLR = RW; IO0CLR = RS; IO0SET = E; DELAY(50); IO0CLR = E;

Page 33: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 30

} void LCDSTR(unsigned char ADDRESS,char *MSG)

{ unsigned char COUNT,LENGTH;

LCD_CMD(ADDRESS); LENGTH = strlen(MSG);

for(COUNT=0;COUNT<LENGTH;COUNT++) {

LCD_DATA(*MSG); MSG++;

} }

void LCD_INIT() {

LCD_CMD(0x00000038); LCD_CMD(0x0000000C); LCD_CMD(0x00000001); LCD_CMD(0x00000006);

}

Program

For Serial Port:

/***************************************************************** *************/ /* SERIAL.C: */ /************** ****************************************************************/ /* This file is part of the RhydoLabz development kit. */ /* Copyright (c) 2005-2006 Rhydo Software. All rights reserved. /* written to run with keil uvision 3v3.53 demo software. */

*/

/*********************************************************************** *******/

#include <LPC214x.H>

/* LPC21xx definitions

*/

void init_serial (void) { /* Initialize Serial Interface */

PINSEL0 = PINSEL0 | 0X00000005; /* Enable RxD0 and TxD0 U0LCR = 0X83; /*8 bits, no Parity, 1 Stop bit */ U0DLL = 0Xbb; //c3 U0DLM = 0X00; /* 9600bps

baud rate */ U0LCR = 0X03; /* DLAB = 0 */

*/

}

char sendchar (char SDat)

Page 34: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 31

{ while (!(U0LSR & 0x20)); return (U0THR = SDat);

}

int getchar (void) {

while (!(U0LSR & 0x01)); return (U0RBR);

}

Result:

Thus interfacing RTC and Serial Port are executed.

Page 35: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 32

EXP.NO: 6 Interfacing Key Board and LCD

Aim:

To write a program for Interfacing Key Board and LCD

Apparatus Required: ARM Trainer Kit

Matrix Key Board and LCD Card

PC

Software Required:

Keil μVision4

Flash Magic

Interfacing of Matrix Keyboard with LCD

Theory:

The ARM7 LPC21xx processor is interfaced to the 2x16 LCD module in 8-bit mode. The interface diagram is shown. The eight data pins are connected with eight data bits (P1.16 – P1.23 pins to bits D0 -D7), address bit (RS – P0.23), read / write bit (R/W – P0.22) and control signal (E – P0.21) to make LCD display complete. The pins D0, D1, D2, D3 are left free without any connections.

16X 2LCD is a 16 pin module. In which pins 1 & 16 are grounded, 2 & 15 are given to Vcc and 3rd pin is given to potentiometer in order adjust the contrast of LCD. Pin 4, 5 & 6 corresponds to RS, R/W & EN respectively. Pins 8 to 15 are data lines from D0 to D7 respectively. Here the LCD is used in 8 bit mode. i.e., 8 bits are used to transfer the data with MSB first and LSB next. Port 0 pins i.e. from P0.09 to 11, are used for both data and control signals. The interfacing diagram of 16X2 LCD is shown.

Page 36: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 33

Program:

#include <LPC214x.H> #include <STRING.H>

#define O1 0X00E00000 #define O2 0X00D00000 #define O3 0X00B00000 #define O4 0X00700000

#define I1 0x000E0000 #define I2 0x000D0000 #define I3 0x000B0000 #define I4 0x00070000

#define CLR 0x00F00000

void DELAY(unsigned int); void INIT_GPIO(void); void INIT_PLL(void); void LCDSTR(unsigned char ADDRESS,char *MSG); void LCD_DATA(unsigned char); void LCD_CD(unsigned int); void LCD_INIT(void); char scan (int); void delay(int);

unsigned int E = 0x00000800; // P1.21 ENABLE LCD unsigned int RW = 0x00000400; // P1.22 READ/WRITE LCD unsigned int RS = 0x00000200; // P1.23 REGISTER SELECT LCD

int main() {

INIT_PLL(); INIT_GPIO(); LCD_INIT();

LCDSTR(0x00000080,"Matrix KeyPad "); LCDSTR(0x000000C0,"Key Pressed: ");

while(1) {

IO0CLR = CLR; IO0SET = O1;

delay(10); if(scan(I1))LCDSTR(0x000000CC,"0"); //S1 if(scan(I2))LCDSTR(0x000000CC,"4"); //S5 if(scan(I3))LCDSTR(0x000000CC,"8"); //S9 if(scan(I4))LCDSTR(0x000000CC,"C"); //S13

Page 37: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 34

IO0CLR = CLR; IO0SET = O2; if(scan(I1))LCDSTR(0x000000CC,"1"); //S2 if(scan(I2))LCDSTR(0x000000CC,"5"); //S6 if(scan(I3))LCDSTR(0x000000CC,"9"); //S10 if(scan(I4))LCDSTR(0x000000CC,"D"); //S14 IO0CLR = CLR; IO0SET = O3; if(scan(I1))LCDSTR(0x000000CC,"2"); //S3 if(scan(I2))LCDSTR(0x000000CC,"6"); //S7 if(scan(I3))LCDSTR(0x000000CC,"A"); //S11 if(scan(I4))LCDSTR(0x000000CC,"E"); //S15 IO0CLR = CLR; IO0SET = O4; if(scan(I1))LCDSTR(0x000000CC,"3"); //S4 if(scan(I2))LCDSTR(0x000000CC,"7"); //S8 if(scan(I3))LCDSTR(0x000000CC,"B"); //S12 if(scan(I4))LCDSTR(0x000000CC,"F"); //S16

} }

char scan(int keystatus) /* scanning a a key */ { while((IO0PIN & 0X000F0000)==keystatus)

{ delay(50); if((IO0PIN & 0X000F0000)== 0X000F0000)return(1);

} return(0) ;

} void delay(int n) /* generates one milisecond delay */ {

int i,j; for (i=1; i<=n; i++) for(j=0; j<=10000; j++);

} void DELAY(unsigned int VALUE) {

unsigned int i,j; for(i=0;i<VALUE;i++)

{ for(j=1;j<1200;j++);

} }

void INIT_GPIO() {

IO0DIR =0x00F00E00; // P0.8 ----- P0.15 LCD DATA

Page 38: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 35

IO1DIR =0X00FF0000;

// P1.21 --- P1.23 LCD CONTROL

} void INIT_PLL() {

PLL0CFG=0x00000024; // TO GENERATE 60 MHZ CCLK

PLL0CON=0x00000001; PLL0FEED=0x000000AA;

// UPDATE THE PLL REGISTER

PLL0FEED=0x00000055; while(!(PLL0STAT & 0x00000400)); // CHECK WHETHRT THE CCLK

IS GENERATED EXAXT VALUE PLL0CON=0x00000003; PLL0FEED=0x000000AA;

// CONNECT PLL

// UPDATE THE PLL REGISTER PLL0FEED=0x00000055; VPBDIV=0x00000002;

// PCLK=1/2*CCLK

} void LCD_DATA(unsigned char VALUE) {

unsigned int b,TEMP; TEMP = VALUE; for(b=0;b<16;b++)

{ TEMP = TEMP<<1;

} IO1SET = TEMP; IO1CLR = ~TEMP; IO0CLR = RW; IO0SET = RS; IO0SET = E; DELAY(50); IO0CLR = E;

} void LCD_CMD(unsigned int LCMD) {

unsigned int b; for(b=0;b<16;b++)

{ LCMD = LCMD<<1;

} IO1SET = LCMD; IO1CLR = ~LCMD; IO0CLR = RW; IO0CLR = RS; IO0SET = E; DELAY(50); IO0CLR = E;

} void LCDSTR(unsigned char ADDRESS,char *MSG)

Page 39: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 36

{ unsigned char COUNT,LENGTH;

LCD_CMD(ADDRESS); LENGTH = strlen(MSG);

for(COUNT=0;COUNT<LENGTH;COUNT++) {

LCD_DATA(*MSG); MSG++;

} }

void LCD_INIT() {

LCD_CMD(0x00000038); LCD_CMD(0x0000000C); LCD_CMD(0x00000001); LCD_CMD(0x00000006);

}

Result:

Thus interfacing of Key Board and LCD are executed.

Page 40: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 37

EXP.NO: 7 Interfacing Stepper Motor and Temperature Sensor

Aim:

To write a program for Interfacing Stepper motor

Apparatus Required: ARM Trainer Kit

Stepper Motor and Matrix Key Board

PC

Software Required:

Keil μVision4

Flash Magic

Interfacing Stepper Motor

Theory:

A stepper motor is a brushless, synchronous electric motor that converts digital pulses

into mechanical rotation in steps. Every revolution of the stepper motor is divided into a discrete

number of steps, and receives the motor rotates through one step.

Figure shows the interface of the stepper motor to ARM7 controller. The stepper motor is

connected to Microcontroller using a ULN2003 driver IC. The ULN driver IC is connected to the

Port 1 pins P0.16 to P0.19 pins. So as the microcontroller gives pulses with a particular

frequency to ULN2003, the motor is rotated either in clockwise or anticlockwise.

Page 41: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 38

This Program first configures the ARM Port0 as a GPIO and also as an port. The sequence code

is sent to the driver IC using these port pins. A suitable delay is incorporated between each step

rotation. By applying the code in the reverse order, the stepper motor can be rotated in the

anticlockwise direction.

Program:

For Stepper Motor:

#include<LPC214X.H>

#define O1 0X000000E0 #define O2 0X000000D0 #define O3 0X000000B0 #define O4 0X00000070

#define I1 0x0000000E #define I2 0x0000000D #define I3 0x0000000B #define I4 0x00000007

#define CLR 0x000000F0

unsigned int CLOCK[4] = {0x00030000,0x00090000,0x000C0000,0x00060000}; unsigned int ANTI_CLOCK[4] = {0x00060000,0x000C0000,0x00090000,0x00030000};

char scan (int); void delay(int);

int main(void){ IO0DIR = 0X000F00F0; while(1){ unsigned char I; IO0CLR = CLR; IO0SET = O1; while(scan(I1)) //S1

{ for(I=0;I<4;I++)

{ IO0SET |= CLOCK[I];

IO0CLR |= ~CLOCK[I]; delay(5);

} }

while(scan(I2)) //S5 { for(I=0;I<4;I++)

{ IO0SET |= CLOCK[I];

Page 42: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 39

IO0CLR |= ~CLOCK[I]; delay(10);

} }

IO0CLR = CLR; IO0SET = O2; while(scan(I1)) //S2

{ for(I=0;I<4;I++)

{ IO0SET |= ANTI_CLOCK[I];

IO0CLR |= ~ANTI_CLOCK[I]; delay(5);

} }

while(scan(I2)) //S6 { for(I=0;I<4;I++)

{ IO0SET |= CLOCK[I];

IO0CLR |= ~CLOCK[I]; delay(50);

} }

IO0CLR = CLR; IO0SET = O3; while(scan(I2)) //S7

{ for(I=0;I<4;I++)

{ IO0SET |= CLOCK[I];

IO0CLR |= ~CLOCK[I]; delay(90);

} }

} } char scan(int keystatus) /* scanning a a key */ { while((IO0PIN & 0X0000000F)==keystatus)

{ return(1);

} return(0);

} void delay(int n) /* generates one milisecond delay */

{

Page 43: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 40

int i,j; for (i=1; i<=n; i++) for(j=0; j<=10000; j++); }

Interfacing Temperature Sensor:

Theory:

The ARM7 LPC21xx processor is interfaced to the 2x16 LCD module in 4-bit mode. The interface diagram is shown. The four data pins are connected with 4 data bits (P1.19 – P1.22 pins to bits D4 -D7), address bit (RS – P0.16), read / write bit (R/W – P0.17) and control signal (E – P0.18) to make LCD display complete. The pins D0, D1, D2, D3 are left free without any connections.

16X 2LCD is a 16 pin module. In which pins 1 & 16 are grounded, 2 & 15 are given to Vcc and 3rd pin is given to potentiometer in order adjust the contrast of LCD. Pin 4, 5 & 6 corresponds to RS, R/W & EN respectively. Pins 8 to 15 are data lines from D0 to D7 respectively. Here the LCD is used in 4 bit mode. i.e., 4 bits are used to transfer the data with MSB first and LSB next. Port 0 pins i.e. from P0.16 to 22, are used for both data and control signals. The interfacing diagram of 16X2 LCD is shown.

Program:

For Temperature Sensor:

#include <LPC214x.H> #include <STRING.H>

void DELAY(unsigned int); void INIT_GPIO(void); void INIT_PLL(void); void LCDSTR(unsigned char ADDRESS,char *MSG); void LCD_DATA(unsigned char); void LCD_CMD(unsigned int); void LCD_INIT(void); int READ_ADC(void); void INIT_ADC(void); void CONVERT_ADC(unsigned int);

unsigned int E = 0x00000800; // P1.21 ENABLE LCD unsigned int RW = 0x00000400; // P1.22 READ/WRITE LCD unsigned int RS = 0x00000200; // P1.23 REGISTER SELECT LCD

unsigned int TEMP=0,ADC=0;

int main() {

INIT_PLL();

Page 44: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 41

INIT_GPIO(); LCD_INIT();

INIT_ADC(); LCDSTR(0x00000080," TEMPERATURE ");

LCDSTR(0x000000C0,"DEGREE C = "); while(1) {

TEMP = READ_ADC(); ADC = (1000*(TEMP*(3.901/1024)))-100; LCD_CMD(0x000000CA);

CONVERT_ADC(ADC); }

} void DELAY(unsigned int VALUE) {

unsigned int i,j; for(i=0;i<VALUE;i++)

{ for(j=1;j<1200;j++);

} }

void INIT_GPIO() {

IO0DIR =0x00000E00; IO1DIR =0X00FF0000;

// P0.8 ----- P0.15 LCD DATA // P1.21 --- P1.23 LCD CONTROL

} void INIT_PLL() {

PLL0CFG=0x00000024; // TO GENERATE 60 MHZ CCLK

PLL0CON=0x00000001; PLL0FEED=0x000000AA;

// UPDATE THE PLL REGISTER

PLL0FEED=0x00000055; while(!(PLL0STAT & 0x00000400)); // CHECK WHETHRT THE CCLK

IS GENERATED EXAXT VALUE PLL0CON=0x00000003; PLL0FEED=0x000000AA;

// CONNECT PLL

// UPDATE THE PLL REGISTER PLL0FEED=0x00000055; VPBDIV=0x00000002;

// PCLK=1/2*CCLK

} void LCD_DATA(unsigned char VALUE) {

unsigned int b,TEMP; TEMP = VALUE; for(b=0;b<16;b++)

{ TEMP = TEMP<<1;

Page 45: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 42

} IO1SET = TEMP; IO1CLR = ~TEMP; IO0CLR = RW; IO0SET = RS; IO0SET = E; DELAY(50); IO0CLR = E;

} void LCD_CMD(unsigned int LCMD) {

unsigned int b; for(b=0;b<16;b++)

{ LCMD = LCMD<<1;

} IO1SET = LCMD; IO1CLR = ~LCMD; IO0CLR = RW; IO0CLR = RS; IO0SET = E; DELAY(50); IO0CLR = E;

} void LCDSTR(unsigned char ADDRESS,char *MSG)

{ unsigned char COUNT,LENGTH;

LCD_CMD(ADDRESS); LENGTH = strlen(MSG);

for(COUNT=0;COUNT<LENGTH;COUNT++) {

LCD_DATA(*MSG); MSG++;

} }

void LCD_INIT() {

LCD_CMD(0x00000038); LCD_CMD(0x0000000C); LCD_CMD(0x00000001); LCD_CMD(0x00000006);

} void INIT_ADC() {

PINSEL1 |= 0x01000000; AD0CR = 0x00200602;

}

Page 46: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 43

int READ_ADC() {

int VAL; AD0CR |= 0x01000000;

/* Start A/D Conversion

*/

do {

VAL = AD0DR1; /* Read A/D Data Register

*/

} while (!(VAL & 0x80000000));

/* Wait for end of A/D Conversion

*/ AD0CR &= ~0x01000000; /* Stop A/D Conversion

*/

VAL >>=6; VAL = VAL & 0x3FF; return(VAL);

} void CONVERT_ADC(unsigned int ADC)

{ unsigned int CNT1,CNT2,CNT3,CNT4;

unsigned char DATA1,DATA2,DATA3,DATA4; CNT1 = ADC % 10000/1000;

CNT2 = ADC % 1000/100; CNT3 = ADC % 100/10; CNT4 = ADC % 10/1; DATA1 = CNT1 | 0x30; DATA2 = CNT2 | 0x30; DATA3 = CNT3 | 0x30; DATA4 = CNT4 | 0x30;

LCD_DATA(DATA1); LCD_DATA(DATA2);

LCD_DATA(DATA3); LCD_DATA('.');

LCD_DATA(DATA4); return;

}

Result: Thus the interfacing of Stepper motor and Temperature Sensor are executed.

Page 47: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 44

EXP.NO: 8 Interfacing EPROM and Interrupt

Aim:

To write a program for Interfacing EPROM and Interrupt

Apparatus Required: ARM Trainer Kit

EPROM Card

PC

Software Required:

Keil μVision4

Flash Magic

Interfacing of External EPROM:

Theory:

The ARM7 LPC21xx processor is interfaced to the 2x16 LCD module in 8-bit mode. The interface diagram is shown. The eight data pins are connected with eight data bits (P1.16 – P1.23 pins to bits D0 -D7), address bit (RS – P0.23), read / write bit (R/W – P0.22) and control signal (E – P0.21) to make LCD display complete. The pins D0, D1, D2, D3 are left free without any connections.

16X 2LCD is a 16 pin module. In which pins 1 & 16 are grounded, 2 & 15 are given to Vcc and 3rd pin is given to potentiometer in order adjust the contrast of LCD. Pin 4, 5 & 6 corresponds to RS, R/W & EN respectively. Pins 8 to 15 are data lines from D0 to D7 respectively. Here the LCD is used in 8 bit mode. i.e., 8 bits are used to transfer the data with MSB first and LSB next. Port 0 pins i.e. from P0.09 to 11, are used for both data and control signals. The interfacing diagram of 16X2 LCD is shown.

Page 48: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 45

Program:

For EPROM:

#include <LPC21xx.H> #include <STRING.H>

#define DEV_WR_STAT 0X18 #define DEV_RD_STAT 0X40 #define LOC_WR_STAT 0x28 #define DATA_WR_STAT 0x28 #define DEV_WRITE 0XA0 #define DEV_READ 0XA1

#define O1 0X00E00000 #define O2 0X00D00000 #define O3 0X00B00000 #define O4 0X00700000

#define I1 0x000E0000 #define I2 0x000D0000 #define I3 0x000B0000 #define I4 0x00070000

#define CLR 0x00F00000

void DELAY(unsigned int); void INIT_GPIO(void); void INIT_PLL(void); void LCDSTR(unsigned char ADDRESS,char *MSG); void LCD_DATA(unsigned char); void LCD_CD(unsigned int); void LCD_INIT(void); void delay(unsigned int del); void i2c_init(void); void i2c_start(void); void i2c_write(char dat , char status); void i2c_stop(void); char i2c_read(void); void eeprom_read(char loc,char loc_count , char *ptr); void eeprom_write(char loc , char *ptr); char scan (int); void delay1(int);

unsigned int E = 0x00000800; // P1.21 ENABLE LCD unsigned int RW = 0x00000400; // P1.22 READ/WRITE LCD unsigned int RS = 0x00000200; // P1.23 REGISTER SELECT LCD

unsigned char I2Cdata;

Page 49: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 46

char buf[16]; unsigned char cnt=0;

int main() {

INIT_GPIO(); LCD_INIT();

LCDSTR(0x00000080,"Ext EEPROM TEST "); LCDSTR(0x000000C0,"MESSAGE COUNT: 1"); cnt=1; while(1) {

IO0CLR = CLR; IO0SET = O1;

delay(10); if(scan(I1))

{ LCDSTR(0x000000C0,"MESSAGE COUNT: 1"); cnt=1;

} if(scan(I2))

{ if(cnt==1) {

eeprom_write(0 , "Enthu Technology"); LCDSTR(0x000000C0,"Writting ");

delay(120000); }

if(cnt==2) {

eeprom_write(0 , "Coimbatore "); LCDSTR(0x000000C0,"Writting

delay(120000); }

if(cnt==3) {

");

eeprom_write(0 , "SSN Sqaure ");

LCDSTR(0x000000C0,"Writting ");

delay(120000); }

if(cnt==4) {

eeprom_write(0 , "Tamil Nadu ");

LCDSTR(0x000000C0,"Writting ");

delay(120000); }

}

Page 50: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 47

IO0CLR = CLR; IO0SET = O2; if(scan(I1))

{ LCDSTR(0x000000C0,"MESSAGE COUNT: 2"); cnt=2;

} if(scan(I2)) { eeprom_read(0,16, buf); LCDSTR(0x000000C0,"Reading "); DELAY(5000);

LCDSTR(0xC0,buf); }

IO0CLR = CLR; IO0SET = O3; if(scan(I1))

{ LCDSTR(0x000000C0,"MESSAGE COUNT: 3"); cnt=3;

} if(scan(I2)) {

eeprom_write(0 , " "); LCDSTR(0x000000C0,"Erasing ");

delay(120000); cnt=5;

} IO0CLR = CLR; IO0SET = O4; if(scan(I1))

{ LCDSTR(0x000000C0,"MESSAGE COUNT: 4"); cnt=4;

} }

} void DELAY(unsigned int VALUE) {

unsigned int i,j; for(i=0;i<VALUE;i++)

{ for(j=1;j<1200;j++);

} }

void INIT_GPIO()

Page 51: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 48

{ IO0DIR =0x00F00E00; IO1DIR =0X00FF0000;

// P0.8 ----- P0.15 // P1.21 --- P1.23

LCD DATA LCD CONTROL

} void LCD_DATA(unsigned char VALUE) {

unsigned int b,TEMP; TEMP = VALUE; for(b=0;b<16;b++)

{ TEMP = TEMP<<1;

} IO1SET = TEMP; IO1CLR = ~TEMP; IO0CLR = RW; IO0SET = RS; IO0SET = E; DELAY(50); IO0CLR = E;

} void LCD_CMD(unsigned int LCMD) {

unsigned int b; for(b=0;b<16;b++)

{ LCMD = LCMD<<1;

} IO1SET = LCMD; IO1CLR = ~LCMD; IO0CLR = RW; IO0CLR = RS; IO0SET = E; DELAY(50); IO0CLR = E;

} void LCDSTR(unsigned char ADDRESS,char *MSG)

{ unsigned char COUNT,LENGTH;

LCD_CMD(ADDRESS); LENGTH = strlen(MSG);

for(COUNT=0;COUNT<LENGTH;COUNT++) {

LCD_DATA(*MSG); MSG++;

} }

void LCD_INIT()

Page 52: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 49

{ LCD_CMD(0x00000038); LCD_CMD(0x0000000C); LCD_CMD(0x00000001); LCD_CMD(0x00000006);

} void delay(unsigned int del) {

while(del-- > 0); }

void i2c_init(void) {

PINSEL0 = 0X50; I2CONCLR = 0X0000002C;

/* clears AA,I2C interrupt

flag,START flag bit*/

I2SCLL = 0xFFFF;

/* bitrate = 400kHz

*/

// 70,5 I2SCLH = 0xFFFF;;

} void i2c_start() {

I2CONSET |= 0x00000020; while (I2STAT !=

/* Set STA flag */ 0x00000008); /* Wait for Status Set - 0x08 */

} void i2c_write(char dat , char status) {

I2DAT = dat; I2CONSET = 0X00000004; I2CONCLR = 0X00000028; while (I2STAT != status); /* Wait for Status Set */

} void i2c_stop(void) {

I2CONSET |= 0x00000014; I2CONCLR = 0x00000008;

/* Stop I2C and Start Bit */ }

char i2c_read(void) {

I2CONSET = 0X00000004; I2CONCLR = 0X00000028; while (I2STAT != return(I2DAT);

0x00000050); /* Wait for Status Set - 0x50 */

}

void eeprom_read(char loc,char loc_count , char *ptr) {

i2c_init(); i2c_start();

Page 53: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 50

i2c_write(DEV_WRITE ,DEV_WR_STAT); i2c_write(loc , LOC_WR_STAT); i2c_stop(); delay(5000); i2c_start(); i2c_write(DEV_READ ,DEV_RD_STAT); while(loc_count-- > 0) { *ptr = i2c_read(); ptr++;

} i2c_stop();

} void eeprom_write(char loc , char *ptr) {

i2c_init(); i2c_start(); i2c_write(DEV_WRITE ,DEV_WR_STAT); i2c_write(loc , LOC_WR_STAT); while(*ptr != '\0')

{ i2c_write(*ptr , LOC_WR_STAT); ptr++;

} i2c_stop();

} char scan(int keystatus) /* scanning a a key */ { while((IO0PIN & 0X000F0000)==keystatus){

delay1(50); if((IO0PIN & 0X000F0000)== 0X000F0000)return(1); } return(0) ;

} void delay1(int n) /* generates one milisecond delay */ { int i,j; for (i=1; i<=n; i++) for(j=0; j<=10000; j++); }

Page 54: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 51

Interfacing of External Interrupt:

Program:

For Interrupt:

#include<lpc21xx.h> void DELAY(unsigned long VALUE); unsigned int A = 0x00010000;

void ext_interrupt(void)__irq {

EXTINT = 0X02; /* Clear interrupt flag

*/ DELAY(5000000); VICVectAddr = 0x00000000;

/*

Acknowledge Interrupt */ }

void init_ext(void) {

PINSEL0 |= 0X20000000; EXT1 */ EXTMODE = 0X02;

edge sensitive */ EXTPOLAR = 0X02;

edge */ VICVectAddr0 =(unsigned int)ext_interrupt; VICVectCntl0 = 0x0000002F;

EXT1 Interrupt */ VICIntEnable = 0x00008000;

EXT1 INTERRUPT */

/* enable

/*

/* on rising

/* Set Interrupt Vector in 0 */ /* Use it for

/* enable

}

int main(void) {

IO0DIR = 0X00FF0000; init_ext();

Page 55: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 52

while(1) {

IO0SET |= A; /* Port0 00-07 High

*/

DELAY(1000000); IO0CLR |= A;

/* Port0 00-07 High

*/

A <<=1; if(A==0x01000000) A=0x00010000; DELAY(1000000); }

} void DELAY(unsigned long VALUE) {

while(VALUE>0) { VALUE--;

} }

Result:

Thus interfacing EPROM and Interrupt are executed.

Page 56: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 53

EXP.NO: 9 Implementing Zigbee Protocol with ARM

Aim:

To write a program for Implementing Zigbee protocol with ARM

Apparatus Required: ARM Trainer Kit

Zigbee

Key Pad

LCD

Stepper Motor

PC

Software Required:

Keil μVision4

Flash Magic

Program:

For Transmitter:

#include <LPC214x.H> #include <STRING.H>

#define O1 0X00E00000 #define O2 0X00D00000 #define O3 0X00B00000 #define O4 0X00700000

#define I1 0x000E0000 #define I2 0x000D0000 #define I3 0x000B0000 #define I4 0x00070000

#define CLR 0x00F00000

void DELAY(unsigned int); void INIT_GPIO(void); void INIT_PLL(void); void LCDSTR(unsigned char ADDRESS,char *MSG); void LCD_DATA(unsigned char); void LCD_CD(unsigned int);

Page 57: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 54

char sendchar (char SDat); void init_serial (void); void LCD_INIT(void); char scan (int); char scan(int keystatus);

unsigned int E = 0x00000800; // P1.21 ENABLE LCD unsigned int RW = 0x00000400; // P1.22 READ/WRITE LCD unsigned int RS = 0x00000200; // P1.23 REGISTER SELECT LCD

int main() {

init_serial(); INIT_PLL(); INIT_GPIO(); LCD_INIT();

LCDSTR(0x00000080," Zig Bee Based "); LCDSTR(0x000000C0,"Motor Controller"); DELAY(6000);

while(1) {

IO0CLR = CLR; IO0SET = O1; while(scan(I1))

{ LCDSTR(0x000000C0,"Running C-wise "); sendchar('C');

} IO0CLR = CLR; IO0SET = O2; while(scan(I1)) {

LCDSTR(0x000000C0,"Running AC-wise "); sendchar('A');

} LCDSTR(0x000000C0,"Motor Stopped ");

} }

void DELAY(unsigned int VALUE) {

unsigned int i,j; for(i=0;i<VALUE;i++)

{ for(j=1;j<1200;j++);

} }

Page 58: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 55

void INIT_GPIO() {

IO0DIR =0x00F00E00; IO1DIR =0X00FF0000;

// P0.8 ----- P0.15 // P1.21 --- P1.23

LCD DATA LCD CONTROL

} void INIT_PLL() {

PLL0CFG=0x00000024; // TO GENERATE 60 MHZ CCLK PLL0CON=0x00000001; PLL0FEED=0x000000AA; // UPDATE THE PLL REGISTER PLL0FEED=0x00000055; while(!(PLL0STAT & 0x00000400)); // CHECK WHETHRT THE CCLK

IS GENERATED EXAXT VALUE PLL0CON=0x00000003; // CONNECT PLL PLL0FEED=0x000000AA; // UPDATE THE PLL REGISTER PLL0FEED=0x00000055; VPBDIV=0x00000002; // PCLK=1/2*CCLK

} void LCD_DATA(unsigned char VALUE) {

unsigned int b,TEMP; TEMP = VALUE;

for(b=0;b<16;b++) {

TEMP = TEMP<<1; }

IO1SET = TEMP; IO1CLR = ~TEMP; IO0CLR = RW; IO0SET = RS; IO0SET = E; DELAY(50); IO0CLR = E;

} void LCD_CMD(unsigned int LCMD) {

unsigned int b; for(b=0;b<16;b++)

{ LCMD = LCMD<<1;

} IO1SET = LCMD; IO1CLR = ~LCMD; IO0CLR = RW; IO0CLR = RS; IO0SET = E; DELAY(50);

Page 59: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 56

IO0CLR = E; }

void LCDSTR(unsigned char ADDRESS,char *MSG) {

unsigned char COUNT,LENGTH; LCD_CMD(ADDRESS);

LENGTH = strlen(MSG); for(COUNT=0;COUNT<LENGTH;COUNT++) {

LCD_DATA(*MSG); MSG++;

} }

void LCD_INIT() {

LCD_CMD(0x00000038); LCD_CMD(0x0000000C); LCD_CMD(0x00000001); LCD_CMD(0x00000006);

}

void init_serial (void) {

PINSEL0 = PINSEL0 | 0X00000005; U0LCR = 0X83; U0DLL = 0XC3; U0DLM = 0X00; U0LCR = 0X03;

}

char sendchar (char SDat) {

while (!(U0LSR & 0x20)); return (U0THR = SDat);

} char scan(int keystatus) { while((IO0PIN & 0X000F0000)==keystatus)

{ return(1);

} return(0);

}

Page 60: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 57

Program:

For Receiver:

#include <LPC21xx.H> #include "serial.h"

void delay(int n);

unsigned int CLOCK[4] = {0x00330000,0x00990000,0x00CC0000,0x00660000}; unsigned int ANTI_CLOCK[4] = {0x00660000,0x00CC0000,0x00990000,0x00330000}; unsigned char SBUF=0;

int main(void) { init_serial (); IO0DIR = 0X00FF0000; while(1) {

SBUF= getchar(); if(SBUF=='C')

{ IO0SET |= CLOCK[0];

IO0CLR |= ~CLOCK[0]; delay(5);

IO0SET |= CLOCK[1]; IO0CLR |= ~CLOCK[1];

delay(5); IO0SET |= CLOCK[2];

IO0CLR |= ~CLOCK[2]; delay(5); IO0SET |= CLOCK[3];

IO0CLR |= ~CLOCK[3]; delay(5);

} if(SBUF=='A')

{ IO0SET |= ANTI_CLOCK[0];

IO0CLR |= ~ANTI_CLOCK[0]; delay(5);

IO0SET |= ANTI_CLOCK[1]; IO0CLR |= ~ANTI_CLOCK[1];

delay(5); IO0SET |= ANTI_CLOCK[2];

IO0CLR |= ~ANTI_CLOCK[2]; delay(5);

IO0SET |= ANTI_CLOCK[3]; IO0CLR |= ~ANTI_CLOCK[3];

delay(5); }

}}

Page 61: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 58

void delay(int n)

{ int i,j; for (i=1; i<=n; i++) for(j=0; j<=10000; j++); }

///// ----------------

Result:

Thus implementing Zigbee protocol with ARM are executed.

Page 62: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 59

EXP.NO: 10 Interrupt Performance characteristics of ARM and FPGA

Aim:

To write a program for Interrupt Performance characteristics of ARM and FPGA

Apparatus Required: ARM Trainer Kit

Wire Connection

Functional Generator

PC

Software Required:

Keil μVision4

Flash Magic

Program:

#include <LPC214x.H> #include <STRING.H>

void DELAY(unsigned int); void INIT_GPIO(void); void INIT_PLL(void); void LCD_DATA(unsigned char); void LCD_CMD(unsigned int); void LCDSTR(unsigned char ADDRESS,char *MSG); void LCD_INIT(void); void CONVERT_DATA(unsigned int); void SEC_DELAY(void);

unsigned int E = 0x00000800; // P1.21 ENABLE LCD unsigned int RW = 0x00000400; // P1.22 READ/WRITE LCD unsigned int RS = 0x00000200; // P1.23 REGISTER SELECT LCD

unsigned int count=0;

void ext_interrupt(void)__irq {

EXTINT = 0X02; /* Clear interrupt flag */

count++;

Page 63: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 60

Interrupt }

VICVectAddr = 0x00000000;

*/

/* Acknowledge

void init_ext(void) {

PINSEL0 |= 0X20000000; /* enable EXT1 */

EXTMODE = 0X02; sensitive */

EXTPOLAR = 0X02; edge */

VICVectAddr0 =(unsigned int)ext_interrupt; VICVectCntl0 = 0x0000002F;

Interrupt */

INTERRUPT */ }

/* edge

/* on rising

/* Set Interrupt Vector in 0 */ /* Use it for EXT1

int main() {

INIT_PLL(); init_ext();

INIT_GPIO(); LCD_INIT();

LCDSTR(0x00000080,"Counter: "); while(1) {

SEC_DELAY(); LCD_CMD(0x00000088); CONVERT_DATA(count); count=0;

} }

void DELAY(unsigned int VALUE) {

unsigned int i,j; for(i=0;i<VALUE;i++)

{ for(j=1;j<1200;j++);

} }

Page 64: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 61

void INIT_GPIO() {

IO0DIR =0x00000E00; IO1DIR =0X00FF0000;

// P0.8 ----- P0.15 // P1.21 --- P1.23

LCD DATA LCD CONTROL

} void INIT_PLL() {

PLL0CFG=0x00000024; // TO GENERATE 60 MHZ CCLK

PLL0CON=0x00000001; PLL0FEED=0x000000AA;

// UPDATE THE PLL REGISTER

PLL0FEED=0x00000055; while(!(PLL0STAT & 0x00000400)); // CHECK WHETHRT THE CCLK

IS GENERATED EXAXT VALUE PLL0CON=0x00000003;

// CONNECT PLL

PLL0FEED=0x00000055; VPBDIV=0x00000002;

// PCLK=1/2*CCLK

} void LCD_DATA(unsigned char VALUE) {

unsigned int b,TEMP; TEMP = VALUE; for(b=0;b<16;b++)

{ TEMP = TEMP<<1;

} IO1SET = TEMP; IO1CLR = ~TEMP; IO0CLR = RW; IO0SET = RS; IO0SET = E; DELAY(50); IO0CLR = E;

} void LCD_CMD(unsigned int LCMD) {

unsigned int b; for(b=0;b<16;b++)

{ LCMD = LCMD<<1;

} IO1SET = LCMD; IO1CLR = ~LCMD; IO0CLR = RW; IO0CLR = RS; IO0SET = E;

Page 65: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 62

DELAY(50); IO0CLR = E;

} void LCDSTR(unsigned char ADDRESS,char *MSG)

{ unsigned char COUNT,LENGTH;

LCD_CMD(ADDRESS); LENGTH = strlen(MSG);

for(COUNT=0;COUNT<LENGTH;COUNT++) {

LCD_DATA(*MSG); MSG++;

} }

void LCD_INIT() {

LCD_CMD(0x00000038); LCD_CMD(0x0000000C); LCD_CMD(0x00000001); LCD_CMD(0x00000006);

} void CONVERT_DATA(unsigned int DATA)

{ LCD_DATA((DATA % 100000000/10000000) | 0x30); LCD_DATA((DATA % 10000000/1000000) | 0x30); LCD_DATA((DATA % 1000000/100000) | 0x30); LCD_DATA((DATA % 100000/10000) | 0x30); LCD_DATA((DATA % 10000/1000) | 0x30); LCD_DATA((DATA % 1000/100) | 0x30); LCD_DATA((DATA % 100/10) | 0x30); LCD_DATA((DATA % 10/1) | 0x30); return;

}

void SEC_DELAY() {

T0PR = 0x0000270F; T0MR0 = 0x00000BA1 ; T0TCR = 0x01; while(T0TC != T0MR0); T0MCR = 0x00000002; T0TCR = 0x02;

//0x0000270F //0x000004B0

}

Page 66: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 63

Result:

Thus Interrupt Performance characteristics of ARM and FPGA are executed.

Page 67: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 64

EXP.NO: 11 MAIL BOX

Aim:

To write a program for Mailbox

Apparatus Required: PC

Software Required:

Keil μVision4

Flash Magic

Program:

#include <RTL.h> #include <LPC21xx.H> #include <stdio.h>

OS_TID tsk1; OS_TID tsk2;

typedef struct { float voltage; float current; U32 counter;

}T_MEAS;

os_mbx_declare (MsgBox,16); _declare_box (mpool,sizeof(T_MEAS),16);

__task void send_task (void); __task void rec_task (void);

void init_serial () {

PINSEL0 = PINSEL0 | 0X00000005; U0LCR = 0X83; U0DLL = 0Xbb; U0DLM = 0X00; U0LCR = 0X03;

Page 68: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 65

}

__task void send_task (void) {

T_MEAS *mptr; tsk1 = os_tsk_self (); tsk2 = os_tsk_create (rec_task, 0); os_mbx_init (MsgBox, sizeof(MsgBox)); os_dly_wait (5);

mptr = _alloc_box (mpool); mptr->voltage = 223.72; mptr->current = 17.54; mptr->counter = 120786; os_mbx_send (MsgBox, mptr, 0xffff); IOSET0 = 0x00010000; os_dly_wait (100);

mptr = _alloc_box (mpool); mptr->voltage = 227.23; mptr->current = 12.41; mptr->counter = 170823; os_mbx_send (MsgBox, mptr, 0xffff); os_tsk_pass (); IOSET0 = 0x00020000; os_dly_wait (100);

mptr = _alloc_box (mpool); mptr->voltage = 229.44; mptr->current = 11.89; mptr->counter = 237178; os_mbx_send (MsgBox, mptr, 0xffff); IOSET0 = 0x00040000; os_dly_wait (100);

os_tsk_delete_self (); }

__task void rec_task (void) {

T_MEAS *rptr; for (;;)

{ os_mbx_wait (MsgBox, (void **)&rptr, 0xffff); printf ("\nVoltage: %.2f V\n",rptr->voltage); printf ("Current: %.2f A\n",rptr->current);

Page 69: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 66

printf ("Number of cycles: %d\n",rptr->counter); _free_box (mpool, rptr);

} }

int main (void) { IODIR0 = 0x00FF0000; IOCLR0 = 0x00FF0000; init_serial (); _init_box (mpool, sizeof(mpool),sizeof(T_MEAS)); os_sys_init (send_task); }

Result:

Thus mailbox are verified and executed.

Page 70: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 67

CONTENT BEYOND THE SYLLABUS

Ex. No. 12

INTERFACING BLUETOOTH MODULE

Aim :

To write an embedded C code for interfacing Bluetooth Module with ARM CORTEX M3-LPC2148.

Circuit Diagram Procedure:

Give +3.3V power supply to LPC2148 Primer Board; connect the 5V adapter with Bluetooth module which is connected with the LPC2148 Primer Board. There are two Bluetooth modules are required. One is connected with LPC2148 Primer Board; other one is connected with PC. First connect the serial cable between LPC2148 Primer board & PC. Then open the Hyper Terminal screen, select which port you are using and set the default settings. Now the screen should show some text messages. If the messages are correctly displayed in Hyper Terminal, then only connect the Bluetooth modules in LPC2148 Primer Board UART0 & PC. If you are not reading any data from UART0, then you just check the jumper connections & just check the serial cable is working. Otherwise you just check the code with debugging mode in Keil.

Page 71: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 68

Program:

#define CR 0x0D #include <LPC21xx.H> void init_serial (void); int putchar (int ch); int getchar (void); unsigned char test; int main(void) { char *Ptr = "*** UART0 Demo ***\n\n\rType Characters to be echoed!!\n\n\r"; VPBDIV = 0x02; // Divide Pclk by two init_serial(); while(1) { while (*Ptr) { putchar(*Ptr++); } putchar(getchar()); // Echo terminal } } void init_serial (void) { PINSEL0 = 0x00000005; // Enable RxD0 and

TxD0 U0LCR = 0x00000083; //8 bits, no Parity, 1 Stop bit U0DLL = 0x000000C3; //9600 Baud Rate @ 30MHz VPB Clock U0LCR = 0x00000003; } int putchar (int ch) { if (ch == '\n') { while (!(U0LSR & 0x20)); U0THR = CR; }

while (!(U0LSR & 0x20)); return (U0THR = ch); } int getchar (void) { while (!(U0LSR & 0x01)); return (U0RBR);

}

Page 72: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 69

Result: Thus, interfacing of GSM module with ARM CORTEX M3- LPC2148 using embedded C code was executed and verified successfully.

Page 73: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 70

Ex. No. 13

INTERFACING GPS MODULE

Aim: To write an embedded C code for interfacing GSM Module with ARM

CORTEX M3-LPC2148.

Circuit Diagram:

Procedure:

Give +3.3V power supply to LPC2148 Primer Board; connect the +5V adapter with GSM module which is connected with LPC2148 Primer Board through UART0. Open the Hyper Terminal screen, select which port you are using and set the default settings. Now the screen should show some text messages.

The following Commands and sequence of events performed for sending text message to a mobile phone through GSM Modem interfaced with microcontroller: First select the text mode for SMS by sending the following AT Command to GSM Modem: AT+CMGF = 1 . This command configures the GSM modem in text mode.

Send the following AT Command for sending SMS message in text mode along with mobile number to the GSM Modem : AT+CMGS =+923005281046 . This command sends the mobile number of the recipient mobile to the GSM modem.

Send the text message string ("hello!") to the GSM Modem This is a test message from UART".

Page 74: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 71

If you not reading any text from UART0, then you just check the jumper connections &

just check the serial cable is working. Otherwise you just check the code with debugging

mode in Keil. If you want to see more details about debugging just see the videos in

below link.

If you not reading any text from UART0, then you just check the jumper connections &

just check the serial cable is working. Otherwise you just check the code with debugging

mode in Keil. If you want to see more details about debugging just see the videos in

below link.

Program:

#define CR 0x0D #include <LPC21xx.H> #include <stdio.h> void getstring(unsigned char *);

int getchar (void) /* Read character from Serial Port */ void status_ok(void); void Serial_Init(void); void delay(unsigned int n); void main(void) { unsigned int cnt=0x80,m; char xx; Serial_Init(); delay(50); while(1) { printf("AT\r"); // AT COMMAND FOR INITIALING status_ok(); printf("AT+IPR=9600\r"); // AT COMMAND FOR BAUD RATE status_ok(); printf("AT+CMGR=2\r"); // Reading the message detail // at Index 1 with phone number, data and time status_ok(); delay(250); printf("ATD9790550124;\r");//AT COMMAND FOR CALL DIALING delay(250); status_ok(); delay(500); delay(500);

delay(500); delay(500); delay(500); delay(500); printf("ATH\r"); // AT COMMAND FOR CALL DISCONNECTING delay(250); status_ok(); delay(500); delay(500); printf("ATDL\r"); // AT COMMAND FOR REDIALING delay(250); status_ok(); delay(500); delay(500); printf("ATH\r"); // AT COMMAND FOR ANSWERING THE CALL delay(250); status_ok();

Page 75: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 72

elay(500); delay(500); } } void getstring(unsigned char *array) { unsigned char temp=0, i=0; do { temp = getchar(); *array++ = temp; } while((temp != '\r') && (temp != '\n')) *array = '\0'; } int getchar (void) /* Read character from Serial Port */ { while (!(U0LSR & 0x01)); return (U0RBR);

} void status_ok(void) { getstring(y); while(!(strstr(y,"OK"))) getstring(y);

pointr = strstr(y,"OK"); lcd_cmd(0xc0); lcd_data(*pointr++); lcd_data(*pointr);

delay(500); lcd_cmd(0x01);

} void Serial_Init(void) { PINSEL0 |= 0X00000005; //Enable Txd0 and Rxd0 U0LCR = 0x00000083; //8-bit data, no parity, 1-stop bit U0DLL = 0x00000061; //for Baud rate=9600,DLL=82 U0LCR = 0x00000003; //DLAB = 0; } void delay(unsigned int n) { unsigned int i,j; for(i=0;i<n;i++) { for(j=0;j<12000;j++) {; } }

Page 76: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 73

Result:

Thus interfacing of GSM module with ARM CORTEX M3- LPC2148 using embedded C code was executed and verified successfully

Page 77: DMI COLLEGE OF ENGINEERINGdmice.ac.in/wp-content/uploads/2017/05/EC6711.pdf · 2018-12-24 · dmi college of engineering (affiliated to anna university t chennai 600 025) palanchur,

EC6711-Embedded.Lab Dept of Electronics & Communication Engg

DMI College Of Engineering 74