Download as pdf or txt
Download as pdf or txt
You are on page 1of 62

EXP NO: 1 INTERFACING LED WITH ARM PROCESSOR

DATE:

AIM:

To write an embedded c program to interface LED with ARM processor

COMPONENTS REQUIRED:

Hardware:

ARM LPC1343

LED module

Software:

Coocox IDE

PROCEDURE:

Step 1: Go to start All programs  COIDE.

Step 2: Give a suitable file name for your project and give the destination folder and then next.

Step 3: Go to chip NXP LPC 13XX  LPC1343  Next

Step 4: Select the required library file (SYSCON and GPIO) from the repository.

Step 5: A new project will be created.

Step 6: Double click on main.c and type the program.

Step 7: Add the required library source file to the project (Right click on include Add file to group and

add the source file).

Step 8: Build the program using build option.

Step 9: Flash the program by clicking on download code to flash.

Step 10: Interface the required component and note down the output.

ADD FILES:

Repository :

Clibrary, CMSIS core , common header files, CMSIS boot, SYSCON, GPIO.

Source files:

No files to be added.

1
BLOCK DIAGRAM:

PROGRAM

A) FOR INFINITE LOOP:

#include "lpc13xx_syscon.h"

#include "lpc13xx_gpio.h"

void BlinkExp()

int i,j;

/* Enable GPIO block clock */

SYSCON_AHBPeriphClockCmd(SYSCON_AHBPeriph_GPIO, ENABLE);

/* If PIO2_0 had been set to other function, set it to PIO function. */

//IOCON_SetPinFunc(IOCON_PIO2_0, PIO2_0_FUN_PIO);

/*Set PIO2_0as output*/

GPIO SetDir(PORT0,GPIO_Pin_7,1)

//Sdcard lines

GPIO_SetDir(PORT0, GPIO_Pin_9, 1);

GPIO_SetDir(PORT0, GPIO_Pin_8, 1);

GPIO_SetDir(PORT2, GPIO_Pin_11, 1);

GPIO_SetDir(PORT0, GPIO_Pin_2, 1);

while(1)

/* Delay some time */

2
for(i=0; i<20; i++)

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

} }

/* Output high level */

GPIO_SetBits(PORT0, GPIO_Pin_7);

//Sdcard lines

GPIO_SetBits(PORT0, GPIO_Pin_8);

GPIO_SetBits(PORT0, GPIO_Pin_9);

GPIO_SetBits(PORT0, GPIO_Pin_2);

GPIO_SetBits(PORT2, GPIO_Pin_11);

/* Delay some time */

for(i=0; i<20; i++) {

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

/* Output low level */

GPIO_ResetBits(PORT0, GPIO_Pin_7);

//Sdcard lines

GPIO_ResetBits(PORT0, GPIO_Pin_8);

GPIO_ResetBits(PORT0, GPIO_Pin_9);

GPIO_ResetBits(PORT0, GPIO_Pin_2);

GPIO_ResetBits(PORT2, GPIO_Pin_11);

}}

int main(void)

BlinkExp();

3
B) FOR FINITE LOOP:

#include "lpc13xx_syscon.h"

#include "lpc13xx_gpio.h"

void BlinkExp()

int i,j,a=0;

/* Enable GPIO block clock */

SYSCON_AHBPeriphClockCmd(SYSCON_AHBPeriph_GPIO, ENABLE);

/* If PIO2_0 had been set to other function, set it to PIO function. */

//IOCON_SetPinFunc(IOCON_PIO2_0, PIO2_0_FUN_PIO);

/* Set PIO2_0 as output. */

GPIO_SetDir(PORT0, GPIO_Pin_7, 1);

//Sdcard lines

GPIO_SetDir(PORT0, GPIO_Pin_9, 1);

GPIO_SetDir(PORT0, GPIO_Pin_8, 1);

GPIO_SetDir(PORT2, GPIO_Pin_11, 1);

GPIO_SetDir(PORT0, GPIO_Pin_2, 1);

do

/* Delay some time */

for(i=0; i<20; i++) {

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

}}

/* Output high level */

GPIO_SetBits(PORT0, GPIO_Pin_7);

//Sdcard lines

GPIO_SetBits(PORT0, GPIO_Pin_8);

GPIO_SetBits(PORT0, GPIO_Pin_9);

GPIO_SetBits(PORT0, GPIO_Pin_2);

4
GPIO_SetBits(PORT2, GPIO_Pin_11);

/* Delay some time */

