Sei sulla pagina 1di 43

CHANDY COLLEGE OF ENGINEERING

Mullakkadu
Department of Electronics & Communication Engineering

EC6711- Embedded Lab

Manual

Prepared by
A.Samsu Nighar
AP/ECE
Chandy College of Engineering
Ex.No.01 ARM EVALUATION SYSTEM

AIM:
To study about the ARM Evaluation System

ARCHITECTURE OF ARM PROCESSOR

ARM Architecture profiles

Application profile (ARMv7-A à e.g. Cortex-A8)


 Memory management support (MMU)
 Highest performance at low power
 Influenced by multi-tasking OS system requirements
 TrustZone and Jazelle-RCT for a safe, extensible system
Real-time profile (ARMv7-R à e.g. Cortex-R4)
 Protected memory (MPU)
 Low latency and predictability ‘real-time’ needs
 Evolutionary path for traditional embedded business
Microcontroller profile (ARMv7-M à e.g. Cortex-M3)
 Lowest gate count entry point
 Deterministic and predictable behavior a key priority
 Deeply embedded use
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 microprogrammed 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.
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.
LPC 2148

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 unique accelerator architecture enable 32-bit code execution at the maximum clock
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 upto 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.

ARM - LPC 2148 BLOCK DIAGRAM


LPC2148 PIN DIAGRAM

LPC 2148 FEATURES

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


• 8 to 40 kB of on-chip static RAM and 32 to 512 kB of on-chip flash program memory.
128 bit wide interface/accelerator enables high speed 60 MHz operation.
• In-System/In-Application Programming (ISP/IAP) via on-chip boot-loader software.
Single flash sector or full chip erase in 400 ms and programming of 256 bytes in 1 ms.
• EmbeddedICE RT and Embedded Trace interfaces offer real-time debugging with the
on-chip RealMonitor software and high speed tracing of instruction execution.
• USB 2.0 Full Speed compliant Device Controller with 2 kB of endpoint RAM.
• In addition, the LPC2146/8 provide 8 kB of on-chip RAM accessible to USB by DMA.
• One or two (LPC2141/2 vs LPC2144/6/8) 10-bit A/D converters provide a total of 6/14
analog inputs, with conversion times as low as 2.44 µs per channel.
• Single 10-bit D/A converter provides variable analog output.
• Two 32-bit timers/external event counters (with four capture and four compare channels
each), PWM unit (six outputs) and watchdog.
• Low power real-time clock with independent power and dedicated 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.
• Vectored interrupt controller with configurable priorities and vector addresses.
• Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package.
• Up to nine edge or level sensitive external interrupt pins available.
• 60 MHz maximum CPU clock available from programmable on-chip PLL with settling
time of 100 µs.
• On-chip integrated oscillator operates with an external crystal in range from 1 MHz to
30 MHz and with an external oscillator up to 50 MHz.
• Power saving modes include Idle and Power-down.
• Individual enable/disable of peripheral functions as well as peripheral clock scaling for
additional power optimization.
• Processor wake-up from Power-down mode via external interrupt, USB, Brown-Out
Detect (BOD) or Real-Time Clock (RTC).
• Single power supply chip with Power-On Reset (POR) and BOD circuits:
• CPU operating voltage range of 3.0 V to 3.6 V (3.3 V ± 10 %) with 5 V tolerant I/O
pads.

PROCEDURE

Step1: Open Keil µvision4 short cut in the desktop.


Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then implement and view the output by
keeping the ARM Kit in execute mode and also press the reset button.

RESULT:
Thus the Evaluation of ARM Processor was studied.
Ex.No.02 BLINKING LEDs

AIM:
To write an embedded ‘c’ program for LED interface with ARM Processor and to execute
it using ARM Processor Kit.

REQIREMENTS:
Software used: Keil software µvision-4, and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors and Adaptor.

PROCEDURE:
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then implement and view the output by
keeping the ARM Development Kit in execute mode and also press the reset button.

