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

ARM Manual Docu

The document is a user manual for the ARM 7-LPC2148 development board, detailing its specifications, features, and various experiments for embedded systems programming. It includes instructions on using Keil Micro Vision 4 for programming and provides step-by-step guides for different experiments, such as interfacing LEDs and other components. The manual serves as a comprehensive resource for users to develop and test embedded applications using the LPC2148 microcontroller.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

ARM Manual Docu

The document is a user manual for the ARM 7-LPC2148 development board, detailing its specifications, features, and various experiments for embedded systems programming. It includes instructions on using Keil Micro Vision 4 for programming and provides step-by-step guides for different experiments, such as interfacing LEDs and other components. The manual serves as a comprehensive resource for users to develop and test embedded applications using the LPC2148 microcontroller.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 127

Raana Semicondutors Pvt Ltd

| DESIGN | RE-ENGINEERING| PRODUCT |

Corporate Office : Hosur

Branch Office : Bangalore & Salem

Website : www.raana.in

Contact : 8220355225

ARM 7-LPC2148
DEVELOPMENT BOARD
USER MANUAL
EC6711 EMBEDDED LABORATORY USER MANUAL

CONTENTS

S.N0 DESCRIPTION Page No

1 INTRODUCTION ABOUT ARM 7


3

2 INTRODUCTION ABOUT KEIL MICRO VISION 4 8

3 EXPERIMENT NO : 1 FLASHING OF LED 9

4 EXPERIMENT NO : 2 INTERFACING ADC AND DAC 64

5 EXPERIMENT NO : 3 INTERFACING LED AND PWM 70

6 EXPERIMENT NO : 4 INTERFACING REAL TIME CLOCK AND SERIAL PORT 76

7 EXPERIMENT NO : 5 INTERFACING KEYBOARD AND LCD 81

8 EXPERIMENT NO : 6 INTERFACING EEPROM AND INTERRUPT 87

9 EXPERIMENT NO : 7 MAILBOX 104

EXPERIMENT NO : 8 INTERRUPT PERFORMANCE CHARACTERISTICS OF ARM


10 109
AND FPGA

EXPERIMENT NO : 9 INTERFACING STEPPER MOTOR AND TEMPERATURE


11 111
SENSOR

12 EXPERIMENT NO : 10 IMPLEMENTING ZIGBEE PROTOCOL WITH ARM 123

2
EC6711 EMBEDDED LABORATORY USER MANUAL

1. INTRODUCTION ABOUT ARM 7


An ARM processor is one of a family of CPUs based on the RISC (reduced instruction set
computer) architecture developed by Advanced RISC Machines (ARM).

ARM makes 32-bit and 64-bit RISC multi-core processors. RISC processors are designed
to perform a smaller number of types of computer instructions so that they can operate at a
higher speed, performing more millions of instructions per second (MIPS). By stripping out
unneeded instructions and optimizing pathways, RISC processors provide outstanding
performance at a fraction of the power demand of CISC (complex instruction set computing)
devices.

ARM processors are extensively used in consumer electronic devices such as smartphones,
tablets, multimedia players and other mobile devices, such as wearables. Because of their
reduced instruction set, they require fewer transistors, which enable a smaller die size for the
integrated circuitry (IC). The ARM processors smaller size reduced complexity and lower power
consumption makes them suitable for increasingly miniaturized devices.

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.

LPC2148 Pro Development Board is a powerful development platform based on LPC2148


ARM7TDMI microcontroller with 512K on-chip memory. This board is also powered by USB
port. It is ideal for developing embedded applications involving high speed wireless
communication (Zigbee / Bluetooth / WiFi), USB based data logging, real time data monitoring
and control, interactive control panels etc. The on-chip USB controller provides direct high
speed interface to a PC/laptop with speeds up to 12Mb/s. It integrates on board UARTs, LEDs,
2X16LCD, keypads, and ADC input to create a stand-alone versatile test platform.

3
EC6711 EMBEDDED LABORATORY USER MANUAL

1. SPECIFICATIONS

PROCESSOR:

 LPC2148 16/32 Bit ARM7TDMI-S™ WITH 12 MHz Crystal On Socket.


 60 MHz Maximum CPU Clock Available From Programmable On-Chip PLL With
Settling Time Of 100 S.
MEMORY:
 40 Kb Of On-Chip Static RAM.
 512 Kb Flash Memory.

TIMER, COUNTERS, SERIAL & PARALLEL I/O:

 Dual UARTS on Board.


 8-Frame FIFO‟S for Both Serial Data Transmit And Receive.
 Synchronous Serial Communication.
 32bit Timers with Double in Numbers.
 32 Bit External Event Counters With Four Capture Channels.
 Programmable 32-Bit Watch Dog Timer.
 All GPIO registers are byte addressable (GPIO- general purpose parallel I/O)
 Parallel port value can be written in one instruction.

SPECIAL FEATURES :

 On Board Voltage Regulator 3.3V With Up To 800ma Current.


 USB Connector Inbuilt With Board Itself.
 Two Channel RS232 Interface and Drivers.
 Extension Headers for All Ports of processor.

4
EC6711 EMBEDDED LABORATORY USER MANUAL

2. GENERAL BLOCK DIAGRAM

5
EC6711 EMBEDDED LABORATORY USER MANUAL

LPC2148 PROCESSOR FEATURES


o 16-bit/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package.

o 8 kB to 40 kB of on-chip static RAM and 32 kB to 512 kB of on-chip flash


memory. 128-bit wide interface/accelerator enables high-speed 60 MHz
operation.

o In-System Programming/In-Application Programming (ISP/IAP) via on-chip boot


loader software. Single flash sector/full chip erase in 400 ms and programming of
256 bytes in 1 ms.

o USB 2.0 Full-speed compliant device controller with 2 kB of endpoint RAM. In


addition, the LPC2146/48 provides 8 kB of on-chip RAM accessible to USB by
DMA.

o One or two (LPC2141/42 vs. LPC2144/46/48) 10-bit ADCs provide a total of


6/14 analog inputs, with conversion times as low as 2.44 μs per channel.

o Single 10-bit DAC provides variable analog output (LPC2142/44/46/48 only).

o Two 32-bit timers/external event counters (with four capture and four compare
channels each), PWM unit (six outputs) and watchdog.

o Low power Real-Time Clock (RTC) with independent power and 32 kHz clock
input. Multiple serial interfaces including two UARTs (16C550), two Fast I2C-
bus (400 kbit/s), SPI and SSP with buffering and variable data length capabilities.

o Vectored Interrupt Controller (VIC) with configurable priorities and vector


addresses. Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64
package.

o Up to 21 external interrupt pins available.

o 60MHz maximum CPU clock available from programmable on-chip PLL with
settling time of 100μs.

o On-chip integrated oscillator operates with an external crystal from 1 MHz to 25


MHz. Power saving modes include Idle and Power-down.

o Individual enable/disable of peripheral functions as well as peripheral clock


scaling for additional power optimization.

o Processor wake-up from Power-down mode via external interrupt or BOD. Single
power supply chip with POR and BOD circuits:

6
EC6711 EMBEDDED LABORATORY USER MANUAL

o CPU operating voltage range of 3.0 V to 3.6 V (3.3 V ± 10 %) with 5 V tolerant


I/O pads.

Here is the pin configuration of LPC 2148.

7
EC6711 EMBEDDED LABORATORY USER MANUAL

2. INTRODUCTION ABOUT KEIL MICRO VISION 4


Embedded system means some combination of computer hardware and programmable
software which is specially designed for a particular task like displaying message on LCD.

One of the important part in making an embedded system is loading the software/program we
develop into the microcontroller. Usually it is called “burning software” into the controller.
Before “burning a program” into a controller, we must do certain prerequisite operations with the
program. This includes writing the program in assembly language or C language, compiling the
program in a compiler and finally generating the hex code and bin code from the compiled
program.

Keil MicroVision is free software which solves many of the pain points for an embedded
program developer. This software is an integrated development environment (IDE), which
integrated a text editor to write programs, a compiler and it will convert your source code to hex
files too.

Here is simple guide to start working with Keil uVision which can be used for

 Writing programs in C/C++ or Assembly language


 Compiling and Assembling Programs
 Debugging program
 Creating Hex and Bin file
 Testing your program without Available real Hardware (Simulator Mode)

8
EC6711 EMBEDDED LABORATORY USER MANUAL

EXPERIMENT NO : 1 FLASHING OF LED


Light Emitting Diodes (LEDs) are the most commonly used components, usually for
displaying pin‟s digital states.
INTERFACING LED TO LPC2148

POINT LEDs LPC2148 PIN +


DETAILS
DIGITAL
LED2 P0.0
OUTPUTS LED3 P0.1
LED4 P0.2
LED5 P0.3
LED6 P0.4
LED7 P0.5
LED8 P0.6
LED9 P0.7
SCHEMATIC DIAGRAM FOR LEDs

9
EC6711 EMBEDDED LABORATORY USER MANUAL

SCREEN SHOTS FOR EXPERIMENTAL DEMOSTRATION

STEP 1:

Create new folder in the name of FLASHING LED, and copy lcd.c and lcd.h from
From CD Embedded lab experiment code FLASHING LED code

Main files: FLASHING LED.c

Sub files: lcd.c, lcd.h

STEP 2:

Click for KEIL µVISION4 Icon . Which appearing after Installing KEIL µVISION4

After opening Keil uV4, go to Project tab and Create new uVision project

10
EC6711 EMBEDDED LABORATORY USER MANUAL

Create the project in FLASHING LED folder created in Step1 and give save.

11
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 3:

Select Target Device Vendor (i.e.).NXP & click ok

12
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 4:

Then select specific chip LPC2148 in NXP

Then click ok, you will see following window click yes

Note: Code wills Not Run without Startup.s