for(i=0; i<20; i++) {

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

/* Output low level */

GPIO_ResetBits(PORT0, GPIO_Pin_7);

//Sdcard lines

GPIO_ResetBits(PORT0, GPIO_Pin_8);

GPIO_ResetBits(PORT0, GPIO_Pin_9);

GPIO_ResetBits(PORT0, GPIO_Pin_2);

GPIO_ResetBits(PORT2, GPIO_Pin_11);

a++;

while(a<5);

int main(void)

BlinkExp();

5
RESULT:

Thus, an embedded c program to interface LED with ARM processor was executed and output
was verified successfully.

6
EXP NO:2 INTERFACING BUZZER WITH ARM PROCESSOR

DATE:

AIM:

To write an embedded c program to interface BUZZER with ARM processor

COMPONENTS REQUIRED:

Hardware:

ARM LPC1343

Buzzer

Software:

Coocox IDE

PROCEDURE:

Step 1: Go to start All programs  COIDE

Step 2: Give a suitable file name for your project and give the destination folder and then next

Step 3: Go to chip NXP LPC 13XX  LPC1343  Next

Step 4: Select the required library file (SYSCON and GPIO) from the repository

Step 5: A new project will be created

Step 6: Double click on main.c and type the program

Step 7: Add the required library source file to the project (Right click on include Add file to group and

add the source file)

Step 8: Build the program using build option

Step 9: Flash the program by clicking on download code to flash

Step 10: Interface the required component and note down the output

ADD FILES:

Repository:

Clibrary, CMSIS core, common header files, CMSIS boot, SYSCON ,GPIO.

Source files:

No files to be added.

7
BLOCK DIAGRAM:

PROGRAM:

#include "lpc13xx_syscon.h"
#include "lpc13xx_gpio.h"
#include "lpc13xx_syscon.h"
#include "lpc13xx_gpio.h"
voidBuzzerInit()
{
Int i, j;
SYSCON_AHBPeriphClockCmd(SYSCON_AHBPeriph_GPIO, ENABLE);
GPIO_SetDir(PORT1, GPIO_Pin_11, 1);
while(1) {
for(i=0; i<200; i++) {
for(j=0; j<10000; j++) {
}
}
GPIO_SetBits(PORT1, GPIO_Pin_11);
for(i=0; i<200; i++) {
for(j=0; j<10000; j++) {
}
}

GPIO_ResetBits(PORT1, GPIO_Pin_11);
}
}

8
int main(void)
{
BuzzerInit();

while(1)
{
}
}

9
RESULT:

Thus, an embedded c program was written to interface BUZZER with ARM processor and output
was verified successfully.

10
EXP NO: 3 INTERFACING LCD WITH ARM PROCESSOR

DATE:

AIM:

To write an embedded c program to interface LCD with ARM processor.

COMPONENTS REQUIRED:

Hardware:

ARM LPC1343

LCD module

Software:

Coocox IDE

PROCEDURE:

Step 1: Go to start All programs  COIDE.

Step 2: Give a suitable file name for your project and give the destination folder and then next.

Step 3: Go to chip NXP LPC 13XX  LPC1343  Next.

Step 4: Select the required library file (SYSCON and GPIO) from the repository.

Step 5: A new project will be created.

Step 6: Double click on main.c and type the program.

Step 7: Add the required library source file to the project (Right click on include Add file to group and
add the source file).

Step 8: Build the program using build option.

Step 9: Flash the program by clicking on download code to flash.

Step 10: Interface the required component and note down the output.

ADD FILES:

Repository:

CMSIS core, CMSIS boot, common header files, SYSCON, GPIO.

Source files:

lcd.h, lcd.c

11
BLOCK DIAGRAM:

PROGRAM:

#include"lcd.h"

int main(void)

init_lcd();

lcd_clear();

lcd_putstring(LINE1,"RAANA");

lcd_putstring(LINE2,"LCD DEMO");

while(1)

12
RESULT:

Thus, an embedded c program to interface LCD with ARM processor was executed and output
was verified successfully.

13
EXP NO: 4 INTERFACING ADC WITH ARM PROCESSOR

DATE:

AIM:

To write an embedded c program to interface ADC with ARM processor

COMPONENTS REQUIRED:

Hardware:

ARM LPC1343

ADC module

LCD module

Software:

Coocox IDE

PROCEDURE:

Step 1: Go to start All programs  COIDE

Step 2: Give a suitable file name for your project and give the destination folder and then next

Step 3: Go to chip NXP LPC 13XX  LPC1343  Next

Step 4: Select the required library file (SYSCON and GPIO) from the repository.

Step 5: A new project will be created.

Step 6: Double click on main.c and type the program

Step 7: Add the required library source file to the project (Right click on include Add file to group and

add the source file)

Step 8: Build the program using build option

Step 9: Flash the program by clicking on download code to flash

Step 10: Interface the required component and note down the output

ADD FILES:

Repository:

Clibrary , retarget printf, CMSIS core, CMSIS boot, common header files, SYSCON ,GPIO,
IOCON, UART,ADC , time.

14
Source files:

simple example.c, Uart Receiver interrupt.c, lcd.c, lcd.h

BLOCK DIAGRAM:

PROGRAM:

#include"lcd.h"
void ADCExp();
int main(void)
{
ReceiverInterrupt();
init_lcd();
lcd_putstring(LINE1, "RAANA ADC DEMO ");
ADCExp();
while(1)
{
}
}

15
RESULT:

Thus, an embedded c program to interface ADC with ARM processor was executed and output
was verified successfully.

16
EXP NO: 5 INTERFACING TEMPERATURE SENSOR WITH ARM PROCESSOR

DATE:

AIM:

To write an embedded c program to interface TEMPERATURE SENSOR with ARM processor

COMPONENTS REQUIRED:

Hardware:

ARM LPC1343

LM 35

LCD module

Software:

Coocox IDE

Docklight

PROCEDURE:

Step 1: Go to start All programs  COIDE

Step 2: Give a suitable file name for your project and give the destination folder and then next

Step 3: Go to chip NXP LPC 13XX  LPC1343  Next

Step 4: Select the required library file (SYSCON and GPIO) from the repository

Step 5: A new project will be created

Step 6: Double click on main.c and type the program

Step 7: Add the required library source file to the project (Right click on include Add file to group and
add the source file)

Step 8: Build the program using build option

Step 9: Flash the program by clicking on download code to flash

Step 10: Interface the required component and note down the output

For Docklight:

Step 1: Go to start Docklight Ok

Step 2: Start with the blank project /blank script continue

17
Step 3: Enable keyboard console by clicking on it

Step 4: Now flash (run) the program on COIDE, the output will be displayed on the serial window in the

Dockligh System window

ADD FILES:

Repository:

Clibrary , retarget printf, CMSIS core, CMSIS boot, common header files, SYSCON ,GPIO,
IOCON, UART,ADC , time.

Source files:

simple example.c, Uart Receiver interrupt.c, lcd.c, lcd.h

BLOCK DIAGRAM:

PROGRAM:

#include"lcd.h"

void ADCExp();

int main(void)

ReceiverInterrupt();

//automatically added by CoIDE

init_lcd();

18
lcd_putstring(0, "RAANA LM35 DEMO ");

ADCExp();

while(1)

19
RESULT:

Thus, an embedded c program to interface temperature sensor with ARM processor was executed
and output was verified successfully.

20
EXP NO: 6 INTERFACING KEYPAD WITH ARM PROCESSOR

DATE:

AIM:

To write an embedded c program to interface keypad with ARM processor

COMPONENTS REQUIRED:

Hardware:

ARM LPC1343

Keypad module

LCD module

Software:

Coocox IDE

PROCEDURE:

Step 1: Go to start All programs  COIDE

Step 2: Give a suitable file name for your project and give the destination folder and then next

Step 3: Go to chip NXP LPC 13XX  LPC1343  Next

Step 4: Select the required library file (SYSCON and GPIO) from the repository

Step 5: A new project will be created

Step 6: Double click on main.c and type the program

Step 7: Add the required library source file to the project (Right click on include Add file to group and
add the source file)

Step 8: Build the program using build option

Step 9: Flash the program by clicking on download code to flash

Step 10: Interface the required component and note down the output

ADD FILES:

Repository:

Clibrary , retarget printf, CMSIS core, CMSIS boot, common header files, SYSCON ,GPIO,
IOCON, UART, VART.

Source files:

lcd.h, lcd.c, Uart receiver interrupt.c.

21
BLOCK DIAGRAM:

PROGRAM:

#include "lcd.h"

#include "lpc13xx_syscon.h"

#include "lpc13xx_gpio.h"

void ReceiverInterrupt();

int i,j;

extern int iRx;

void delay1()

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

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

}}