PROGRAM
#include<LPC214x.h> // Define LPC2148 Header File
#define led IO0PIN // Define LED to Port0
#define tled IO0DIR
void delay(int x);
int main()
{
PINSEL0 = 0x00000000;
tled = 0x00FF0000; // Define P0.16 – P0.23 as O/P
while(1) // Loop forever
{
led = 0x00AA0000; // Turn ON P0.16 – P0.23
delay(2000);
led = 0x00550000; // Turn OFF P0.16 – P0.23
delay(2000);
}
}
void delay(int x)
{
unsigned int k,l;
for(k = x;k > 0;k--)
for(l = 0;l < x;l++);
}

RESULT:

Thus the program was executed and the result was verified.
Ex.No.03 PULSE WIDTH MODULATION

AIM:
To write an embedded ‘c’ program for PWM interface with ARM Processor and to
execute it using ARM Processor Kit.

REQIREMENTS:
Software used: Keil software µvision-4, and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors and Adaptor.

ALGORITHM:
1. Include the LPC2148 header file.

PROCEDURE:
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then implement and view the output by
keeping the ARM Development Kit in execute mode and also press the reset button.
PROGRAM
#include <lpc214x.h>
void PWM_Init(unsigned int cycle)
{
PINSEL0 = 0x00000002; /* set GPIOs for all PWMs */
PWMTCR = 0x00000002; /* Counter Reset */
PWMPR = 0x00000000; /* count frequency:Fpclk */
PWMMR0 = cycle; /* set PWM cycle */
PWMLER = 0x0000007F; /* all PWM latch enabled */
}
/*****************************************************************************
*
** Function name: PWM_Set
**
** Descriptions: PWM cycle setup
*****************************************************************************/
void PWM_Set( unsigned long cycle, unsigned long offset )
{
PWMMR0 = cycle; /* set PWM cycle */
}
/*****************************************************************************
*** Function name: PWM_Start **** Descriptions: Enable PWM by
setting the PCR, PTCR registers
*****************************************************************************/
void PWM_Start( void )
{
PWMPCR = 0x00000200; /* Selects single edge controlled
mode for all PWM, The PWM1 output enabled.*/
PWMTCR = 0x09; /* counter enable, PWM enable */
}
/*****************************************************************************
********************
Main Routine
*****************************************************************************/
int main(void)
{
unsigned long cycle = 2000, Offset = 100;
PWM_Init(0); /* PWM Init */
PWM_Set(cycle,Offset); /* Set PWM : Cycle and offset*/
PWM_Start(); /* Start PWM genration */
while(1); /* Loop forever */
}
RESULT:
Thus the program was executed and the result was verified.
Ex.No.04 ANALOG TO DIGITAL CONVERTER

AIM:
To write an embedded ‘c’ program for ADC interface with ARM Processor and to execute
it using ARM Processor Kit.

REQIREMENTS:
Software used: Keil software µvision-4, and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors and Adaptor.

PROCEDURE:
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then implement and view the output in the
hyperterminal window (baud rate 9600) by keeping the ARM Development Kit in execute mode
and also press the reset button.

PROGRAM
#include <LPC214x.H> /* LPC214x definitions */
#include <stdio.h>

unsigned int ADC_Val;

char adcreading[16] ;
char Newline[]="\n\r\n";
void Delay(unsigned int Time)
{
unsigned int i,j;

for(i=0;i<=Time;i++)
for(j=0;j<110;j++);
}
/*****************************************************************************
******************
* UART0 Initialization *
******************************************************************************
******************/
void UART0_Init()
{
PINSEL0 = 0x05; /* Enable RxD0 and TxD0 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U0DLL = 0x86; /* 9600 Baud Rate @60MHz VPB Clock */
U0DLM = 0x01;
U0LCR = 0x03; /* DLAB = 0 */
VPBDIV = 0x01;
}
/*****************************************************************************
****************************
* ADC initialization
*
******************************************************************************
***************************/
void ADC_Init()
{
PINSEL1 = 0x01000000; /* channel AD0.1 (P0.28) */
AD0CR = 0x00230602; /* Setup A/D: 10-bit AIN0 @ 3MHz */
}

void U0Write(char data)