13
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 5:

Then you will see following window

14
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 6:

Now you see Startups is already added which is necessary for running code for Keil.

Startup.s is available in C:\Keil\ARM\Startup\Philips.

The startup-code executes immediately upon reset of the target system and performs the
following operations:

15
EC6711 EMBEDDED LABORATORY USER MANUAL

We are going to add C file in two ways

Method 1: Creating a new c file for FLASHING LED.C


STEP 7:

Now Click on File Menu and Click on New.

Write Code for FLASHING LED in C and save it as FileName.c here FLASHING LED.c

16
EC6711 EMBEDDED LABORATORY USER MANUAL

PROGRAM:
#include <LPC21xx.H>
#include "lcd.h"
void delay(unsigned int a);
int main(void)
{
int i;
PINSEL0=0x00000000;
IODIR0=0x000000FF;
lcd_init();
lcd_write_control(0x01); // Clear Display (Clear Display,Set DD RAM Address=0)
goto_cursor(0x00); // Set Cursor Line-1
lcd_print(" RAANA FLASHING "); // Display LCD Line-1
goto_cursor(0x40); // Set Cursor = Line-2
lcd_print(" LED DEMO ");
while(1)
{

for(i=0;i<=10;i++)
{
IOSET0=0x000000FF;
delay(70);
IOCLR0=0x000000FF;
delay(70);
}
for(i=0;i<=7;i++)
{
IOSET0=0x00000001<< i ;
delay(30);
}
for(i=0;i<=7;i++)
{
IOCLR0=0x00000080>> i ;
delay(30);
}
for(i=0;i<=10;i++)
{
IOCLR0=0x00000055;
IOSET0=0x000000AA;
delay(70);
17
EC6711 EMBEDDED LABORATORY USER MANUAL

IOCLR0=0x000000AA;
IOSET0=0x00000055;
delay(70);
}
for(i=0;i<=7;i++)
{
IOSET0=0x00000001<< i;
delay(30);
IOCLR0=0x000000FF;
delay(30);
}
for(i=0;i<=7;i++)
{
IOSET0=0x00000080>> i;
delay(30);
IOCLR0=0x000000FF;
delay(30);
}
}

void delay(unsigned int a)

{ int i,j;

for(i=0;i<a;i++)

{ for(j=0;j<20000;j++);

18
EC6711 EMBEDDED LABORATORY USER MANUAL

Write Code for flashing led in C and SAVE as FLASHING LED.c

STEP 8:

Once the code is written it has to be added to the project to do that right click on source
group and select “ADD FILES TO SOURCE GROUP” option AND add FILES FLASHING
LED.c, lcd.c.

 Main files: FLASHING LED.c

Sub files: lcd.c, lcd.h

OR

19
EC6711 EMBEDDED LABORATORY USER MANUAL

METHOD 2: Using existing file from copied folder


Copy FLASHING LED.c file from

CD Embedded lab experiment code FLASHING LED code copy to FLASHING


LED folder

Now add FLASHING LED.c , lcd.c, to source group from FLASHING LED FOLDER

Copy flashing led .c and lcd.c from Embedded lab experiment code

20
EC6711 EMBEDDED LABORATORY USER MANUAL

Now our folder contains flashing led.c and lcd.c.

Add files to Source Group

21
EC6711 EMBEDDED LABORATORY USER MANUAL

now add lcd file to the source

22
EC6711 EMBEDDED LABORATORY USER MANUAL

23
EC6711 EMBEDDED LABORATORY USER MANUAL

Hex file and bin files are not created unless we follow particular steps.

Steps to be followed for creating hex file and bin files are mentioned below

REATING HEXFILE

The Intel hex (ihex) generally known as hex file, is a format used to store machine
language code in hexadecimal form. It is widely used format to store programs to be transferred
to microcontrollers, ROM and EEPROM. The compilers convert the programs written in
assembly, C etc into corresponding hex files, which are dumped into the controllers using
burners/programmers.

STEP 1:

Go to Options for Target „Target 1‟.

24
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 2:

Go to output Tab

25
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 3:

Click on Check Box “Create HEX File”.

26
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 4:

In TARGET TAB IROM1 enter as displayed

27
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 5:

Then Click on Rebuild All Target Files

Once the project is build result can be seen at the bottom. If any errors are present list of errors
will be displayed or if project has no errors build is said to be successful.

STEP 6:

Now you see 0 Error(s), 0 Warning (s). Then Hex File will create in Specific Folder. Now to
download it for you target hardware

28
EC6711 EMBEDDED LABORATORY USER MANUAL

CREATING BIN FILE


The BIN files contain binary code that is used by the different applications on your computer.

STEP 1:

Go to options tab

29
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 2:

In TARGET tab mention IROM1 as 0X2000 FOR BIN FILE

30
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 3:

In USER TAB, run command1 , give Project name ie Here FLASHING LED to axf file as
created in STEP1 (Page N0:12) Bin file name can vary i.e. need not to be same, Bin file will be
created in this name.

31
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 4:

IN ASM define NO_CRP which means user flash can be read or written

32
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 5:

Then Click on Rebuild All Target Files

33
EC6711 EMBEDDED LABORATORY USER MANUAL

BURNING HEXFILE IN TO THE CHIP


STEP 1:

Connect UART0 in the ARM kit to the system via serial cable.

34
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 2:

Go to programs and search for launch lpc 210x_isp.exe and click on it.

35
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 3:

LPC 2000 FLASH UTILITY WINDOW WILL OPEN

CLICK as shown below

36
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 4:

Select the hex file created in step6 in hex file creation

37
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 5:

To check USB enumeration status Right Click on “My Computer” icon and select Manage.

38
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 6:

A “Computer Management” window opens. In this select Device Manager and select the port
as shown below:

39
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 7:

Note the port connected, here its connected to com2.

40
EC6711 EMBEDDED LABORATORY USER MANUAL

Step 8:

Select the Com port where you download hex file in to flash and select the baud rate.

41
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 9:

Now reset arm kit

Reset key can be identified in arm kit, let us assume another key as A

Keep A pressed, press & release RESET then release A

42
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 10:

Now click on read device button to detect the Target, If detected, the Part ID and Boot
loader ID will be displayed in their relative Textboxes And also a message will be displayed at
the bottom “Read Part ID Successfully”

43
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP11:

To program the flash select the file to be loaded in to flash, Once the hex file is loaded, click
on Upload to Flash button. Once clicked the programming starts. The programming progress is
indicated by the progress bar.

44
EC6711 EMBEDDED LABORATORY USER MANUAL

45
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 12:

Press and hold SW3, PRESS the RESET &release the RESET, then release SW3

46
EC6711 EMBEDDED LABORATORY USER MANUAL

OBSERVE LED, YOU SHOULD SEE THEM BLINKING

47
EC6711 EMBEDDED LABORATORY USER MANUAL

BURNING BIN FILE IN TO THE CHIP


STEP 1:

After connecting USB to the system switch on the kit by sliding the switch from off to on

48
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 2:

You will get a message as shown below

“USB Device Not Recognized”

49
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 3:

Connect the serial cable to computer.

Now we are going to run boot loader to make USB recognize

50
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 4:

BOOT LOADER

A Boot loader is a small piece of code that runs before the operating system starts running. In
our case the boot loader is the code that runs before the device firmware starts up. Typically a
boot loader is used because the system memory is too small to contain the entire program, and so
the boot loader uses a set of routines to call the program from a different part of memory.

USB Virtual COM Port Installation For Windows XP

The USB in Board might not get enumerated if it does not find the appropriate driver for it.
To check USB enumeration status Right Click on “My Computer” icon and select Manage.

51
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 5 :

A “Computer Management” window opens. In this select Device Manager and select the port
as shown below:

52
EC6711 EMBEDDED LABORATORY USER MANUAL

Note the port connected, here its connected to com2.

53
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 6:

Open Philips flash utility and select baud rate and set the com port to COM2, in Philips
software we can select com from 1 to 5 only

54
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 7:

Click on read device to check if ARM is connected properly or not

55
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 8:

Browse the file to upload the code and select upload to flash Button as shown

56
EC6711 EMBEDDED LABORATORY USER MANUAL

57
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 9:

Now if you switch ON the Arm board , folder opens as below

58
EC6711 EMBEDDED LABORATORY USER MANUAL

INTERFACING ARM KIT

STEP 10: ADDING BIN FILE

 Now connect the USB cable between the development board and PC and press reset on
the development board.

 Your PC should detect LPC2148 development board as a mass storage device. Let
windows install generic drivers for mass storage device class

 After successful installation of drivers a disk drive will be created in the My Computer as
shown in fig. below. As there is no user code loaded in to the microcontroller, the
bootloader firmware will enter directly in to bootloader mode. Once the user code is
loaded in to the microcontroller, pressing reset button will execute user code rather than
bootloader code and no disk drive will be created in My Computer

 Double click on this drive to view its contents. It will contain a single file labeled as
“Firmware.bin” which is the image of internal flash of the microcontroller

59
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 11: Deleting Firmware

To load the user application, delete the file “firmware.bin”.

60
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 12:

Now copy the “FLASHINGLED.bin” file that was created earlier using Keil to this drive using
drag and drop with mouse or copy and paste with keyboard..

61
EC6711 EMBEDDED LABORATORY USER MANUAL

On successful copying the file. Keep SW3 pressed and then press and release RESET button
then release SW3.

62
EC6711 EMBEDDED LABORATORY USER MANUAL

STEP 13:

Now Observe led, you should see them blinking

63
EC6711 EMBEDDED LABORATORY USER MANUAL

EXPERIMENT NO : 2 INTERFACING ADC AND DAC


ON-CHIP ADC

Basic clocking for the A/D converters is provided by the VPB clock. Supports maximum
clock of 4.5MHz . Each ADC is of 10 bit resolution, using Successive approximation conversion
technique.
SPECIFICATION
 ADC 8 bit Resolution Data.
 1 Ch 8 bit data.
 Data, Control signals are connected through Burg stick.
 350 MHz Analog Bandwidth.
 1 V p-p Analog Input Range.
 Internal 2.5 V Reference and
 T/H Low Power: 500 Mw
 5 V Single Supply Operation

ADC LPC2148 PIN DETAILS


AD0.2 PO.28

ON-CHIP DIGITAL-TO-ANALOG CONVERTER (DAC)

A digital-to-analog converter is a device for converting a digital (usually binary) code to an


analog signal (current, voltage or charges). Digital-to-Analog Converters are the interface
between the abstract digital world and the analog real life. Simple switches, a network of
resistors, current sources or capacitors may implement this conversion. A DAC inputs a binary
number and outputs an analog voltage or current signal.

SPECIFICATION

 8-Bit R2R DAC with an Output Buffer.


 High speed multiplying input slew rate: 8 mA/µs n
 Power supply voltage range: ±4.5V to ±18V n
 Low power consumption: 33 mW @ ±5V
 Relative accuracy: ±0.19% error maximum
 Full scale current match: ±1 LSB type.
 Fast settling time: 150 ns type.

64
EC6711 EMBEDDED LABORATORY USER MANUAL

DAC Pin Description

AOUT : ANALOG OUTPUT.


VREF : Voltage reference.
VDDA, VSSA : Analog power and ground.

Operation
Bits 19:18 of the PINSEL1 register, control whether the DAC is enabled and controlling the
state of pin P0.25/AD0.4/AOUT. When these bits are 10, the DAC is powered on and active.

The settling times noted in the description of the BIAS bit are valid for a capacitance load on
the AOUT pin not exceeding 100pF. A load impedance value greater than that value will cause
settling time longer than the specified time.

DAC OUTPUT LPC2148PORTLINES


AOUT P0.25

WORKING PROCEDURE

 Create new folder in the name of ADC_DAC and copy lcd.c, dac.c.,config.h,dac.h,lcd.h.

From CD Embedded lab experiment code

INTERFACING ADC AND DAC code copy the files for

lcd.c, dac.c.,config.h, dac.h, lcd.h

 Main files: ADC_DAC.c

Sub files: lcd.c, dac.c.,config.h,dac.h,lcd.h.

 Follow steps from STEP2 TO STEP6 under Screen Shot For Experimental
Demonstration

 We are going to add C file in two ways

Method 1: Creating a new c file for ADC_DAC.c

Follow step 7

65
EC6711 EMBEDDED LABORATORY USER MANUAL

 WRITE THE BELOW PROGRAM

#include <stdio.h> /* prototype declarations for I/O functions */

#include <LPC214x.H> /* LPC21xx definitions */

#include "lcd.h"

#include "dac.h"

char lcd_buf[30];

#define sw2 (IOPIN0 & (1<<15))

#define sw3 (IOPIN0 & (1<<30))

void ADC_Init(void);

unsigned int Read_ADC(void);

void Delay () {

unsigned int i,j;

for (i=0;i<50;i++)

for (j=0;j<500;j++); }

int main()

unsigned int adc_data;

int dac_data;

dac_data=1024/2;

lcd_init();

lcd_write_control(0x01); // Clear Display (Clear Display,Set DD RAM Address=0)

goto_cursor(0x00); // Set
Cursor Line-1

lcd_print(" RAANA ADC DEMO "); //


Display LCD Line-1

ADC_Init();

66
EC6711 EMBEDDED LABORATORY USER MANUAL

DacInit(); //Initialize the DAC

IODIR1|=0xFFFF0000; //Clear all the LEDs on board

IOPIN1&=~(0xFFFF0000);

Delay();

while(1)

adc_data = Read_ADC

sprintf(lcd_buf,"AD-%00004d DA-%00004d ",adc_data,dac_data);

goto_cursor(0x40);
// Set Cursor = Line-2

lcd_print(lcd_buf);

if ((sw2) == 0 )

IOCLR0 = 0x00000040;

else

dac_data++;

if(dac_data>1024)

dac_data=1024;

DacOut(dac_data);

if ((sw3) == 0 )

67
EC6711 EMBEDDED LABORATORY USER MANUAL

else

dac_data--;

if(dac_data<=1)

dac_data=1;

DacOut(dac_data);

void ADC_Init(void)

PINSEL1 |= 0x01000000; //Configure P0.28 as AD0.2

AD0CR = 0x00200F02;

/*

SEL = 0x02 as AD0.1 is Choosen

CLKDIV = 0x0F

CLKS and BURST = 0x0 means that 11 Intruction Cycles used,resulting in 10-Bit
Data

And Don't Start the Conversion Now

*/

unsigned int Read_ADC(void)

unsigned int adc_data;

68
EC6711 EMBEDDED LABORATORY USER MANUAL

AD0CR |= 0x01000000; //Start the ADC Conversion

//Delay(100000);

do

adc_data = AD0DR1;

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

//Wait untill the DONE bits Sets

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

//AD0CR &= 0xFE000000; //Stop the ADC Conversion

adc_data = adc_data>>6;

adc_data = adc_data & 0x3FF; //Clearing all other Bits

Return (adc_data);

Write the code for adc and save it as filename.c

 Once the code is written it has to be added to the project to do that right click on source
group and select “ADD FILES TO SOURCE GROUP” option .Now you add ADC_DAC.c
,but lcd.c, dac.c must be added from the ADC_DAC FOLDER
0R

Method 2: copy ADC_DAC.c file from CD Embedded lab experiment code

INTERFACING ADC AND DAC code to ADC_DAC folder

Now add ADC_DAC.c ,lcd.c, dac.c to source group from ADC_DAC FOLDER

 Now follow the steps under

Creating hex file

Creating bin file

Burning hex file in to chip

Burning bin file in to chip

69
EC6711 EMBEDDED LABORATORY USER MANUAL

EXPERIMENT NO : 3 INTERFACING LED AND PWM


LIGHT EMITTING DIODES

Light Emitting Diodes (LEDs) are the most commonly used components, usually for
displaying pin‟s digital states.

INTERFACING LED TO LPC2148

POINT LEDs LPC2148 PIN +


DETAILS
DIGITAL
LED2 P0.0
OUTPUTS
LED3 P0.1
LED4 P0.2
LED5 P0.3
LED6 P0.4
LED7 P0.5
LED8 P0.6
LED9 P0.7

SCHEMATIC DIAGRAM FOR LEDS

SCHEMATIC DIAGRAM FOR LEDs

70
EC6711 EMBEDDED LABORATORY USER MANUAL

PWM (PULSE WIDTH MODULATION)

Pulse width modulation (PWM) is a powerful technique for controlling analog circuits with a
processor's digital outputs. PWM is employed in a wide variety of applications, ranging from
measurement and communications to power control and conversion.

PWMs LPC2148 lines


PWM2 P0.7
PWM3 P0.1
WORKING PROCEDURE

 Create new folder in the name of INTERFACING LED AND PWM and copy, lcd.c,lcd.h
From

CD Embedded lab experiment code INTERFACING LED AND PWM code

Main files- PWM.c, Sub files- lcd.c,lcd.h.

 Follow steps from STEP2 TO STEP6 under Screen Shot For Experimental Demonstration

 We are going to add c file in two ways

Method 1: creating a new c file for PWM.C

Write the below program in step 7

#include <LPC21xx.H>

#include "lcd.h"

#include <stdio.h>

#define sw2 (IOPIN0 & (1<<15))

#define sw3 (IOPIN0 & (1<<30))

char lcd_buff[16];

unsigned long duty, duty1;

unsigned long oldval = 0;

void delay(void);

void init_PWM (void);

void PWM0_isr(void) __irq {

71
EC6711 EMBEDDED LABORATORY USER MANUAL

PWMIR |= 0x00000001; // Clear match0 interrupt

VICVectAddr = 0x00000000;

unsigned int k;

int main(void)

PINSEL0 |= 0x00000000;

IODIR0 |= 0x000000FF;

init_PWM();

lcd_init();

lcd_write_control(0x01); // Clear Display (Clear Display,Set DD RAM Address=0)

goto_cursor(0x00); // Set Cursor Line-1

lcd_print(" RAANA PWM DEMO "); // Display LCD Line-1

duty = 50;

sprintf(lcd_buff, "W%c = %0003d", (int)0x25, duty);

goto_cursor(0x40); // Set Cursor = Line-2

lcd_print(lcd_buff);

duty1 = duty * 10.2;

PWMMR2 = duty1;

PWMLER = 0xF;

oldval = duty1;

while (1)

if ((sw2) == 0 )

72
EC6711 EMBEDDED LABORATORY USER MANUAL

IOCLR0 = 0x00000040;

else

duty++;

if (duty > 100)

duty = 100;

sprintf(lcd_buff, "W%c = %0003d", 0x25, duty);

goto_cursor(0x40);
// Set Cursor = Line-2

lcd_print(lcd_buff);

duty1 = duty * 10.2;

for (k = 0; k < 30000; k++);

PWMMR2 = duty1;

PWMLER = 0xF;

oldval = duty1;

IOSET0 = 0x00000040;

if ((sw3) == 0)

IOCLR0 = 0x00000020;

else

duty--;

73
EC6711 EMBEDDED LABORATORY USER MANUAL

if (duty <= 1)

duty = 1;

sprintf(lcd_buff, "W%c = %0003d",0x25, duty);

goto_cursor(0x40);
// Set Cursor = Line-2

lcd_print(lcd_buff);

duty1 = duty * 10.2;

for (k = 0; k < 30000; k++);

PWMMR2 = duty1;

PWMLER = 0xF;

oldval = duty1;

IOSET0 = 0x00000020;

void delay(void) // delay loop

int i;

for (i = 0; i < 3000000; i++)

void init_PWM (void) {

VICVectAddr8 = (unsigned)PWM0_isr; //PWM ISR vec.addr

VICVectCntl8 = 0x00000028; // Set channel

74
EC6711 EMBEDDED LABORATORY USER MANUAL

VICIntEnable = 0x00000100; // Enable the interrupt

PINSEL0 |= 0x00008008; // Enable P0.7&P0.1-PWM

PWMPR = 0x00000000; // Load prescaler

PWMPCR = 0x00000C0C; /* PWM channel 2 & 3 double edge control */

PWMMCR = 0x00000003; // reset the counter

PWMMR0 = 0x400; // set dutycycle is sixteen ticks

PWMMR1 = 0; // rising edge of PWM2– 100 tricks

PWMMR2 = 0x200; // falling edge of PWM2- 200 ticks

PWMMR3 = 0x100; // rising edge of PWM2– 100 tricks

PWMLER = 0xF; // shadow latch for match 1 – 3

PWMTCR = 0x00000002; // Reset counter and prescaler

PWMTCR = 0x00000009; // release counter from reset

Write the program for pwm and save it as pwm.c

Once the code is written it has to be added to the project to do that right click on source
group and select “ADD FILES TO SOURCE GROUP” option .Now you add pwm.c but
,lcd.c must be copied from INTERFACING LED AND PWM.

OR

METHOD 2: copy PWM.C FROM CD Embedded lab experiment code


INTERFACING LED AND PWM code TO INTERFACING LED AND
PWM folder

Add pwm.c & lcd.c to source group from INTERFACING LED AND PWM folder

 Now follow the steps under

Creating hex file

Creating bin file

Burning hex file in to chip

Burning bin file in to chip


75
EC6711 EMBEDDED LABORATORY USER MANUAL

EXPERIMENT NO : 4 INTERFACING REAL TIME CLOCK AND


SERIAL PORT
REAL TIME CLOCK

A real-time clock (RTC) is a computer clock (most often in the form of an integrated circuit)
that keeps track of the current time. On the LPC2148, the RTC is clocked by 32.768 KHz
oscillator, or by a programmable prescale divider based on the VPB clock. Also, the RTC is
powered by its own power supply pin, VBAT, which can be connected to a battery or to the same
3.3 V supply used by the rest of the device.

 Inbuilt RTC Backup Battery Connector On Board.


 Ultra-Low Power Design to Support Battery Powered Systems.
 RTC With Programmable Reference Clock Divider.
 RTC Dedicated To 32 KHz Oscillator Input.

WORKING PROCEDURE
 Create new folder in the name of INTERFACING REALTIME CLOCK AND SERIAL
PORT and copy lcd.c,serial.c,main.c,Retarget.c, ,lcd.h,serial.h from

CD Embedded lab experiment code INTERFACING REALTIME CLOCK AND


SERIAL PORT code

 Main files- RTC_SERIAL.c,


Sub files- lcd.c,serial.c,main.c,Retarget.c,RTC_SERIAL.c

 Follow steps from STEP2 TO STEP7 under Screen Shot For Experimental Demonstration
 We are going to add c file in two ways

METHOD 1:creating a new c file for RTC_SERIAL.c

Write below program in step 7


#include <stdio.h> /* prototype declarations for I/O functions */
#include <LPC214x.H> /* LPC21xx definitions */
#include "Serial.h"
#include "lcd.h"

76
EC6711 EMBEDDED LABORATORY USER MANUAL

#define MASKSEC 0x3F


// Second 00..59 00000000:00000000:00xxxxxx
#define MASKMIN 0x3F00
// Minute 00..59 00000000:00xxxxxx:00000000
#define MASKHR 0x1F0000
// Hour 00..23 000xxxxx:00000000:00000000
char uart1_buf[];
unsigned char flag = 1;
void RTC_Init(void);
/**
************************************************************************
**

****1111
Function Name : delay()

Description :This function suspends the tasks for specified ticks.

Input : ticks:no of ticks in multiple of 1 usec


task: task to be suspended

Output : void

Note :
************************************************************************
*******
*/
__irq void RTC_ISR(void)
{
flag = 1;
ILR = 0x01; //Clear the RTC Interrupt Flag
VICVectAddr = 0x00;
}
/***************************************/
void delay(int count)
{
int j=0,i=0;

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

77
EC6711 EMBEDDED LABORATORY USER MANUAL

/* At 60Mhz, the below loop introduces


delay of 10 us */
for(i=0;i<35;i++);
}
}

/****************/
/* main program */
/****************/
int pcclk_cali;
int main (void) { /* execution starts here */
unsigned char Hour,Minute,Second,Last_Second; // RTC Buffer
Data
lcd_init();
lcd_write_control(0x01); // Clear
Display (Clear Display,Set DD RAM Address=0)
goto_cursor(0x00); // Set
Cursor Line-1
lcd_print(" RAANA RTC DEMO "); //
Display LCD Line-1
uart1_init(); // Initialize UART1
// Initial Internal RTC Function
// Initial RTC Function

HOUR = 7;//0x07;
MIN = 33;//0x03;
SEC = 0;//0x03;
RTC_Init();
// CCR = 0x00000002;
// CIIR = 0x00000000;
// AMR = 0x000000FF;
// ILR = 0x00000003;
// CCR = 0x00000011;

Last_Second = 0x00;

while (1) { /* An embedded program does not stop */

78
EC6711 EMBEDDED LABORATORY USER MANUAL

do
// Repeat Get Second until Second Change
{
Hour = (CTIME0 & MASKHR)>>16;
// Read Hour
Minute = (CTIME0 & MASKMIN)>>8;
// Read Minute
Second = CTIME0 & MASKSEC;
// Read Second

}
while(Last_Second == Second); //
Repeat if Second Not Change

Last_Second = Second;
// Update Current Second

sprintf(uart1_buf,"\rRAANA RTC DEMO = ");


uart1_puts(uart1_buf);
sprintf(uart1_buf," %002d : %002d : %002d",Hour,Minute,Second);
uart1_puts(uart1_buf);
uart1_puts("\n");
goto_cursor(0x40);
// Set Cursor = Line-2
lcd_print(uart1_buf);

}
}
/**********Function Definition**********/
void RTC_Init(void)
{
// DOY = 23; //Enter Date
// MONTH = 50; //MONTH
// YEAR = 2013; //Year
HOUR =11; //Hour)
MIN = 15; //Min
SEC = 0; //Sec

79
EC6711 EMBEDDED LABORATORY USER MANUAL

PREINT = 0x392/2; //To Generate clock of 32.768KHz for RTC Module


PREFRAC = 0x4380/2; //when PCLK = 30MHz
/*
Formula For Calculation is as follow:-
PREINT = (int)(PCLK/32768)-1
PREFRAC = PCLK - ((PREINT+1)*32768
Example:-
if PCLK = 30MHz
PREINT = 914 = 0x392
PREFRAC = 17280 = 0x4380
*/
CIIR = 0x01; //Enables Second Counter Interrupt
CCR = 0x01; //Start RTC
}

SAVE THE ABOVE PROGRAM IN FILENAME.C


 Once the code is written it has to be added to the project to do that right click on source
group and select “ADD FILES TO SOURCE GROUP” option .Now you add serial.c. lcd.c
,main.c,retarget.c,RTC_SERIAL.c

OR
METHOD 2: COPY RTC_SERIAL.C FROM CD Embedded lab experiment code
INTERFACING REALTIME CLOCK AND SERIAL PORT code to
INTERFACING REALTIME CLOCK AND SERIAL PORT folder
Add RTC_SERIAL.C, serial.c. lcd.c ,main.c,retarget.c,RTC_SERIAL.c to source group
from INTERFACING REALTIME CLOCK AND SERIAL PORT folder

Now follow the steps under


Creating hex file
Creating bin file
Burning hex file in to chip
Burning bin file in to chip

80
EC6711 EMBEDDED LABORATORY USER MANUAL

EXPERIMENT NO : 5 INTERFACING KEYBOARD AND LCD


LCD 2x16 IN 4-BIT MODE

The ARM214X Kit, have 2x16 character LCD. 7 pins are required to create 4-bit interface; 4
data bits (P1.18 – P1.21, D4-D7), address bit (RS-P1.16), and control signal (E-P1.17). The LCD
controller is a standard KS0070B or equivalent, which is a very well-known interface for smaller
character based LCDs and also facility to adjust contrast through trim pot.
Figure below illustrate the LCD part of the design and which pins are used for the interface.
The LCD is powered from the 5V power supply

SPECIFICATION

Number Of Characters: 16 Characters X 2 Lines For Alpha Numeric Display.

 Lcd Type: Stn, Positive, Transflective, Yellow/Green.


 Duty Ratio: 1/16.
 View Direction: Wide Viewing Angle.
 Backlight Type: Yellow/Green Led.

LCD LPC2148 2X16 LCD SELECTION


MODULE PIN
DETAILS
RS P1.16
EN P1.17
D0-D3 NC
D4 P1.18
D5 P1.19
D6 P1.20
D7 P1.21

81
EC6711 EMBEDDED LABORATORY USER MANUAL

SCHEMATIC DIAGRAM FOR LCD


KEYPAD

Switch is the most widely used input device. When a switch is pressed either low or high
signal is given to controller depending upon the circuit designing. This approach requires one pin
for a single switch. With increasing requirement of input devices, more numbers of controller
pins are required which may not be available all the time. For example, to enter value from 0 to
15, we need 16 pins of controller to be interfaced with switches. To reduce number of required
pins, we can arrange keys in matrix form

82
EC6711 EMBEDDED LABORATORY USER MANUAL

SCHEMATIC DIAGRAM FOR KEYPAD

SPECIFICATION

 4 SW Point Board Can Be Used To Interface With Lpc 2148 Processor.


 Input Logic Data: High Or Low
 Input Switches With Four Terminal Burg Sticks.

SWITCHES LPC2148 PIN DETAILS


SW2 P0.15

SW3 P0.30

WORKING PROCEDURE

 Create new folder in the name of INTERFACING KEYBOARD AND LCD and copy
lcd.c&lcd.h from CD Embedded lab experiment code INTERFACING
KEYBOARD AND code

 MAIN FILE: KP_LCD.c

SUBFILE: lcd.c,lcd.h

 Follow steps from STEP2 TO STEP6 under Screen Shot For Experimental Demonstration

WE ARE GOING TO ADD CFILE IN TWO WAYS

83
EC6711 EMBEDDED LABORATORY USER MANUAL

 METHOD1:Creating a new c file FOR KP_LCD.c

Write the below code in step7

#include <LPC21xx.H>

#include "lcd.h"

#include <stdio.h>

#define sw2 (IOPIN0 & (1<<15))

#define sw3 (IOPIN0 & (1<<30))

char lcd_buff[16];

void delay(void);

unsigned int k;

int main(void)

PINSEL0 |= 0x00000000;

IODIR0 |= 0x000000FF;

lcd_init();

lcd_write_control(0x01); // Clear Display (Clear Display,Set DD RAM Address=0)

goto_cursor(0x00); // Set Cursor Line-1

lcd_print("ROHINI DEMO"); // Display LCD Line-1

while (1)

if ((sw2) == 0 )

IOCLR0 = 0x00000040;

goto_cursor(0x40);

lcd_print(" ");

84
EC6711 EMBEDDED LABORATORY USER MANUAL

else

IOSET0 = 0x00000040;

goto_cursor(0x40);

lcd_print("SW3 PRESSED");

if ((sw3) == 0)

IOCLR0 = 0x00000020;

goto_cursor(0x40);

lcd_print(" ");

else

IOSET0 = 0x00000020;

goto_cursor(0x40);

lcd_print("SW2 PRESSED");

void delay(void) // delay loop

int i;

for (i = 0; i < 3000000; i++)

85
EC6711 EMBEDDED LABORATORY USER MANUAL

Save the program in FILE NAME.C

 Once the code is written it has to be added to the project to do that right click on source
group and select “ADD FILES TO SOURCE GROUP” option .Now you add lcd.c &
KP_LCD.c

OR

 Method 2: COPY KP_LCD.C FROM CD Embedded lab experiment code


INTERFACING KEYBOARD AND LCD code TO INTERFACING KEYBOARD
AND LCD FOLDER

NOW ADD LCD.C AND KP_LCD.C TO SOURCE GROUP FROM INTERFACING


KEYBOARD AND LCD FOLDER

 Now follow the steps under

Creating hex file

Creating bin file

Burning hex file in to chip

Burning bin file in to chip

86
EC6711 EMBEDDED LABORATORY USER MANUAL

EXPERIMENT NO : 6 INTERFACING EEPROM AND INTERRUPT


SERIAL EEPROM
EEPROM (electrically erasable programmable read-only memory) is user-modifiable read-
only memory (ROM) that can be erased and reprogrammed (written to) repeatedly through the
application of higher than normal electrical voltage. It is a type of non-volatile memory used in
computers and other electronic devices to store small amounts of data that must be saved when
power is removed, e.g., calibration tables or device configuration.

Features of AT24Cxx:
Internally Organized 128 x 8 (1K), 256 x 8 (2K), 512 x 8 (4K)
2-wire Serial Interface
Bi-directional Data Transfer Protocol
100 kHz (1.8V, 2.5V, 2.7V) and 400 kHz (5V)
Compatibility Write Protect Pin for Hardware Data
Protection
byte Page (1K, 2K), 16-byte Page (4K, 8K, 16K) Write Modes
Data Retention: 100 Years.

I2C EEPROM LPC2148 PIN DETAILS


SCL P0.2
SDA P0.3

SCHEMATIC DIAGRAM

87
EC6711 EMBEDDED LABORATORY USER MANUAL

INTERRUPTS

An interrupt is a signal sent to the CPU which indicates that a system event has a occurred
which needs immediate attention
Interrupts in LPC214x are handled by Vectored Interrupt Controller (VIC) and are classified
into 3 types based on the priority levels.(Though Interrupts can classified in many different ways
as well)
1. Fast Interrupt Request i.e FIQ : which has highest priority
2. Vectored Interrupt Request i.e Vectored IRQ : which has „middle‟ or priority between
FIQ and Non-Vectored IRQ.
3. Non-Vectored IRQ : which has the lowest priority.

INTERRUPTS LPC2148 PIN DETAILS


INT2 P0.15

WORKING PROCEDURE

 Create new folder in the name of INTERFACING EEPROM AND INTERRUTS and
copy lcd.c, serial.c,lcd.h&serial.h.

FROM CD Embedded lab experiment code INTERFACING EEPROM AND


INTERRUTS code

MAIN FILE: EEP_INT.c

SUB FILE: , lcd.c, serial.c,lcd.h&serial.h

 Follow steps from STEP2 TO STEP7 under Screen Shot For Experimental Demonstration

 We are going to add c file in two ways

METHOD 1: creating a new c file for EEP_INT.c

Write the below code in step 7

#include <LPC214x.h>

#include <stdio.h>

88
EC6711 EMBEDDED LABORATORY USER MANUAL

#include <string.h>

#include"lcd.h"

#define MAX 18

#define AA 2

#define SI 3

#define STO 4

#define STA 5

#define I2EN 6

#define sw1 (IOPIN0 & (1<<14))

#define sw3 (IOPIN0 & (1<<30))

char c_rx_data[];

void I2C_ISR(void)__irq;

void Wait (unsigned int);

void I2C_Init (void);

int I2C_Start (unsigned int Slave_Addr);

int I2C_Write (unsigned char *Buff, unsigned int Count);

void Delay(void);

char ReLoad[MAX] = {0x00,0x00,'R','A','A','N','A',' ','E','E', 'P', ' ','T','S','T'};

char Buff[MAX] ={0x00,0x00,'R','A','A','N','A',' ','E','E', 'P', ' ','T','S','T'};

unsigned char Rec[MAX] = {"NO-DATA!"};

unsigned char index = 0;

unsigned char flag = 0, ii, Ready=0, Erase = 0;

char lcd_buff[50];

char uart1_buf[];

89
EC6711 EMBEDDED LABORATORY USER MANUAL

void read_eep();

void I2C_ISR(void)__irq

if (I2C0CONSET & 0x08)

switch (I2C0STAT)

case (0x08):

if (flag == 'W')

I2C0CONCLR = 1 << STO;

I2C0CONCLR = 1 << STA ;

I2C0DAT = 0xA0;

I2C0CONCLR = 1 << SI;

else if (flag == 'R')

I2C0DAT = 0xA0;

I2C_Start (0xA1);

I2C0CONCLR = 1 << SI;

index = 0;

break;

case (0x10):

90
EC6711 EMBEDDED LABORATORY USER MANUAL

I2C0CONCLR = 1 << STA;

if (flag == 'W')

I2C0DAT = 0xA0;

else if (flag == 'R')

I2C0CONCLR = 1 << STA;

I2C0CONCLR = 1 << STO;

I2C0DAT = 0xA1;

I2C0CONCLR = 1 << SI;

index = 0;

break;

case (0x18):

I2C0CONCLR = 0x20;

I2C0CONCLR = 0x38;

I2C0DAT = Buff[index];

index++;

break;

case (0x20):

I2C0CONCLR = 0x20;

I2C0CONCLR = 0x38;

I2C0DAT = Buff[index];

index++;

break;

case (0x28):

91
EC6711 EMBEDDED LABORATORY USER MANUAL

if (index < MAX)

if (flag == 'W')

I2C0DAT = Buff[index];

I2C0CONCLR = 0x20;

I2C0CONCLR = 0x38;

else if ((index > 1) && flag == 'R')

I2C0CONCLR = 0x18;

I2C0CONSET = 1 << STA;

else

I2C0DAT = Buff[index];

I2C0CONCLR = 0x20;

I2C0CONCLR = 0x38;

index++;

else

index = 0;

flag = 'R';

92
EC6711 EMBEDDED LABORATORY USER MANUAL

I2C0CONSET = 1 << STO;

if (Erase == 1)

Erase = 0;

else

I2C0CONCLR = 1 << STA;

I2C0CONCLR = 1 << SI;

break;

case (0x30):

I2C0CONCLR = 0x20;

if (index < MAX)

if (flag == 'W')

I2C0DAT = Buff[index];

index++;

else

index = 0;

93
EC6711 EMBEDDED LABORATORY USER MANUAL

flag = 0;

I2C0CONSET = 0x10;

I2C0CONCLR = 1 << SI;

break;

case (0x38):

I2C0CONSET = 0x20;

break;

case (0x40):

I2C0CONSET = 1 << AA;

I2C0CONCLR = 1 << STA;

I2C0CONCLR = 1 << STO;

I2C0CONCLR = 1 << SI;

break;

case (0x48):

I2C0CONSET = 1 << STA;

break;

case (0x50):

I2C0CONSET = 1 << AA;

if (index < MAX)

Rec [index] = I2C0DAT;

index++;

else

94
EC6711 EMBEDDED LABORATORY USER MANUAL

I2C0CONSET = 1 << STO;

I2C0CONCLR = 1 << SI;

index = 0;

Ready = 'T';

break;

case (0x58):

Rec [index] = I2C0DAT;

I2C0CONCLR = 1 << STA;

I2C0CONCLR = 1 << STO;

break;

I2C0CONCLR = 1 << SI;

VICVectAddr = 0x00;

char uart_rx;

unsigned char rx_true;

int main()

unsigned int i;

//VPBDIV = 0x02;

PINSEL0 = 0x00000050; //P0.2-SCLK0 & P0.3-SDA0

PINSEL2 &= 0xFFFFFFF3;

95
EC6711 EMBEDDED LABORATORY USER MANUAL

IODIR0 = 0x000000FF;

IO1DIR |= 0xFF << 16;

lcd_init();

uart1_init();

sprintf(uart1_buf,"\r RAANA EEP_INT DEMO ");

uart1_puts(uart1_buf);

lcd_write_control(0x01); // Clear
Display (Clear Display,Set DD RAM Address=0)

goto_cursor(0x00); // Set
Cursor Line-1

lcd_print(" RAANA EEP_INT "); //


Display LCD Line-1

/* Init VIC for I2C0 */

VICIntSelect =(0<< 9); // Setting all interrupts as IRQ(Vectored)

VICVectCntl0 = 0x20 | 9; // Assigning Highest Priority Slot to I2C0 and enabling this
slot

VICVectAddr0 = (unsigned long)I2C_ISR; // Storing vector address of I2C0

VICIntEnable = (1<<9);

I2C_Init();

ii = 0;

read_eep();

while(1)

uart_rx = uart1_getkey();

if(uart_rx == '+')

Buff [0]=Buff [1]=0x00;


96
EC6711 EMBEDDED LABORATORY USER MANUAL

rx_true=1;

ii=2;

while( rx_true)

uart_rx = uart1_getkey();

if(uart_rx == 0x0d)

uart1_putc(0x0A);

rx_true=0;

else

uart1_putc(uart_rx);

if(ii < MAX-2)

Buff [ii]=uart_rx;

ii++;

while(ii<MAX)

Buff [ii]=' ';

ii++;

97
EC6711 EMBEDDED LABORATORY USER MANUAL

IOSET0 = 0x00000040;

IOCLR1 = 0xFF << 16;

IOSET1 = 1 << 16;

Wait (5000);

sprintf(uart1_buf,"\r WRITING EEPROM ");

uart1_puts(uart1_buf);

flag = 'W';

I2C_Start (0x70);

for (i=0;i<30;i++) Wait(10000);

I2C0CONCLR = 1 << SI;

Wait (5000);Wait (5000);

Wait (5000);Wait (5000);

Wait (5000);Wait (5000);

Wait (5000);Wait (5000);

Wait (5000);Wait (5000);

Delay();

sprintf(uart1_buf,"\r WRITING FINISHED ");

uart1_puts(uart1_buf);

Delay();

Delay();

Delay();

sprintf(uart1_buf,"\r READING EEPROM ");

98
EC6711 EMBEDDED LABORATORY USER MANUAL

uart1_puts(uart1_buf);

read_eep();

sprintf(uart1_buf,"\r READING FINISHED ");

uart1_puts(uart1_buf);

else if(uart_rx == '-')

sprintf(uart1_buf,"\r ERASIG EEPROM ");

uart1_puts(uart1_buf);

Buff [0]=Buff [1]=0x00;

ii=2;

while(ii<MAX)

Buff [ii]=' ';

ii++;

IOSET0 = 0x00000040;

IOCLR1 = 0xFF << 16;

IOSET1 = 1 << 16;

Wait (5000);

flag = 'W';

I2C_Start (0x70);

for (i=0;i<30;i++) Wait(10000);

I2C0CONCLR = 1 << SI;

Wait (5000);Wait (5000);

99
EC6711 EMBEDDED LABORATORY USER MANUAL

Wait (5000);Wait (5000);

Wait (5000);Wait (5000);

Wait (5000);Wait (5000);

Wait (5000);Wait (5000);

Delay();

sprintf(uart1_buf,"\r ERASIG FINISH ");

uart1_puts(uart1_buf);

Delay();

sprintf(uart1_buf,"\r READING EEPROM ");

uart1_puts(uart1_buf);

read_eep();

sprintf(uart1_buf,"\r READING FINISHED ");

uart1_puts(uart1_buf);

void Delay(void)

unsigned int i,j;

for(i=0;i<150;i++)

for(j=0;j<900;j++);

100
EC6711 EMBEDDED LABORATORY USER MANUAL

void Wait (unsigned int Delay)

while(Delay--);

void I2C_Init (void)

I2C0SCLH = 150; //50%duty,I2CFreq->100KHz,PCLK=30MHz

I2C0SCLL = 150;

I2C0CONSET = 1 << I2EN; //Enable I2C 1

int I2C_Start (unsigned int Slave_Addr)

I2C0CONCLR = 1 << STO;

I2C0CONSET = 1 << AA;

I2C0CONSET = 1 << STA;

return 0;

int I2C_Write (unsigned char *Buff, unsigned int Count)

while(Count--)

I2C0DAT = *Buff++;

return 0;

101
EC6711 EMBEDDED LABORATORY USER MANUAL

void read_eep()

unsigned int i;

goto_cursor(0x40);
// Set Cursor = Line-2

IO1CLR = 0xFF << 16;

IOCLR1 = 0xFF << 16;

IOSET1 = 1 << 17;

flag = 'R';

I2C_Start (0x70);

for (i=0;i<30;i++) Wait(10000);

I2C0CONCLR = 1 << SI;

while (Ready == 'F');

if (Ready == 'T')

ii=0;

while (ii<MAX)

Wait (1000);

sprintf(lcd_buff,"%c",Rec[ii]);

lcd_print(lcd_buff);

Wait (1000);

Wait (1000);

Wait (1000);

102
EC6711 EMBEDDED LABORATORY USER MANUAL

ii++;

Wait (1000);

Ready = 'F';

Wait (5000);Wait (5000);Wait (5000);Wait (5000);

WRITE THE PROGRAM AND SAVE IT AS FILENAME .C

 Once the code is written it has to be added to the project to do that right click on source
group and select “ADD FILES TO SOURCE GROUP” option Now you add
EEP_INT.c,lcd.c,serial.c

OR

 METHOD 2 : COPY EEP_INT.C FROM CD Embedded lab experiment code


INTERFACING EEPROM AND INTERRUTS code TO FOLDER

NOW ADD EEP_INT.c,lcd.c,serial.c to source group from INTERFACING EEPROM AND


INTERRUTS FOLDER

Now follow the steps under

Creating hex file

Creating bin file

Burning hex file in to chip

Burning bin file in to chip

103
EC6711 EMBEDDED LABORATORY USER MANUAL

EXPERIMENT NO : 7 MAILBOX
Mailbox was a freeware email management application for iOS and Android, developed by
Orchestra, Inc. It drew the attention of numerous technology blogs for its usability and
innovative features, such as swipe-based email sorting, snoozing and filtering.[1][2] Weeks before
its launch, a pre-registration period resulted in a waiting list of over 380,000
reservations.[3][4] Upon its iOS launch on February 7, 2013, Mailbox became the second-most-
downloaded free app in the App Store that day.[5]

In March 2013, Orchestra was acquired by Drop box.[6][7][8] The rollout of Mailbox was sped
up and the pre-registration period ended in April.[9] In April 2014, Drop box released Mailbox
for Android and announced a public beta version for OS X,[10][11] which was released in
August.[12]

In December 2015, Drop box announced the discontinuation of Mailbox, saying that they
were not able to "fundamentally fix email" with it and that they rather focus on "[streamlining]
the workflows that generate so much email".[13] It was ultimately discontinued on February 26,
2016, as announced earlier.

WORKING PROCEDURE
 Create new folder in the name of Mailbox and copy blinky.c,lcd.c,
,RTX_config.c &lcd.h FROM

CD Embedded lab experiment code MAIL BOX code

MAIN FILE: mailbox.c

SUB FILE: blinky.c,lcd.c, ,RTX_config.c &lcd.h

 Follow steps from STEP2 TO STEP7 under Screen Shot For Experimental
Demonstration

We are going to add c file in two ways

METHOD 1: creating a new c file for mailbox.c


Write the below code in step7

#include <RTL.h> /* RTX kernel functions & defines */

#include <LPC214x.H> /* LPC21xx definitions */

#include <stdio.h>
104
EC6711 EMBEDDED LABORATORY USER MANUAL

#include "lcd.h"

OS_TID tsk1; /* assigned identification for task 1 */

OS_TID tsk2; /* assigned identification for task 2 */

typedef struct { /* Message object structure */

U32 counter; /* A counter value */

} T_MEAS;

os_mbx_declare (MsgBox,16); /* Declare an RTX mailbox */

_declare_box (mpool,sizeof(T_MEAS),16);/* Dynamic memory pool */

__task void send_task (void);

__task void rec_task (void);

/*----------------------------------------------------------------------------

* Task 1: RTX Kernel starts this task with os_sys_init (send_task)

*---------------------------------------------------------------------------*/

__task void send_task (void) {

T_MEAS *mptr;

tsk1 = os_tsk_self (); /* get own task identification number */

tsk2 = os_tsk_create (rec_task, 0); /* start task 2 */

os_mbx_init (MsgBox, sizeof(MsgBox));/* initialize the mailbox */

os_dly_wait (5); /* Startup delay for MCB21xx */

105
EC6711 EMBEDDED LABORATORY USER MANUAL

for (;;) {

mptr = _alloc_box (mpool); /* Allocate a memory for the message */

mptr->counter = 1;

os_mbx_send (MsgBox, mptr, 0xffff); /* Send the message to the mailbox */

IOSET0 = 0x00000010;

IOCLR0 = 0x00000020;

IOCLR0 = 0x00000040;

os_dly_wait (300);

mptr = _alloc_box (mpool);

mptr->counter = 2;

os_mbx_send (MsgBox, mptr, 0xffff); /* And send it. */

os_tsk_pass (); /* Cooperative multitasking */

IOSET0 = 0x00000020;

IOCLR0 = 0x00000010;

IOCLR0 = 0x00000040;

os_dly_wait (300);

mptr = _alloc_box (mpool);

mptr->counter = 3;

os_mbx_send (MsgBox, mptr, 0xffff); /* And send it. */

IOSET0 = 0x00000040;

IOCLR0 = 0x00000010;

IOCLR0 = 0x00000020;

os_dly_wait (300);

106
EC6711 EMBEDDED LABORATORY USER MANUAL

// os_tsk_delete_self (); /* We are done here, delete this task */

__task void rec_task (void) {

T_MEAS *rptr;

for (;;) {

os_mbx_wait (MsgBox, (void **)&rptr, 0xffff); /* wait for the message */

IOSET0 = 0x00000080;

goto_cursor(0x40);
// Set Cursor Line-1

lcd_print(" RECI. MAILBOX ");

os_dly_wait (50);

IOCLR0 = 0x00000080;

goto_cursor(0x40);
// Set Cursor = Line-2

lcd_print(" WAITING FOR MB "); //


Display LCD Line-1

_free_box (mpool, rptr); /* free memory allocated for message */

int main (void) { /* program execution starts here */

IODIR0 = 0x000000FF;

lcd_init();

107
EC6711 EMBEDDED LABORATORY USER MANUAL

lcd_write_control(0x01); // Clear
Display (Clear Display,Set DD RAM Address=0)

goto_cursor(0x00); // Set
Cursor Line-1

lcd_print(" HELLO "); // Display LCD Line-


1

_init_box (mpool, sizeof(mpool), /* initialize the 'mpool' memory for */

sizeof(T_MEAS)); /* the membox dynamic allocation */

os_sys_init (send_task); /* initialize and start task 1 */

Once the code is written it has to be added to the project to do that right click on source
group and select “ADD FILES TO SOURCE GROUP” option .Now you add,mailbox.c,
blinky.c,lcd.c & ,RTX_config.c FROM MAILBOX FOLDER

Method 2: Copy mailbox.c FROM CD Embedded lab experiment code MAIL


BOX code TO MAILBOX FOLDER

NOW ADD mailbox.c,blinky.c,lcd.c & ,RTX_config.c TO SOURCE FILE FROM


MAILBOX FOLDER

Now follow the steps under

Creating hex file

Creating bin file

Burning hex file in to chip

Burning bin file in to chip

108
EC6711 EMBEDDED LABORATORY USER MANUAL

EXPERIMENT NO : 8 INTERRUPT PERFORMANCE CHARACTERISTICS OF ARM


AND FPGA

ARM

An ARM processor is one of a family of CPUs based on the RISC (reduced instruction set
computer) architecture developed by Advanced RISC Machines (ARM).ARM makes 32-bit
and 64-bit RISC multi-core processors. RISC processors are designed to perform a smaller
number of types of computer instructions so that they can operate at a higher speed, performing
more millions of instructions per second (MIPS). By stripping out unneeded instructions and
optimizing pathways, RISC processors provide outstanding performance at a fraction of the
power demand of CISC (complex instruction set computing) devices.ARM processors are
extensively used in consumer electronic devices such as smartphones, tablets, multimedia
players and other mobile devices, such as wearables. Because of their reduced instruction set,
they require fewer transistors, which enables a smaller die size for the integrated circuitry (IC).
The ARM processor‟s smaller size, reduced complexity and lower power consumption makes
them suitable for increasingly miniaturized devices.ARM processor features include:

 Load/store architecture.

 Anorthogonal instruction set.

 Mostly single-cycle execution.

 Enhanced power-saving design.

 64 and 32-bit execution states for scalable high performance.

 Hardware virtualization support.

The simplified design of ARM processors enables more efficient multi-core processing and
easier coding for developers. While they don't have the same raw compute throughput as the
products of x86 market leader Intel, ARM processors sometimes exceed the performance of Intel
processors for applications that exist on both architectures.The head-to-head competition
between the vendors is increasing as ARM is finding its way into full size notebooks. Microsoft,
for example, offers ARM-based versions of Surface computers. The cleaner code base
of Windows RT versus x86 versions may be also partially responsible -- Windows RT is more
streamlined because it doesn‟t have to support a number of legacy hardware.ARM is also
moving into the server market, a move that represents a large change in direction and a hedging
of bets on performance-per-watt over raw compute power. AMD offers 8-core versions of ARM
processors for its Opteron series of processors. ARM serversrepresent an important shift in
server-based computing. A traditional x86-class server with 12, 16, 24 or more cores increases
performance by scaling up the speed and sophistication of each processor, using brute force
speed and power to handle demanding computing workloads.In comparison, an ARM server uses

109
EC6711 EMBEDDED LABORATORY USER MANUAL

perhaps hundreds of smaller, less sophisticated, low-power processors that share processing tasks
among that large number instead of just a few higher-capacity processors. This approach is
sometimes referred to as “scaling out,” in contrast with the “scaling up” of x86-based
servers.The ARM architecture was originally developed by Acorn Computers in the 1980s.

Wave forms in performance charcteristics of ARM and FPGA

110
EC6711 EMBEDDED LABORATORY USER MANUAL

EXPERIMENT NO : 9 INTERFACING STEPPER MOTOR AND TEMPERATURE


SENSOR

STEPPER MOTOR

Stepper motors are DC motors that move in discrete steps.

SPECIFICATION
 7 Darlington Arrays in 16-Pin DIP Package part : ULN 2003
 Current & voltage rating of L293D: 500mA and up to 50V respectively.
 Four-Phase Motor Has A Step Angle Of 7.5 Degrees And Requires 12 Vdc
For Operation.

 Step Angle:- 1.8degrees for (200 steps per revolution)

SCHEMATIC DIAGRAM FOR STEPPER MOTOR

PINS IN L298N LPC2148 PIN DETAILS


IN1 P1.20
IN2 P1.19
IN3 P1.22
IN4 P1.21
EXT1 P1.24
EXT2 P1.23

111
EC6711 EMBEDDED LABORATORY USER MANUAL

TEMPERATURE SENSOR-LM35

The LM35 series are precision integrated-circuit temperature sensors, whose output voltage
is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage
over linear temperature sensors calibrated in ° Kelvin, as the user is not required to subtract a
large constant voltage from its output to obtain convenient Centigrade scaling.

The LM35 does not require any external calibration or trimming to provide typical accuracies
of ±¼°C at room temperature and ±¾°Cover a full -55 to +150°C temperature range. Low cost is
assured by trimming and calibration at the wafer level. It can be used with single power supplies,
or with plus and minus supplies. The LM35 is rated to operate over a -55° to +150°C
temperature range, while the LM35C is rated for a -40° to +110°C range (-10° with improved
accuracy).
SPECIFICATION
 Lm 35 Interfaced PCB Board Module With 3 Burg Pin Connectors.
 Sensitivity: 10mv Per Degree.
 Celsius Functional Range: -40 Degree Celsius To 150 Degree Celsius.
 Linear + 10.0 mv/˚C Scale Factor N 0.5˚C Accuracy.
 Operates From 4 To 30 Volts.
 Less Than 60 µa Current Drain.
 Low Self-Heating, 0.08˚C in Still Air.
 Nonlinearity Only ±1⁄4˚C Typical.
 Low Impedance Output, 0.1 Ω For 1 Ma Load.

ARM2148 Kit
In LPC2148, LM35 Temp sensor connected at P0.28 (AD0.1)

TEMPERATURE LPC2148 PIN DETAILS


SENSOR
Temp output P0.28

112
EC6711 EMBEDDED LABORATORY USER MANUAL

WORKING PROCEDURE

 Create new folder in the name of INTERFACING STEPPER MOTOR AND


TEMPERATURE SENSOR and copy files lcd.c,lcd.h from stepper motor folder

FROM CD Embedded lab experiment code stepper motor code

dac.c.lcd.c,config.h.dac.h&lcd.h from temperature sensor folder

FROM CD Embedded lab experiment code temperature sensor code

MAIN FILE:steppermot.c,temp.c

SUB FILES: lcd.c, ,lcd.h, dac.c.lcd.c ,config.h.dac.h&lcd.h

 Follow steps from STEP2 TO STEP7 under Screen Shot For Experimental Demonstration

 WE are going to add c file in two

METHOD 1:CREATING A NEW C FILE

Write the below programs

Program for stepper motor

#include <LPC21xx.H>

#include "lcd.h"

#include <stdio.h>

#define SHIFT 19 //change the Stepper Motor Port!

#define sw2 (IOPIN0 & (1<<14))

#define sw3 (IOPIN0 & (1<<30))

//unsigned char STEP[] = {0x09, 0x08, 0x0C, 0x04, 0x06, 0x02, 0x03, 0x01};

//d7 d6 d5 d4 = 0x09 0x06

//d7 d6 d5 d4 = 0x80 0x04

//d7 d6 d5 d4 = 0x0C 0x0C

113
EC6711 EMBEDDED LABORATORY USER MANUAL

//d7 d6 d5 d4 = 0x04 0x80

//d7 d6 d5 d4 = 0x06 0x09

//d7 d6 d5 d4 = 0x02 0x01

//d7 d6 d5 d4 = 0x03 0x03

//d7 d6 d5 d4 = 0x01 0x02

unsigned char STEP[] = {0x06, 0x04, 0x0C, 0x08, 0x09, 0x01, 0x03, 0x02};

char lcd_buff[16];

void delay(void);

void delay2(int n);

void motor_cw(void) ;

void motor_ccw(void);

unsigned int k;

int cw =1;

int main(void)

PINSEL0 = 0x000F8000;

IODIR0 = 0x000F8000;

PINSEL1 = 0x00F80000;

IODIR1 = 0x00F80000;

// PINSEL0 |= 0x00000000;

// 0-3 4-7 8-11 12-15 16-19 20-23 24-27 28-31

// IODIR0 |= 0x000000FF;

lcd_init();

114
EC6711 EMBEDDED LABORATORY USER MANUAL

lcd_write_control(0x01); // Clear
Display (Clear Display,Set DD RAM Address=0)

goto_cursor(0x00); // Set
Cursor Line-1

lcd_print("RAANA STEP.MOTOR"); //
Display LCD Line-1

goto_cursor(0x40);

lcd_print(" CW ");

while (1)

if ((sw2) == 0 )

else

goto_cursor(0x40);

lcd_print(" CCW ");

cw=0;

if ((sw3) == 0)

else

115
EC6711 EMBEDDED LABORATORY USER MANUAL

goto_cursor(0x40);

lcd_print(" CW ");

cw=1;

if(cw == 1)

motor_cw();

else

motor_ccw();

void delay(void) // delay loop

int i;

for (i = 0; i < 3000000; i++)

void delay2(int n)

int i,j;

for(i=0;i<n;i++)

for(j=0;j<0x3FF0;j++)

116
EC6711 EMBEDDED LABORATORY USER MANUAL

void motor_cw(void)

int i = 7;

while (i >= 0)

IOSET1 = STEP[i] << SHIFT;

delay2(10);

IOCLR1 = STEP[i] << SHIFT;

delay2(10);

i--; }}

void motor_ccw(void)

unsigned int i=0;

while (STEP[i] != '\0')

IOSET1 = STEP[i] << SHIFT;

delay2(10);

IOCLR1 = STEP[i] << SHIFT;

delay2(10);

i++; }

117
EC6711 EMBEDDED LABORATORY USER MANUAL

Program for temperature sensor

#include <stdio.h> /* prototype declarations for I/O functions */

#include <LPC214x.H> /* LPC21xx definitions */

#include "lcd.h"

//#include "dac.h"

char lcd_buf[30];

#define sw2 (IOPIN0 & (1<<15))

#define sw3 (IOPIN0 & (1<<30))

void ADC_Init(void);

int avg_count,avg_adc_data;

unsigned int Read_ADC(void);

void Delay () {

unsigned int i,j;

for (i=0;i<50;i++)

for (j=0;j<500;j++); }

int main()

unsigned int adc_data;

int dac_data;

dac_data=1024/2;

lcd_init();

lcd_write_control(0x01); // Clear
Display (Clear Display,Set DD RAM Address=0)

goto_cursor(0x00); // Set
Cursor Line-1

118
EC6711 EMBEDDED LABORATORY USER MANUAL

lcd_print(" RAANA TEMP.DEMO"); //


Display LCD Line-1

ADC_Init();

// DacInit(); //Initialize the DAC

IODIR1|=0xFFFF0000; //Clear all the LEDs on board

IOPIN1&=~(0xFFFF0000);

Delay();

avg_count=0;

while(1)

adc_data += Read_ADC();

avg_count++;

if(avg_count>10)

avg_count=0;

avg_adc_data= adc_data/10;

avg_adc_data *=.283;

sprintf(lcd_buf,"T > %0003d%c%c ",avg_adc_data,223,'C');

goto_cursor(0x40);
// Set Cursor = Line-2

lcd_print(lcd_buf);

adc_data=0;

119
EC6711 EMBEDDED LABORATORY USER MANUAL

if ((sw2) == 0 )

IOCLR0 = 0x00000040;

else

dac_data++;

if(dac_data>1024)

dac_data=1024;

// DacOut(dac_data);

if ((sw3) == 0 )

else

dac_data--;

if(dac_data<=1)

dac_data=1;

// DacOut(dac_data);

120
EC6711 EMBEDDED LABORATORY USER MANUAL

void ADC_Init(void)

PINSEL1 |= 0x01000000; //Configure P0.28 as AD0.2

AD0CR = 0x00200F02;

/*

SEL = 0x02 as AD0.1 is Choosen

CLKDIV = 0x0F

CLKS and BURST = 0x0 means that 11 Intruction Cycles used,resulting in 10-Bit
Data

And Don't Start the Conversion Now

*/

unsigned int Read_ADC(void)

unsigned int adc_data;

AD0CR |= 0x01000000; //Start the ADC Conversion

//Delay(100000);

do

adc_data = AD0DR1;

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

//Wait untill the DONE bits Sets

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

//AD0CR &= 0xFE000000; //Stop the ADC Conversion

121
EC6711 EMBEDDED LABORATORY USER MANUAL

adc_data = adc_data>>6;

adc_data = adc_data & 0x3FF; //Clearing all other Bits

return (adc_data);

SAVE THE PROGRAM IN FILE NAME.C

 Once the code is written it has to be added to the project to do that right click on source
group and select “ADD FILES TO SOURCE GROUP” option .Now you add
lcd.c,stepper_mot.c , dac.c.lcd.c&temp.c

OR

METHOD 2: copy stepper_mot.c from CD Embedded lab experiment code


steppermotor code

copy temp.c from CD Embedded lab experiment code temperature sensor


code to INTERFACING STEPPER MOTOR AND TEMPERATURE SENSOR folder

 now add lcd.c,stepper_mot.c , dac.c.lcd.c&temp.c to source group from INTERFACING


STEPPER MOTOR AND TEMPERATURE SENSOR folder

 Now follow the steps under

Creating hex file

Creating bin file

Burning hex file in to chip

Burning bin file in to chip

122
EC6711 EMBEDDED LABORATORY USER MANUAL

EXPERIMENT NO : 10 IMPLEMENTING ZIGBEE PROTOCOL WITH ARM

WORKING PROCEDURE

ZIGBEE

ZigBee is a wireless networking standard that is aimed at remote control and sensor
applications which is suitable for operation in harsh radio environments and in isolated locations.

SPECIFICATION

 Range Up To 20 Ft.
 Transmit Power Output 2mw (+3dbm),
 Boost Mode Enabled 1.25mw (+1dbm),
 Boost Mode Disabled 63mw (+18 Dbm) 10mw.
 Baud Rate 250,000 Bps 250,000 Bps Serial Interface.
 Receiver Sensitivity: -96 Dbm,
 Boost Mode Enabled: -95 Dbm, Boost Mode Disabled.
 RS232 3.3volts 232 Converter Based.
 Onboard Regulated Power Supply.

WORKING PROCEDURE

 Create new folder in the name of INTERFACING ZIGBEE PROTOCAL WITH ARM
and copy serial.c,rtc_serial.c,retarget.c,main.c,lcd.c,lcd.h&serial.h from

 CD Embedded lab experiment code INTERFACING ZIGBEE PROTOCAL


WITH ARM code

Main file: xbee.c

Sub file: serial.c,rtc_serial.c,retarget.c,main.c,lcd.c,lcd.h&serial.h

 Follow steps from STEP2 TO STEP7 under Screen Shot For Experimental Demonstration

 We are going to add c file in two ways

123
EC6711 EMBEDDED LABORATORY USER MANUAL

METHOD1: CREATING A NEW C FILE for xbee.c


Write the below program

#include <stdio.h> /* prototype declarations for I/O functions */

#include <LPC214x.H> /* LPC21xx definitions */

#include "Serial.h"

#include "lcd.h"

#define MASKSEC 0x3F


// Second 00..59 00000000:00000000:00xxxxxx

#define MASKMIN 0x3F00


// Minute 00..59 00000000:00xxxxxx:00000000

#define MASKHR 0x1F0000


// Hour 00..23 000xxxxx:00000000:00000000

char uart1_buf[];

/**

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

****1111

Function Name : delay()

Description :This function suspends the tasks for specified ticks.

Input : ticks:no of ticks in multiple of 1 usec

task: task to be suspended

124
EC6711 EMBEDDED LABORATORY USER MANUAL

Output : void

Note :

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

*/

void delay(int count)

int j=0,i=0;

for(j=0;j<count;j++)

/* At 60Mhz, the below loop introduces

delay of 10 us */

for(i=0;i<35;i++);

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

/* main program */

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

int main (void) { /* execution starts here */

lcd_init();

lcd_write_control(0x01); // Clear
Display (Clear Display,Set DD RAM Address=0)

goto_cursor(0x00); // Set
Cursor Line-1

lcd_print("RAANA SEMI DEMO"); //


Display LCD Line-1
125
EC6711 EMBEDDED LABORATORY USER MANUAL

uart1_init(); // Initialize UART1

while (1) { /* An embedded program does not stop */

sprintf(uart1_buf,"\ SKP XBEE DEMO \n");

uart1_puts(uart1_buf);

delay(30000);

delay(30000);

delay(30000);

Save the program in filename.c

 Once the code is written it has to be added to the project to do that right click on source
group and select “ADD FILES TO SOURCE GROUP” option .Now you add
xbee.c,serial.c,rtc_serial.c,retarget.c,main.c,lcd.c

Or

 METHOD2: copy xbee.c from CD Embedded lab experiment code


INTERFACING ZIGBEE PROTOCAL WITH ARM code to folder

Now add xbee.c,serial.c,rtc_serial.c,retarget.c,main.c,lcd.c to source group from


INTERFACING ZIGBEE PROTOCAL WITH ARM folder

 Now follow the steps under

Creating hex file

Creating bin file

Burning hex file in to chip

Burning bin file in to chip

126
EC6711 EMBEDDED LABORATORY USER MANUAL

FOR ANY QUERIES:

Contact :
Raana Semiconductors Pvt Ltd

No.5, Near Sai Baba Temple,

Opp Surya Hospital,

Tank Street,

Hosur - 635 109.

Mail ID: [email protected]

Contact: 8220355225.

127

You might also like