int main(void)

SYSCON_AHBPeriphClockCmd(SYSCON_AHBPeriph_GPIO, ENABLE);

22
GPIO_SetDir(PORT2, GPIO_Pin_0, 0);

GPIO_SetDir(PORT2, GPIO_Pin_1, 0);

init_lcd(); // Initialize LCD

lcd_putstring(LINE1,"RAANA KP DEMO");

ReceiverInterrupt();

while(1)

if (GPIO_ReadInputPin(PORT2,GPIO_Pin_0) == 0)

UART_Send(LPC_UART, "KEY P2.0 PRESSED \r\n",20, BLOCKING);

iRx = 0;

lcd_putstring(LINE2,"KP-P2.0");

else if (GPIO_ReadInputPin(PORT2,GPIO_Pin_1) == 0)

UART_Send(LPC_UART, "KEY P2.1 PRESSED \r\n",20, BLOCKING);

iRx = 0;

lcd_putstring(LINE2,"KP-P2.1");

else

lcd_putstring(LINE2,"KP-OPEN");

23
RESULT:

Thus, an embedded c program to interface KEYPAD with ARM processor was executed and
output was verified successfully.

24
EXP NO: 7 INTERFACING KEYBOARD WITH ARM PROCESSOR

DATE:

AIM:

To write an embedded c program to interface KEYBOARD with ARM processor

COMPONENTS REQUIRED:

Hardware:

ARM LPC1343

PS2 Keyboard

Software:

Coocox IDE

PROCEDURE:

Step 1: Go to start All programs  COIDE

Step 2: Give a suitable file name for your project and give the destination folder and then next

Step 3: Go to chip NXP LPC 13XX  LPC1343  Next

Step 4: Select the required library file (SYSCON and GPIO) from the repository

Step 5: A new project will be created

Step 6: Double click on main.c and type the program

Step 7: Add the required library source file to the project (Right click on include Add file to group and
add the source file)

Step 8: Build the program using build option

Step 9: Flash the program by clicking on download code to flash