{
while (!(U0LSR & (1<<5))); // wait till the THR is empty
// now we can write to the Tx FIFO
U0THR = data;
}
void Send_String(char* StringPtr)
{
while(*StringPtr != 0x00)
{
U0Write(*StringPtr);
StringPtr++;
}
}
/*****************************************************************************
*************************
* Main
* Description : This function Initialize the UART0and ADC
******************************************************************************
************************/
int main (void) /* program exec. starts here */
{
UART0_Init(); /* Init UART 0 */
Delay(3000);
ADC_Init(); /* ADC Initialize */
while(1)
{
AD0CR |= 0x01000000; /* start of ADC conversion */
do
{
ADC_Val = AD0GDR; /* 10 bit value */
}
while ((ADC_Val & 0x80000000) == 0); /* Wait ADC Conversion Complete */
AD0CR &= ~0x01000000; /* Again start ADC */
ADC_Val = (ADC_Val >> 6) & 0x03FF;
sprintf(adcreading,"ADC Value= %u",ADC_Val);
Send_String(adcreading);
Send_String(Newline);
Delay(4000);
}
}

RESULT:

Thus the program was executed and the result was verified.
Ex.No.05 DIGITAL TO ANALOG CONVERTER

AIM:
To write an embedded ‘c’ program for DAC interface with ARM Processor and to execute
it using ARM Processor Kit.

REQIREMENTS:
Software used: Keil software µvision-4, and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors and Adaptor.

PROCEDURE:
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then implement and view the output by
keeping the ARM Development Kit in execute mode and also press the reset button.

PROGRAM
Square Wave Generation
#include<LPC214x.H>
void msdelay (unsigned long a) // DELAY ROUTINE
{
while(--a!=0);
}
int main(void)
{
unsigned int DAC_Val;
VPBDIV = 0x01;
PINSEL1 = 0x00080000; //ENABLE DAC PIN (P0.25)
while (1) /*START FIRST WHILE*/
{
DAC_Val = 0x03FF;
DAC_Val=DAC_Val<<6;
DACR=DAC_Val;
msdelay(100);

DAC_Val = 0x00;
DAC_Val=DAC_Val<<6;
DACR=DAC_Val;
msdelay(100);
}
}

Sawtooth Wave Generation

#include<LPC214x.H>
int main(void)
{
unsigned int DAC_Val,i;
VPBDIV = 0x01;
PINSEL1 = 0x00080000; //ENABLE DAC PIN (P0.25)
DAC_Val = 0x0;
while (1) /*START FIRST WHILE*/
{
for(i=0;i<=0x3ff;i++)
{
DAC_Val=i<<6;
DACR=DAC_Val;
}
}
}

RESULT:
Thus the program was executed and the result was verified.
Ex.No.06 LCD

AIM:
To write an embedded ‘c’ program for Liquid Crystal Display (LCD) interface with ARM
Processor and to execute it using ARM Processor Kit.

REQIREMENTS:
Software used: Keil software µvision-4, and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors and Adaptor.

PROCEDURE:
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then implement and view the output by
keeping the ARM Development Kit in execute mode and also press the reset button.