Step 10: Interface the required component and note down the output

ADD FILES:

Repository:

CMSIS core, CMSIS boot, common header file, SYSCON, GPIO, IOCON, UART, SSP.

Source files:

lcd.c, lcd.h, ps2kb.c , ps2kbd.h ,gpio.c, scancodes.h, type.h

25
BLOCK DIAGRAM:

PROGRAM:

#include "LPC13xx.h"

#include "ps2kbd.h"

#include "gpio.h"

#include "lcd.h"

int main(void) {

init_lcd();

init_keyboard();

lcd_putstring(LINE1, "RAANA");

lcd_putstring(LINE2, "PS2 KEY BOARD");

keyboard();

while (1)

if(keyhit())

process_keyboard();

26
}

return 0 ;

27
RESULT:

Thus, an embedded c program to interface keyboard with ARM processor was executed and
output was verified successfully.

28
EXP.NO: 8 INTERFACING RTC AND SERIAL PORT WITH ARM PROCESSOR

DATE:

AIM:

To write an embedded c program to interface RTC AND SERIAL PORT with ARM processor
LPC1768.

COMPONENTS REQUIRED:

HARDWARE:

ARM LPC1343

LCD

SOFTWARE:

Coocox IDE

PROCEDURE:

Step 1: Go to start All programs  COIDE

Step 2: Give a suitable file name for your project and give the destination folder and then next

Step 3: Go to chip NXP LPC 13XX  LPC1343  Next

Step 4: Select the required library file (SYSCON and GPIO) from the repository

Step 5: A new project will be created

Step 6: Double click on main.c and type the program

Step 7: Add the required library source file to the project (Right click on include Add file to group and
add the source file)

Step 8: Build the program using build option

Step 9: Flash the program by clicking on download code to flash

Step 10: Interface the required component and note down the output.

ADD FILES:

Repository:

CMSIS core, CMSIS boot, common header files, SYSCON, GPIO, IOCON, UART.

29
Source files:

lcd.h, lcd.c, uart Receiver interrupt.c

BLOCK DIAGRAM:

PROGRAM:

#include "lpc13xx_gpio.h"
#include "i2c.h"
#include "lcd.h"
#include "stdio.h"
#include "lpc13xx_syscon.h"
#include "lpc13xx_gpio.h"
#include "lpc13xx_uart.h"

unsigned char i2c_test_buf[]="RAANA POWER";

unsigned char data_cpy[20];

extern int iRx;


extern uint8_t RxData[];

30
void wait(int count)
{
int j=0,i=0;

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

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

void test_i2c_at24c256_flash(void)
{
unsigned char i=0;
unsigned char status=1;
for(i=0;i<sizeof(i2c_test_buf);i++)
i2c_test_buf[i] = 0;

lcd_clear();
lcd_putstring(LINE1,i2c_test_buf);
for(i=0;i<sizeof(i2c_test_buf);i++)
{

if(i2c_test_buf[i] != i)
{

status = 0;
break;
}
}

if(status == 1)
{
lcd_putstring(LINE2,"I2C-WR SUCSESS ");
}
else
{
lcd_putstring(LINE2,"I2C-WR FAIL ");

}
}

char buff[20];
char buff1[20];
unsigned char old_sec;
DATETIMEINFO time;

31
int i_data_count;
int i_delay_count;
int main (void)
{
ReceiverInterrupt();
init_lcd(); // Initialize LCD
lcd_putstring(LINE1,"RAANA RTC DEMO ");
i2c_lpc_init(I2C_SPEED_100); // Initialize I2C
Transmit_UART();
//wait(1000);
// lcd_clear();

time.year=16;
time.month=6;
time.day=4;
time.hour=13;
time.minute=54;
time.second=00;
ds1307_set(&time);
// test_i2c_at24c256_flash(); // Test I2C EEPROM by wrinting some data at some address and
reading the same from same address

while(1)
{
ds1307_get(&time);
wait(10000);
while(old_sec == time.second )
{
ds1307_get(&time);
wait(10000);
}

//if(old_sec != time.second )
{

sprintf(buff,"%002d:%002d:%002d", time.hour,time.minute,time.second );
lcd_putstring(LINE2,buff);

sprintf(buff1,"%002d:%002d:%002d\r\n", time.hour,time.minute,time.second );

UART_Send(LPC_UART,buff1,15, BLOCKING);
old_sec = time.second;
}
wait(10000);
}

32
/*
while(1)
{
ds1307_get(&time);
if(old_sec != time.second )
{
old_sec = time.second;
sprintf(buff,"%002d:%002d:%002d\r\n", time.hour,time.minute,time.second );
lcd_putstring(LINE2,buff);
UART_Send(LPC_UART,buff,10, BLOCKING);
}
if (iRx)
{

i_data_count=0;
i_delay_count=30000;
while(i_delay_count>0)
i_delay_count--;

if(RxData[0] == 'S')
{

UART_Send(LPC_UART, " WRITE TIME \r\n",16, BLOCKING);


iRx = 0;
for(int it=0;it<=16;it++)
data_cpy[it]='\0';
while(RxData[i_data_count+1] != 0x0a)
{
data_cpy[i_data_count]=RxData[i_data_count+1];
i_data_count++;
if(i_data_count>16)
break;
}
time.hour = ((data_cpy[0]+30)*10)+ (data_cpy[1]+30);
ds1307_set(&time);
// lcd_putstring(LINE2,data_cpy);
// UART_Send(LPC_UART, data_cpy,16, BLOCKING);
// iRx = 0;

iRx=0;

33
}
*/
}

RESULT:

Thus, an embedded c program to interface RTC and Serial Port with ARM processor was
executed and output was verified successfully.

34
EXP.NO: 9 INTERFACING LED AND PWM WITH ARM PROCESSOR

DATE:

AIM:

To write an embedded c program to interface LED AND PWM with ARM processor LPC1768

COMPONENTS REQUIRED:

HARDWARE:

ARM LPC1768

LED

DSO

SOFTWARE:

KEIL

PROCEDURE:

 Open the Keil software and select the New uvision project from Project Menu as shown below.

 Browse to your project folder and provide the project name and click on save.

 Once the project is saved a new pop up “Select Device for Target” opens, Select the
controller (NXP: LPC1768) from NXP (founded by philips) and click on OK.

 Select the controller (NXP: LPC1768) and click on OK.

 As LPC1768 needs the startup code, click on Yes option to include the LPC17xx Startup file.

 Create a new file by file → new to write the program.

 Type the code.

 After typing the code save the file as main.c eg. (abc.c).

 Right click target and Add the suitable files to source group1 and header for the project.

 Add the main.c along with system_LPC17xx.c.

 Build the project and fix the compiler errors/warnings if any.

 Code is compiled with no errors. The .bin file is still not generated.

 Right Click on Target Options to select the option for generating .bin file.

 Set IROM1 start address as 0x2000. Bootloader will be stored from 0x0000-0x2000 so

35
application should start from 0x2000

 Write the command to generate the .bin file from .axf file
Command: fromelf --bin projectname.axf --output filename.bin

 in c/c++ → include paths → desktop (00-libfiles).

 .Bin file is generated after a rebuild.

 Check the project folder for the generated .Bin file.

ADD FILES:

Target1:

Source group1:

Startuplpc17xx.s, delay.c (t), gpio.c (t), pwm.c (t), sysytemlpc17xx.c (t), main.c (t)

Header:

delay.h, gpio.h, pwm.h, stdulils.h

36
PROGRAM:

#include <lpc17xx.h>

#include "pwm.h"

#include "delay.h"

#define CYCLE_TIME 255 /* start the main program */

int main()

int dutyCycle;

SystemInit(); /* Clock and PLL configuration */

PWM_Init(CYCLE_TIME);

/* Initialize the PWM module and the Cycle time(Ton+Toff) is set to 255(similar to arduino)*/

PWM_Start(PWM_2|PWM_3|PWM_4|PWM_5);

/* Enable PWM output on PWM_1-PWM_4 (P2_0 - P2_3) */

while(1)

for(dutyCycle=0;dutyCycle<CYCLE_TIME;dutyCycle++) /* Increase the Brightness of the Leds */

PWM_SetDutyCycle(PWM_2,dutyCycle); //P2_1

PWM_SetDutyCycle(PWM_3,dutyCycle); //P2_2

PWM_SetDutyCycle(PWM_4,dutyCycle); //P2_3

PWM_SetDutyCycle(PWM_5,dutyCycle); //P2_4

DELAY_ms(500);

for(dutyCycle=CYCLE_TIME;dutyCycle>0;dutyCycle--) /* Decrease the Brightness of the Leds */

PWM_SetDutyCycle(PWM_1,dutyCycle); //P2_0

37
PWM_SetDutyCycle(PWM_2,dutyCycle); //P2_1

PWM_SetDutyCycle(PWM_3,dutyCycle); //P2_2

PWM_SetDutyCycle(PWM_4,dutyCycle); //P2_3

DELAY_ms(500);

} } }

38
RESULT:

Thus interfacing LED AND PWM with ARM processor LPC1768 is verified.

39
EXP.NO: 10 INTERRUPT CHARACTERISTICS PERFORMANCE OF ARM PROCESSOR

DATE:

AIM:

To write an embedded c program to interrupt the performance characteristics of ARM processor


LPC1768

COMPONENTS REQUIRED:

HARDWARE:

ARM LPC1768

LED

DSO

SOFTWARE:

KEIL

PROCEDURE:

 Open the Keil software and select the New uvision project from Project Menu as shown below.

 Browse to your project folder and provide the project name and click on save.

 Once the project is saved a new pop up “Select Device for Target” opens, Select the
controller (NXP: LPC1768) from NXP (founded by philips) and click on OK.

 Select the controller (NXP: LPC1768) and click on OK.

 As LPC1768 needs the startup code, click on Yes option to include the LPC17xx Startup file.

 Create a new file by file → new to write the program.

 Type the code.

 After typing the code save the file as main.c eg. (abc.c).

 Right click target and Add the suitable files to source group1 and header for the project.

 Add the main.c along with system_LPC17xx.c.

 Build the project and fix the compiler errors/warnings if any.

 Code is compiled with no errors. The .bin file is still not generated.

 Right Click on Target Options to select the option for generating .bin file.