PROGRAM
#include<LPC214x.h>
#define lcd_data IO1PIN
#define EN 0x00000400
#define RW 0x00000200
#define RS 0x00000100
unsigned char arr1[16]=" IElec Systems ";
unsigned char arr2[16]=" Nellai.. ";
void delay_ms()
{
unsigned int i,j;
for(i=0;i<0xf;i++)
for(j=0;j<0xff;j++);
}
void busy_check()
{
delay_ms();
}
void lcd_cmd(unsigned char value)
{
busy_check();
IO0CLR=RS;
IO0CLR=RW;
lcd_data=(value<<16);
IO0SET=EN;
IO0CLR=EN;
return;
}
void lcd_dat(unsigned char item)
{
busy_check();
IO0SET=RS;
IO0CLR=RW;
lcd_data=(item<<16);
IO0SET=EN;
IO0CLR=EN;
return;
}
void lcd_data_string(unsigned char *str) // Program to send string to LCD
{
int i=0;
while(str[i]!='\0')
{
lcd_dat(str[i]);
i++;
delay_ms();
}
return;
}
void main()
{
IO0DIR=0x00000F00;
IO1DIR=0x00FF0000;
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000;
PINSEL2 = 0x00000000;
lcd_cmd(0x38);
lcd_cmd(0x0C);
lcd_cmd(0x01);
lcd_cmd(0x06);
lcd_cmd(0x80);
lcd_data_string(arr1);
lcd_cmd(0xc0);
lcd_data_string(arr2);
while(1);

RESULT:
Thus the program was executed and the result was verified.
Ex.No.07 4 x 4 MATRIX KEYPAD

AIM:
To write an embedded ‘c’ program for 4 x 4 Matrix Keypad interface with ARM
Processor and to execute it using ARM Processor Kit.

REQIREMENTS:
Software used: Keil software µvision-4, and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors and Adaptor.

PROCEDURE:
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then implement and view the output by
keeping the ARM Development Kit in execute mode and also press the reset button.

PROGRAM
#include <LPC214x.H> /* LPC214x definitions */
#include <stdio.h>
char Newline[]="\n\r";
char TAB[]="\t";
void Delay(unsigned int Time)
{
unsigned int i,j;
for(i=0;i<=Time;i++)
for(j=0;j<110;j++);
}

void UART0_Init()
{
PINSEL0 = 0x05; /* Enable RxD0 and TxD0 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U0DLL = 0x86; /* 9600 Baud Rate @60MHz VPB Clock */
U0DLM = 0x01;
U0LCR = 0x03; /* DLAB = 0 */
VPBDIV = 0x01;
}

void U0Write(char data)


{
while (!(U0LSR & (1<<5))); // wait till the THR is empty
// now we can write to the Tx FIFO
U0THR = data;
}

void Send_String(char* StringPtr)


{
while(*StringPtr != 0x00)
{
U0Write(*StringPtr);
StringPtr++;
}
}
/*****************************************************************************
*************************
* Main
* Description : This function Initialize the UART0and ADC
******************************************************************************
************************/
int main (void) /* program exec. starts here */
{
UART0_Init(); /* Init UART 0 */
PINSEL1 = 0x00000000;
IO0DIR = 0X00F00000; //P0.20 TO P0.23 (O/P)(COL 1 2 3 4)
//P0.16 TO P0.19(I/P)(ROW 1 2 3 4)
Send_String("4 x 4 Matrix Key Pad Interface");
Send_String(Newline);
Send_String("Press any Key");
Send_String(Newline);
while(1)
{
IO0PIN=0x00E00000; // First Scan Line

if(( IO0PIN & 0x000F0000 )!= 0x000F0000)


{
switch(IO0PIN & 0x000F0000)
{
case 0x00070000 : Send_String("0");Send_String(TAB);break;
case 0x000B0000 : Send_String("4");Send_String(TAB);break;
case 0x000D0000 : Send_String("8");Send_String(TAB);break;
case 0x000E0000 : Send_String("C");Send_String(TAB);break;
}
}

IO0PIN=0x00D00000; // Second Scan Line

if(( IO0PIN & 0x000F0000 )!= 0x000F0000)


{
switch(IO0PIN & 0x000F0000)
{
case 0x00070000 : Send_String("1");Send_String(TAB);break;
case 0x000B0000 : Send_String("5");Send_String(TAB);break;
case 0x000D0000 : Send_String("9");Send_String(TAB);break;
case 0x000E0000 : Send_String("D");Send_String(TAB);break;
}
}

IO0PIN=0x00B00000; // Third Scan Line

if(( IO0PIN & 0x000F0000 )!= 0x000F0000)


{
switch(IO0PIN & 0x000F0000)
{
case 0x00070000 : Send_String("2");Send_String(TAB);break;
case 0x000B0000 : Send_String("6");Send_String(TAB);break;
case 0x000D0000 : Send_String("A");Send_String(TAB);break;
case 0x000E0000 : Send_String("E");Send_String(TAB);break;
}
}

IO0PIN=0x00700000; // Fourth Scan Line


if(( IO0PIN & 0x000F0000 )!= 0x000F0000)
{
switch(IO0PIN & 0x000F0000)
{
case 0x00070000 : Send_String("3");Send_String(TAB);break;
case 0x000B0000 : Send_String("7");Send_String(TAB);break;
case 0x000D0000 : Send_String("B");Send_String(TAB);break;
case 0x000E0000 : Send_String("F");Send_String(TAB);break;
}
}

Delay(4000);
}
}

RESULT:
Thus the program was executed and the result was verified.
Ex.No.08 FLASHING OF LEDs

AIM:
To write an embedded ‘c’ program for Flashing of LEDs and to execute it using ARM
Processor Kit.

REQIREMENTS:
Software used: Keil software µvision-4, and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors and Adaptor.

PROCEDURE:
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then implement and view the output by
keeping the ARM Development Kit in execute mode and also press the reset button.

PROGRAM
#include<LPC214x.h> // Define LPC2148 Header File
#define led IO0PIN // Define LED to Port1
#define tled IO0DIR // Define Port1 as output
void delay(int x);
int main(void)
{
PINSEL1 = 0x00000000; //Define port lines as GPIO from P1.16 – P1.31 as zero
tled = 0x00FF0000; // Define P0.16 – P0.23 as O/P

while(1) // Loop forever


{
led = 0x00FF0000; // Turn ON P1.16 – P1.23
delay(2000);
led = 0x00000000; // Turn OFF P1.16 – P1.23
delay(2000);
}
}
void delay(int x)
{
unsigned int k,l;
for(k = x;k > 0;k--)
for(l = 0;l < x;l++);
}

RESULT:
Thus the program was executed and the result was verified.
Ex.No.09 STEPPER MOTOR

AIM:
To write an embedded ‘c’ program for Stepper Motor interface with ARM Processor and
to execute it using ARM Processor Kit.

REQIREMENTS:
Software used: Keil software µvision-4, and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors and Adaptor.

PROCEDURE:
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then implement and view the output by
keeping the ARM Development Kit in execute mode and also press the reset button.

PROGRAM
#include<LPC214x.h> // Define LPC2148 Header File
#define mot IO0PIN // Define mot to Port1
#define tmot IO0DIR
void delay(int x);
int main()
{
PINSEL0 = 0x00000000;
tmot = 0x000000F0; // Define P0.4 – P0.7 as O/P
while(1) // Loop forever
{
mot = 0x00000010; // Phase Scheme Clock-wise First Sequence.
delay(200); // Call Delay with data
mot = 0x00000020; // Phase Scheme Clock-wise Second Sequence.
delay(200);
mot = 0x00000040; // Phase Scheme Clock-wise Third Sequence.
delay(200);
mot = 0x00000080; // Phase Scheme Clock-wise Fourth Sequence.
delay(200);
}

}
void delay(int x)
{
unsigned int k,l;
for(k = x;k > 0;k--)
for(l = 0;l < x;l++);
}

RESULT:

Thus the program was executed and the result was verified.
Ex.No.10 TEMPERATURE SENSOR

AIM:
To write an embedded ‘c’ program for Temperature Sensor interface with ARM Processor
and to execute it using ARM Processor Kit.

REQIREMENTS:
Software used: Keil software µvision-4, and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors and Adaptor.

PROCEDURE:
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then implement and view the output by
keeping the ARM Development Kit in execute mode and also press the reset button.

PROGRAM
#include <LPC214x.H> /* LPC214x definitions */
#include <stdio.h>

unsigned int ADC_Val;

char adcreading[16] ;
char Newline[]="\n\r\n";
void Delay(unsigned int Time)
{
unsigned int i,j;

for(i=0;i<=Time;i++)
for(j=0;j<110;j++);
}
/*****************************************************************************
******************
* UART0 Initialization *
******************************************************************************
******************/
void UART0_Init()
{
PINSEL0 = 0x05; /* Enable RxD0 and TxD0 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U0DLL = 0x86; /* 9600 Baud Rate @60MHz VPB Clock */
U0DLM = 0x01;
U0LCR = 0x03; /* DLAB = 0 */
VPBDIV = 0x01;
}
/*****************************************************************************
****************************
* ADC initialization *
******************************************************************************
***************************/
void ADC_Init()
{
PINSEL1 = 0x01000000; /* channel AD0.1 (P0.28) */
AD0CR = 0x00230602; /* Setup A/D: 10-bit AIN0 @ 3MHz */
}

void U0Write(char data)


{
while (!(U0LSR & (1<<5))); // wait till the THR is empty
// now we can write to the Tx FIFO
U0THR = data;
}

void Send_String(char* StringPtr)


{
while(*StringPtr != 0x00){
U0Write(*StringPtr);
StringPtr++;}
}
/*****************************************************************************
*************************
* Main
* Description : This function Initialize the UART0and ADC
******************************************************************************
************************/
int main (void) /* program exec. starts here */
{
UART0_Init(); /* Init UART 0 */
Delay(3000);
ADC_Init(); /* ADC Initialize */
while(1)
{
AD0CR |= 0x01000000; /* start of ADC conversion */
do
{
ADC_Val = AD0GDR; /* 10 bit value */
}
while ((ADC_Val & 0x80000000) == 0); /* Wait ADC Conversion Complete */
AD0CR &= ~0x01000000; /* Again start ADC */
ADC_Val = (ADC_Val >> 6) & 0x03FF;
sprintf(adcreading,"Temperature Value= %f",ADC_Val*0.322);
Send_String(adcreading);
Send_String(Newline);
Delay(4000);
}
}

RESULT:

Thus the program was executed and the result was verified.
Ex.No.11 SERIAL PORT

AIM:
To write an embedded ‘c’ program for Serial Port and to execute it using ARM Processor
Kit.

REQIREMENTS:
Software used: Keil software µvision-4 and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors and Adaptor.

PROCEDURE:
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then implement and view the output in the
hyperterminal window (baud rate 9600) by keeping the ARM Development Kit in execute mode
and also press the reset button.

PROGRAM
#include <LPC214x.H> /* LPC214x definitions */
/*****************************************************************************
******************
* UART0 Initialization *
* Description : This function Initializes the UART0.
* Note : This function should be called once before any of the other functions of UART0.
******************************************************************************
*******************/
void UART0_Init()
{
PINSEL0 = 0x00000005; /* lower 4bit selected for UART0 and
remaining all bits selected for GPIO's.*/
/* frist LSB 2bit(0 and 1 bits) selected 01b for UART0 Tx.*/
/* LSB bit(2 and 3 bits) selected 01b for UART0 Rx.*/
U0LCR = 0x83; /* 0x83: enable Divisor Latch access, set 8-bit word
length,no Parity,1 Stop bit*/
VPBDIV = 0x01; /* VPBDIV: VPB bus clock divider 0x01: PCLK =
processor clock*/
/*-----------------------------------------------------------------------------------------------*/
// BAUD RATE CALCULATION
// DIVISOR = (PCLK/(16*DESIRED_BAUDRATE))
// For Example
// Peripheral Clock Frequency (PCLK) = 60 Mhz
// Desired Baud Rate = 9600 bps
// Divisor = (60000000/(16*9600)) = 390(Decimal) =186(Hex)
//-----------------------------------------------------------------------------------------------
U0DLL = 0x86;
U0DLM = 0x01;
U0LCR = 0x03; /* 0x03: same as above, but disable Divisor Latch access.*/
}

/*****************************************************************************
******************
* Send_Char
* Description : Write a character to Serial Port
******************************************************************************
*******************/
unsigned char Send_Char(unsigned char ch)
{
if (ch == '\n')
{
while(!(U0LSR & 0x20));
U0THR='\r'; /* output CR */
}
while(!(U0LSR & 0x20));
return (U0THR = ch);
}

void Send_String(unsigned char *ch)


{
while(*ch != '\0')
{
Send_Char(*ch++);
}
}

/*****************************************************************************
********************
* Main Routine
******************************************************************************
********************/
int main (void)
{
int i;
UART0_Init(); /* Init UART 0 */
while (1) /* Infinite Loop */
{
Send_String("Chandy College.,Tuty\n");
}
}

RESULT:
Thus the program was executed and the result was verified.
Ex.No.12 ZIGBEE PROTOCOL WITH ARM

AIM:
To write an embedded ‘c’ program for Implementing Zigbee protocol with ARM
processor.

REQUIREMENTS:
Software used: Keil software µvision-4 and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors, zigbee kits and
Adaptors.

PROCEDURE:
ARM
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file to the ARM Development Kit.
ZIGBEE:
Step1: Select the same pair of Zigbee kits (i.e.C1 and R1).
Step2: Connect the C1 with the ARM development kit and connect R1 with the PC via two
UART individually.
Step3: Power up the R1 kit with the adaptor.
Step4: Keep the C1 kit in kit mode and R1 kit in PC mode.
Step5: Change the mode of the ARM development kit to be in Execution mode
Step6: Open the hyper terminal window in PC and Restore the default settings.
Step7: Press the reset switch in the ARM development kit as well as in C1 and R1.
Step8: View the output in hyper terminal. Here the connection is wireless and the data is carried
only through the zigbee kits.

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

/*****************************************************************************
******************
* UART0 Initialization *
* Description : This function Initializes the UART0.
* Note : This function should be called once before any of the other functions of UART0.
******************************************************************************
*******************/
void UART0_Init()
{
PINSEL0 = 0x00000005; /* lower 4bit selected for UART0 and
remaining all bits selected for GPIO's.*/
/* frist LSB 2bit(0 and 1 bits) selected 01b for UART0 Tx.*/
/* LSB bit(2 and 3 bits) selected 01b for UART0 Rx.*/
U0LCR = 0x83; /* 0x83: enable Divisor Latch access, set 8-bit word
length,no Parity,1 Stop bit*/
VPBDIV = 0x01; /* VPBDIV: VPB bus clock divider 0x01: PCLK =
processor clock*/
/*-----------------------------------------------------------------------------------------------*/
// BAUD RATE CALCULATION
// DIVISOR = (PCLK/(16*DESIRED_BAUDRATE))
// For Example
// Peripheral Clock Frequency (PCLK) = 60 Mhz
// Desired Baud Rate = 9600 bps
// Divisor = (60000000/(16*9600)) = 390(Decimal) =186(Hex)
//-----------------------------------------------------------------------------------------------
U0DLL = 0x86;
U0DLM = 0x01;
U0LCR = 0x03; /* 0x03: same as above, but disable Divisor Latch access.*/
}

/*****************************************************************************
******************
* Send_Char
* Description : Write a character to Serial Port
******************************************************************************
*******************/
unsigned char Send_Char(unsigned char ch)
{
if (ch == '\n')
{
while(!(U0LSR & 0x20));
U0THR='\r'; /* output CR */
}
while(!(U0LSR & 0x20));

return (U0THR = ch);


}

void Send_String(unsigned char *ch)


{
while(*ch != '\0')
{
Send_Char(*ch++);
}
}

/*****************************************************************************
********************
* Main Routine
******************************************************************************
********************/
int main (void)
{
int i;
UART0_Init(); /* Init UART 0 */
while (1) /* Infinite Loop */
{
Send_String("Chandy College.,Tuty\n");
}
}

RESULT:
Thus the program was executed and the result was verified.
Ex.No.13 INTERRUPT

AIM:
To write an embedded ‘c’ program for interrupting the ARM Processor Externally.

REQUIREMENTS:
Software used: Keil software µvision-4 and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors and Adaptor.

PROCEDURE:
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then keep the ARM processor development kit
in execution mode.
Step 13: Interrupt the ARM processor externally through the external interrupt pin (pin 21 – port
0.1- EINT0).
Step14: Press the Reset switch in ARM development kit and view the output (LEDs will glow).
PROGRAM
#include <LPC214x.H>
__irq void ExtInt0_ISR (void)
{
//Clear the interrupt
EXTINT = 0x00000001;
IO1SET = 0x00FF0000; /* All LED Glow */
VICVectAddr = 0x00000000;
}

void InitExtInt0(void)
{
VICVectCntl0 = (1<<5) | 14;; /* use it for External Interrupt 0 */
VICIntEnable = (1<<14); /* Enable External Interrupt0 */
VICVectAddr0 = (unsigned long) ExtInt0_ISR; /* set interrupt vector in 0 */
}

int main(void)
{
PINSEL0 = 0x0000000C; /*Enable the EXTINT0 interrupt */
PINSEL2 = 0x00000000; /* Select pin for LED I/F */
IO1DIR = 0x00FF0000; /* Set direction for Pin P1.16 to Pin
P1.23 as output */

VPBDIV = 0x00000001;
InitExtInt0(); /* Init External Interrupt 0 */
while(1)
{
IO1CLR = 0x00FF0000; /* Clear All LED */
}
}

RESULT:
Thus the program was executed and the result was verified.
Ex.No.14 RTC

AIM:
To write an embedded ‘c’ program for Real Time Clock( RTC) interface with ARM
Processor and to execute it using ARM Processor Kit.

REQIREMENTS:
Software used: Keil software µvision-4, and Flash Magic.
Hardware used: ARM kit, Serial port cable, Burg connectors and Adaptor.

PROCEDURE:
Step1: Open Keil µvision4 short cut in the desktop.
Step2: Open project - > New project, save the project with no extension.
Step3: Click NXP then discloses ‘+’ symbol, then select LPC2148, then click ok.
Step4: Next it will ask for startup code click yes.
Step5: Now the project is created, in project window disclose ‘+’ of target1, the source group
will open.
Step6: Open a new file and save the file with extension ‘.c’.
Step7: Write the Keil c program and save the file.
Step8: Right click the source group, click the add files to the group ’source group ’, add the
saved ‘c’ file program.
Step9: Right click target1, click the option for target1, click output and click create hex file.
Step10: Right click target1, click the option rebuild all target files and check for the error in the
program.
Step10: Click flash magic short cut in desktop and set baud rate as 19200, and clock frequency as
12,00,000 MHZ.
Step11: Browse the corresponding hex file and keep the ARM processor kit in program mode
and press the reset button.
Step12: Download the corresponding hex file and then implement and view the output by
keeping the ARM Development Kit in execute mode and also press the reset button.

PROGRAM
#include <lpc214x.h>
unsigned char arr1[16]="REAL TIME CLOCK";
unsigned char h1,h2,m1,m2,s1,s2;
#define lcd_data IO1PIN
#define EN 0x00000400
#define RW 0x00000200
#define RS 0x00000100
void DelayMs(unsigned int ms);
void lcd_cmd(unsigned char value);
void lcd_dat(unsigned char item);
void lcd_data_string(unsigned char *str);
void init_rtc(void);

void rtc_int(void)__irq
{
ILR = 0x01;
// VICVectAddr = 0x00000000;
}
int main(void)
{
VPBDIV = 0x02;
DelayMs(1000);
IO0DIR=0x00000700;
IO1DIR=0x00FF0000;
lcd_cmd(0x38);
lcd_cmd(0x0C);
lcd_cmd(0x01);
lcd_cmd(0x06);
lcd_cmd(0x80);
lcd_data_string(arr1);
init_rtc();

while(1)
{
lcd_cmd(0xC4);
lcd_dat(HOUR/10 + '0');
lcd_dat(HOUR%10 + '0');
lcd_dat(':') ;
lcd_dat(MIN/10 + '0');
lcd_dat(MIN%10 + '0');
lcd_dat(':');
lcd_dat(SEC/10 + '0');
lcd_dat(SEC%10 + '0');
}
}
void DelayMs(unsigned int ms)
{
long i,j;
for (i = 0; i < ms; i++ )
for (j = 0; j < 6659; j++ );
}

void busy_check()
{
DelayMs(5);
}
void lcd_cmd(unsigned char value)
{
busy_check();
IO0CLR=RS;
IO0CLR=RW;
lcd_data=(value<<16);
IO0SET=EN;
IO0CLR=EN;
return;
}
void lcd_dat(unsigned char item)
{
busy_check();
IO0SET=RS;
IO0CLR=RW;
lcd_data=(item<<16);
IO0SET=EN;
IO0CLR=EN;
return;
}
void lcd_data_string(unsigned char *str) // Program to send string to LCD
{
int i=0;
while(str[i]!='\0')
{
lcd_dat(str[i]);
i++;
DelayMs(5);
}
return;
}

void init_rtc(void)
{
ILR = 0x01;
CCR = 0x13;
CCR = 0x11;
CIIR = 0x01;
SEC = 0x00;
MIN = 0x00;
HOUR = 0x00;

VICIntEnable |= (1<<13);
//RTC Interrupt 13(0x0D)
VICVectCntl0 = 0x0000002D;
//0x20+13=0x2D
VICVectAddr0 = (unsigned)rtc_int;
}
RESULT:
Thus the program was executed and the result was verified.

Potrebbero piacerti anche