40
 Set IROM1 start address as 0x2000. Bootloader will be stored from 0x0000-0x2000 so
application should start from 0x2000

 Write the command to generate the .bin file from .axf file
Command: fromelf --bin projectname.axf --output filename.bin

 in c/c++ → include paths → desktop (00-libfiles).

 .Bin file is generated after a rebuild.

 Check the project folder for the generated .Bin file.

ADD FILES:

Target1:

Source group1:

Startuplpc17xx.s, main.c (t), systemlpc17xx.c (t)

BLOCK DIAGRAM:

PROGRAM:

#include <lpc17xx.h>

#define PINSEL_EINT0 20

#define PINSEL_EINT1 22

#define LED1 0

#define LED2 1

41
#define SBIT_EINT0 0

#define SBIT_EINT1 1

#define SBIT_EXTMODE0 0

#define SBIT_EXTMODE1 1

#define SBIT_EXTPOLAR0 0

#define SBIT_EXTPOLAR1 1

void EINT0_IRQHandler(void)

LPC_SC->EXTINT = (1<<SBIT_EINT0); /* Clear Interrupt Flag */

LPC_GPIO1->FIOPIN ^= (1<< LED1); /* Toggle the LED1 everytime INTR0 is generated */

void EINT1_IRQHandler(void)

LPC_SC->EXTINT = (1<<SBIT_EINT1); /* Clear Interrupt Flag */

LPC_GPIO1->FIOPIN ^= (1<< LED2); /* Toggle the LED2 everytime INTR1 is generated */

int main()

SystemInit();

LPC_SC->EXTINT = (1<<SBIT_EINT0) | (1<<SBIT_EINT1); /* Clear Pending interrupts */

LPC_PINCON->PINSEL4 = (1<<PINSEL_EINT0) | (1<<PINSEL_EINT1);

/* Configure P2_10,P2_11 as EINT0/1 */

LPC_SC->EXTMODE = (1<<SBIT_EXTMODE0) | (1<<SBIT_EXTMODE1);

/* Configure EINTx as Edge Triggered*/

LPC_SC->EXTPOLAR = (1<<SBIT_EXTPOLAR0)| (1<<SBIT_EXTPOLAR0);

/* Configure EINTx as Falling Edge */

42
LPC_GPIO1->FIODIR = (1<<LED1) | (1<<LED2); /* Configure LED pins as OUTPUT */

LPC_GPIO1->FIOPIN = 0x00;

NVIC_EnableIRQ(EINT0_IRQn); /* Enable the EINT0,EINT1 interrupts */

NVIC_EnableIRQ(EINT1_IRQn);

while(1)

// Do nothing

43
RESULT:

Thus interrupt characteristics performance of ARM processor LPC1768 is verified.

44
EXP.NO: 11 INTERFACING STEPPER MOTOR WITH ARM PROCESSOR

DATE:

AIM:

To write an embedded c program to interface STEPPER MOTOR with ARM processor LPC1768.

COMPONENTS REQUIRED:

HARDWARE:

ARM LPC1768

STEPPER MOTOR

SOFTWARE:

KEIL

PROCEDURE:

 Open the Keil software and select the New uvision project from Project Menu as shown below.

 Browse to your project folder and provide the project name and click on save.

 Once the project is saved a new pop up “Select Device for Target” opens, Select the
controller (NXP: LPC1768) from NXP (founded by philips) and click on OK.

 Select the controller (NXP: LPC1768) and click on OK.

 As LPC1768 needs the startup code, click on Yes option to include the LPC17xx Startup file.

 Create a new file by file → new to write the program.

 Type the code.

 After typing the code save the file as main.c eg. (abc.c).

 Right click target and Add the suitable files to source group1 and header for the project.

 Add the main.c along with system_LPC17xx.c.

 Build the project and fix the compiler errors/warnings if any.

 Code is compiled with no errors. The .bin file is still not generated.

 Right Click on Target Options to select the option for generating .bin file.

 Set IROM1 start address as 0x2000. Bootloader will be stored from 0x0000-0x2000 so
application should start from 0x2000

45
 Write the command to generate the .bin file from .axf file
Command: fromelf --bin projectname.axf --output filename.bin

 in c/c++ → include paths → desktop (00-libfiles).

 .Bin file is generated after a rebuild.

 Check the project folder for the generated .Bin file.

ADD FILES:

Target1:

Source group1:

Startuplpc17xx.s, main.c (t), delay.c (t), systemlpc17xx.c (t), gpio.c (t)

Header:

Delay.h, stdutils.h, gpioi.h

BLOCK DIAGRAM:

PROGRAM:

#include<lpc17xx.h>

#include "gpio.h"

#define SWITCH1 P1_26

46
#define SWITCH2 P1_27

#define pin1 20

#define pin2 21

#define pin3 22

#define pin4 23

#define control LPC_GPIO1->FIOPIN

void cmotor1()

control |=(1<<pin1);

control |=(1<<pin2);

control &=~(1<<pin3);

control &=~(1<<pin4);

void cmotor2()

control &=~(1<<pin1);

control |=(1<<pin2);

control |=(1<<pin3);

control &=~(1<<pin4);

void cmotor3()

control &=~(1<<pin1);

control &=~(1<<pin2);

control |=(1<<pin3);

control |=(1<<pin4);

47
}

void cmotor4()

control |=(1<<pin1);

control &=~(1<<pin2);

control &=~(1<<pin3);

control |=(1<<pin4);

void delay_ms(unsigned int ms)

unsigned int i,j;

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

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

int main()

SystemInit(); //Clock and PLL configuration

LPC_PINCON->PINSEL3 = 0x000000; //Configure the PORT2 Pins as GPIO;

LPC_GPIO1->FIODIR =(1<<pin1)|(1<<pin2)|(1<<pin3) | (1<<pin4);

//Configure the PORT1 pins as OUTPUT;

GPIO_PinDirection(SWITCH1,INPUT);

GPIO_PinDirection(SWITCH2,INPUT);

while(1)

while(1)

48
if(!GPIO_PinRead(SWITCH1))

break;

cmotor1();

delay_ms(50);

cmotor2();

delay_ms(50);

cmotor3();

delay_ms(50);

cmotor4();

delay_ms(50); }

while(1)

if(!GPIO_PinRead(SWITCH2)) {

break;

cmotor4();

delay_ms(50);

cmotor3();

delay_ms(50);

cmotor2();

delay_ms(50);

cmotor1();

delay_ms(50);

} } }

49
RESULT:

Thus interfacing STEPPER MOTOR with ARM processor LPC1768 is verified.

50
EXP.NO: 12 INTERFACING EEPROM

DATE:

AIM:

To write an embedded c program to interface EEPROM AND INTERRUPT with ARM processor
LPC1768

COMPONENTS REQUIRED:

HARDWARE:

ARM LPC1768

EEPROM MODULE

LCD

SOFTWARE:

KEIL

SOURCE FILE:

Startup lpc 17xx.s, delay.c(t), eeprom.c(t), gpio.c(t), system lpc 17xx.c(t), uart.c(t), main.c(t), softi 2c.c(t),
lcd.c(t)

HEADER FILE:

Delay.h, eeprom.h

PROCEDURE:

 Open the Keil software and select the New uvision project from Project Menu as shown below.

 Browse to your project folder and provide the project name and click on save.

 Once the project is saved a new pop up “Select Device for Target” opens, Select the
controller (NXP: LPC1768) from NXP (founded by philips) and click on OK.

 Select the controller (NXP: LPC1768) and click on OK.

 As LPC1768 needs the startup code, click on Yes option to include the LPC17xx Startup file.

 Create a new file by file → new to write the program.

 Type the code.

 After typing the code save the file as main.c eg. (abc.c).

 Right click target and Add the suitable files to source group1 and header for the project.

51
 Add the main.c along with system_LPC17xx.c.

 Build the project and fix the compiler errors/warnings if any.

 Code is compiled with no errors. The .bin file is still not generated.

 Right Click on Target Options to select the option for generating .bin file.

 Set IROM1 start address as 0x2000. Bootloader will be stored from 0x0000-0x2000 so
application should start from 0x2000

 Write the command to generate the .bin file from .axf file
Command: fromelf --bin projectname.axf --output filename.bin

 in c/c++ → include paths → desktop (00-libfiles).

 .Bin file is generated after a rebuild.

 Check the project folder for the generated .Bin file.

BLOCK DIAGRAM:

52
PROGRAM:

#include<LPC17xx.h>

#include "uart.h"

#include "lcd.h"

#include "gpio.h"

#include "eeprom.h"

#include "delay.h"

#define SWITCH1 P1_26

#define SWITCH2 P1_27

#define SWITCH3 P1_28

/* start the main program */

int main()

uint8_t eeprom_address = 0x00, write_str[] = "EEPROM Memory";

uint8_t read_str[50];

LCD_SetUp(P1_18,P1_19,P1_20,P_NC,P_NC,P_NC,P_NC,P1_21,P1_22,P1_23,P1_24);

LCD_Init(2,16);

EEPROM_Init(AT24C08,P0_0,P0_1);

LCD_CmdWrite(0x80);

LCD_String("EEPROM DEMO");

while (1)

if(!GPIO_PinRead(SWITCH1))

LCD_CmdWrite(0x01);

LCD_CmdWrite(0x80);

53
LCD_String("DATA SEND");

LCD_CmdWrite(0xC0);

LCD_String(write_str);

EEPROM_WriteString(eeprom_address, write_str); // Write the string at memoryLocation 0x00

else if(!GPIO_PinRead(SWITCH2))

LCD_CmdWrite(0x01);

LCD_CmdWrite(0x80);

LCD_String("DATA RECEIVE");

EEPROM_ReadString(eeprom_address, read_str);

LCD_CmdWrite(0xC0); // Read the string from memoryLocation 0x00

LCD_String(read_str); //Print the message on UART

else if(!GPIO_PinRead(SWITCH3))

main();

break;

54
RESULT:

Thus interfacing EEPROM AND INTERRUPT with ARM processor LPC1768 is verified.

55
EXP.NO: 13 INTERFACING DAC WITH ARM PROCESSOR

DATE:

AIM:

To write an embedded c program to interface DAC with ARM processor LPC1768.

COMPONENTS REQUIRED:

HARDWARE:

ARM LPC1768

LED

MULTIMETER

SOFTWARE:

KEIL

SOURCE FILE:

Startup lpc17xx.s, main.c(t), delay.c(t), gpio.c(t), pwm.c(t), system lpc17xx.c(t)

HEADER FILE:

Delay.h, gpio.h, pwm.h, stdutils.h

PROCEDURE:

 Open the Keil software and select the New uvision project from Project Menu as shown below.

 Browse to your project folder and provide the project name and click on save.

 Once the project is saved a new pop up “Select Device for Target” opens, Select the
controller (NXP: LPC1768) from NXP (founded by philips) and click on OK.

 Select the controller (NXP: LPC1768) and click on OK.

 As LPC1768 needs the startup code, click on Yes option to include the LPC17xx Startup file.

 Create a new file by file → new to write the program.

 Type the code.

 After typing the code save the file as main.c eg. (abc.c).

 Right click target and Add the suitable files to source group1 and header for the project.

 Add the main.c along with system_LPC17xx.c.

56
 Build the project and fix the compiler errors/warnings if any.

 Code is compiled with no errors. The .bin file is still not generated.

 Right Click on Target Options to select the option for generating .bin file.

 Set IROM1 start address as 0x2000. Bootloader will be stored from 0x0000-0x2000 so
application should start from 0x2000

 Write the command to generate the .bin file from .axf file
Command: fromelf --bin projectname.axf --output filename.bin

 in c/c++ → include paths → desktop (00-libfiles).

 .Bin file is generated after a rebuild.

 Check the project folder for the generated .Bin file

BLOCK DIAGRAM:

PROGRAM:

#include <lpc17xx.h>

#include "pwm.h"

#include "delay.h"

#include "gpio.h"

#define CYCLE_TIME 255

57
#define SWITCH1 P1_26 /* start the main program */

int main()

int dutyCycle=0;

SystemInit(); /* Clock and PLL configuration */

PWM_Init(CYCLE_TIME);

/* Initialize the PWM module and the Cycle time(Ton+Toff) is set to 255(similar to arduino)*/

PWM_Start(PWM_4); /* Enable PWM output on PWM_1-PWM_4 (P2_0 - P2_3) */

GPIO_PinDirection(SWITCH1,INPUT);

while(1)

PWM_SetDutyCycle(PWM_4,dutyCycle); //P2_3

if(!GPIO_PinRead(SWITCH1))

DELAY_ms(5);

dutyCycle=dutyCycle+50;

if(dutyCycle>250)

dutyCycle=0;

58
RESULT:

Thus interfacing DAC with ARM processor LPC1768 is verified

59
EXP NO:14 STUDY OF ARM PROCESSOR

DATE:

AIM:

To study ARM processor features and functions for further analysis of interfacing peripherals.

ARM - INTRODUCTION:

 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.
 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:

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

ARM PROCESSOR – CHARACTERISTICS:

 The simplified design of ARM processors enables more efficient multi-core processing and easier
coding for developers.
 ARM servers represent an important shift in server-based computing.
 An ARM server uses 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.

ARM PROCESSOR – SERIES:

60
 ARM Processor are categorized based on following for high performance with low power
consumption
o A – Application (for application of processor), implemented by 32-bit cores in
the Cortex-A series and by some non-ARM cores.
o R - Real Time Application (for real time characteristics), implemented by cores in
the Cortex-R series.
o M - Microcontroller (for microcontroller application), implemented by most cores in
the Cortex-M series.
 Some of the series are
o ARM1 , ARM2 , ARM250, ARM3, ARM60 , ARM610, ARM700 , ARM710a
o ARM 11 MPcore, ARM CORTEX A5, ARM CORTEX A7, ARM CORTEX A8, ARM
CORTEX A9, ARM CORTEX A12, ARM CORTEX A15
o ARM CORTEX R4, ARM CORTEX R5
o ARM CORTEX M0, ARM CORTEX M0+, ARM CORTEX M1, ARM CORTEX M3,
ARM CORTEX M4

ARM CORTEX M3:

 3-stage pipeline with branch speculation.


 Instruction sets:
o Thumb (entire)
o Thumb-2 (entire).
o 32-bit hardware multiply with 32-bit or 64-bit result, signed or unsigned, add or subtract
after the multiply.
 32-bit hardware divide (2-12 cycles).
 saturation arithmetic support.
 1 to 240 interrupts, plus NMI.
 12 cycle interrupt latency.
 Integrated sleep modes.

61
RESULT:

Thus the study of ARM processor is analyzed for application interfacing the peripherals with
ARM Board.

62

You might also like