Professional Documents
Culture Documents
RESULT:
2. SIMULATION OF ADDITION AND SUBTRACTION ON ARM IN ASSEMBLY
AIM:
To write an assembly language program for Addition, Subtraction and simulate the program in
the software.
APPARATUS REQUIRED:
1. Personal computer
2. IAR embedded software
PROCEDURE:
1. Open IAR Embedded software in the desktop.
2. Select, project → create new project →asm → ok.
3. Create new folder in desktop and save the project.
4. Enter the program in the workspace.
5. Save the program.
6. In options select, general option as core ARM7TDMI-S
7. Select the output converter as intel extended.
8. Select the path for linker.
9. Rebuild all
10. Select project →debug without downlading
11. Select view → register. The register window will show in the workspace.
12. Select project →make and restart debugger.
13. Press F11 key and Verify the output in register window.
FLOW CHART
PROGRAM:
#include <NXP/iolpc2148.h>
NAME main
PUBLIC __iar_program_start
SECTION .intvec : CODE (2)
CODE32
__iar_program_start
B main
SECTION .text : CODE (2)
CODE32
main NOP
LDR R0,=0X5
LDR R1,=0XA
ADD R8,R1,R0
SUB R9,R1,R0
stop B stop
END
RESULT:
3. SIMULATION OF MULTIPLICATION OPERATION ON ARM IN ASSEMBLY
AIM:
To write an assembly language program for Multiplication operations and simulate the program
in the software.
APPARATUS REQUIRED:
1. Personal computer
2. IAR embedded software
PROCEDURE:
1. Open IAR Embedded software in the desktop.
2. Select, project → create new project →asm → ok.
3. Create new folder in desktop and save the project.
4. Enter the program in the workspace.
5. Save the program.
6. In options select, general option as core ARM7TDMI-S
7. Select the output converter as intel extended.
8. Select the path for linker.
9. Rebuild all
10. Select project →debug without downlading
11. Select view → register. The register window will show in the workspace.
12. Select project →make and restart debugger.
13. Press F11 key and Verify the output in register window.
FLOW CHART
PROGRAM:
#include <NXP/iolpc2148.h>
NAME main
PUBLIC __iar_program_start
SECTION .intvec : CODE (2)
CODE32
__iar_program_start
B main
SECTION .text : CODE (2)
CODE32
main NOP
LDR R0,=0X5
LDR R1,=0XA
MUL R10, R1, R0
UMULL R11,R12, R1,R0
stop B stop
END
RESULT:
4. SIMULATION OF C PROGRAM FOR SOFT DELAY
AIM:
To write an assembly language program for soft delay and simulate the program in the software.
APPARATUS REQUIRED:
1. Personal computer
2. IAR embedded software
3. Embedded kit
4. Connecting cables
PROCEDURE:
1. Open IAR Embedded software in the desktop.
2. Select, project → create new project →C→ ok.
3. Create new folder in desktop and save the project.
4. Enter the program in the workspace.
5. Save the program.
6. In options select, general option as core ARM7TDMI-S
7. Select the output converter as intel extended.
8. Select the path for linker.
9. Rebuild all
10. Open flash magic and browse your hex file.
11. Load the program to kit and verify the output.
FLOWCHART
PROGRAM:
#include<nxp/iolpc2148.h>
void delay_ms(int j) //delay routine
{
int i;
for(i=0;i<j;i++);
}
void main()
{
unsigned int n,m=4000;
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000; // PINSEL(0,1,2) = 0 configures the pins as GPIO
PINSEL2 = 0x00000000;
IO1DIR = 0xff000000; // only P1.24 to p1.31 pin will be configured as Output Pin.
while(1)
{
for(n=0x00;n<0x08;n++)
{
IO1PIN=0x01000000 << n; // Set 1 st LED to 8th LED
delay_ms(m);
}
RESULT:
5. REALIZING TIMER PERIPHERAL IN ARM BY POLLING METHOD
AIM:
To write a C program for realizing timer peripheral in ARM by polling method.
APPARATUS REQUIRED:
1. Personal computer
2. IAR embedded software
3. Embedded kit
4. Connecting cables
PROCEDURE:
1. Open IAR Embedded software in the desktop.
2. Select, project → create new project → C → ok.
3. Create new folder in desktop and save the project.
4. Enter the program in the workspace.
5. Save the program.
6. In options select, general option as core ARM7TDMI-S
7. Select the output converter as intel extended. FLOWCHART:
8. Select the path for linker.
9. Rebuild all
10. Open flash magic and browse your hex file.
11. Load the program to kit and verify the output.
PROGRAM:
#include<nxp\iolpc2148.h>
unsigned int LED_value = 0xf0;
unsigned int timer_delay = 1000 ;
void timer_init()
{
VPBDIV = 0x00000001;
T0PR = 12000*timer_delay ;
T0MR0 = 0x01;
T0MCR = 0x02;
T0TCR = 0x00000002;
T0TCR = 0x00000001;
}
void main(void)
{
PINSEL0 = 0X00000000;
PINSEL1 = 0x00000000;
PINSEL2 = 0X00000000;
IO1DIR = 0xff000000;
timer_init();
IO1PIN = 0xff000000;
while(1)
{
if( T0TC==0 )
{
IO1PIN = LED_value <<24;
while(T0TC==0);
}
else
IO1PIN = 0x00000000;
}
}
RESULT:
6. REALIZING TIMER PERIPHERAL IN ARM BY INTERRUPT DRIVEN METHOD
AIM:
To write a program for realizing timer peripheral in ARM by interrupt driven method.
APPARATUS REQUIRED:
1. Personal computer
2. IAR embedded software
3. Embedded kit
4. Connecting cables
PROCEDURE:
1. Open IAR Embedded software in the desktop.
2. Select, project → create new project → C → ok.
3. Create new folder in desktop and save the project.
4. Enter the program in the workspace.
5. Save the program.
6. In options select, general option as core ARM7TDMI-S
7. Select the output converter as intel extended.
8. Select the path for linker.
9. Rebuild all
10. Open flash magic and browse your hex file. FLOW CHART:
11. Load the program to kit and verify the output.
PROGRAM:
#include <NXP/iolpc2148.h>
#include <intrinsics.h>
#include <stdio.h>
void timer0_ISR();
void timer0_init();
void feed (void);
__irq __arm void irq_handler (void);
__fiq __arm void fiq_handler (void);
void main(void)
{
PINSEL2 = 0X00000000;
IO1DIR = 0xff000000;
timer0_init();
__enable_interrupt();
while(1)
{
IO1PIN = 0x55000000;
}
}
void timer0_ISR()
{
IO1PIN = 0xAA000000;
for(int i = 0; i < 500000; ++i);
T0IR = 1;
}
void timer0_init()
{
PLLCON_bit.PLLC = PLLCON_bit.PLLE = 0;
feed();
VPBDIV_bit.VPBDIV = 0;
T0IR =0xFF;
T0TC = 0 ;
T0PR = 0 ;
T0MR0 = 3000000;
T0MCR = 3 ;
T0TCR = 1 ;
VICIntSelect = 0;
VICIntEnClear = 0xFFFFFFFF;
VICProtection = 0;
VICVectAddr = 0;
VICProtection = 0;
VICIntSelect &= ~(1<<VIC_TIMER0);
VICVectAddr0 = (unsigned int)&timer0_ISR;
VICVectCntl0 = 0x20 | VIC_TIMER0;
VICIntEnable |= (1<<VIC_TIMER0);
}
__irq __arm void irq_handler (void)
{
void (*interrupt_function)();
interrupt_function = (void(*)())VICVectAddr;
(*interrupt_function)();
VICVectAddr = 0;
}
__fiq __arm void fiq_handler (void)
{ while(1);
}
void feed (void)
{
PLLFEED=0xAA;
PLLFEED=0x55;
}
RESULT:
7. REALIZATION OF INPUT AND OUTPUT PORT IN C
AIM:
To write an C program for realization of input(Switch) and output(LED) port on embedded kit.
APPARATUS REQUIRED:
1. Personal computer
2. IAR embedded software
3. Embedded kit
4. Connecting cables
PROCEDURE:
1. Open IAR Embedded software in the desktop.
2. Select, project →create new project →C→ ok.
3. Create new folder in desktop and save the project.
4. Enter the program in the workspace.
5. Save the program.
6. In options select, general option as core ARM7TDMI-S
7. Select the output converter as intel extended.
8. Select the path for linker.
9. Rebuild all
10. Open flash magic and browse your hex file.
11. Load the program to kit and verify the output.
FLOW CHART
PROGRAM:
#include <nxp/iolpc2148.h>
static void delay (void)
{
volatile inti,j;
for (i=0;i<0x3F;i++)
for (j=0;j<500;j++);
}
// SWITCH INTERFACE
// SW0 - SW7 : P0.16 - P0.23
// LED0 - LED7 : P1.23 - P1.31
// Switch Staus Displayed on LED
//------------------------------------------------------------------------------
void main()
{
// PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000; // Configured as GPIO port
PINSEL2 = 0x00000000; // Configured as GPIO port
IO0DIR = 0X00000000; // P0.16 TO P0.23 Configured as input
IO1DIR = 0Xff000000; // P1.23 TO P1.31 Configured as output
while(1)
{
// IO0CLR = 0XFF000000;
// IO1CLR = 0XFF000000;
IO1PIN = (~(IO0PIN & 0x00FF0000)<<0x08);
// delay();
}
}
RESULT:
8.EXTERNAL INTERRUPT PULSE DISPLAY IN LED
AIM:
To write a program for counting external interrupt pulses(VIC) and to display the count value in
LED.
APPARATUS REQUIRED:
1. Personal computer
2. IAR embedded software
3. Embedded kit
4. Connecting cables
PROCEDURE:
1. Open IAR Embedded software in the desktop.
2. Select, project → create new project → C → ok.
3. Create new folder in desktop and save the project.
4. Enter the program in the workspace.
5. Save the program.
6. In options select, general option as core ARM7TDMI-S
7. Select the output converter as intel extended.
8. Select the path for linker.
9. Rebuild all
10. Open flash magic and browse your hex file.
11. Load the program to kit and verify the output.
FLOWCHART
PROGRAM
#include<nxp\iolpc2148.h>
#include "intrinsics.h"
#include "stdio.h"
void EXINT3(void);
int temp;
if(ch=='\n')
while((U0LSR&0x20)!=0x20);
U0THR='\r';
while((U0LSR&0x20)!=0x20);
return(U0THR=ch);
void main()
U0LCR=0X83;
U0LCR=0X03;
PINSEL1_bit.P0_30=2;
PINSEL2=0x00000000;
IO1DIR=0xff000000;
while(1);
void EXINT3(void)
EXTINT_bit.EINT3=1;
IO1PIN=0x00000000;
temp=(IO1PIN | i);
i++;
#pragma vector=0x18
void (*interrupt_function)();
vector = VICVectAddr;
interrupt_function = (void(*)())vector;
(*interrupt_function)();
VICVectAddr = 0;
__fiq __arm void fiq_handler (void) /*------ FIQ Handler Function ---------*/
{ while(1); }
RESULT:
9. SEVEN SEGMENT LED DISPLAY INTERFACE IN C
AIM:
To write a program for seven segments LED display interface in C on embedded kit.
APPARATUS REQUIRED:
1. Personal computer
2. IAR embedded software
3. Embedded kit
4. Connecting cables
PROCEDURE:
1. Open IAR Embedded software in the desktop.
2. Select, project → create new project → C → ok.
3. Create new folder in desktop and save the project.
4. Enter the program in the workspace.
5. Save the program.
6. In options select, general option as core ARM7TDMI-S
7. Select the output converter as intel extended.
8. Select the path for linker.
9. Rebuild all
10. Open flash magic and browse your hex file.
11. Load the program to kit and verify the output.
FLOW CHART
PROGRAM:
#include<nxp/iolpc2148.h>
#include<stdio.h>
#define DESIRED_BAUDRATE 19200
#define CRYSTAL_FREQUENCY_IN_HZ 12000000
#define PCLK CRYSTAL_FREQUENCY_IN_HZ
// since VPBDIV=0x01 #define DIVISOR (PCLK/(16*DESIRED_BAUDRATE))
int i,temp,Temp1,addr;
unsigned char i2c_data[] = {0x00,0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67};
static void delay(void )
{
volatile int i,j;
for (i=0;i<5;i++)
for (j=0;j<50;j++);
}
static void delay1(void )
{
volatile int i,j;
for (i=0;i<100;i++)
for (j=0;j<500;j++); }
void i2c_write(char a,char add)
{
//START CONDITION
I2C0CONSET=0x60; //0x60 chang //start I2C data transmission when set STA flag.
delay();
delay();
temp=I2C0STAT;
while(temp!=0x08)
temp=I2C0STAT;
//SLAVE ADDRESS
I2C0DAT=add;
I2C0CONCLR=0x28;
temp=I2C0STAT;
delay();
while(temp!=0x18)
{
temp=I2C0STAT;
delay();
}
//Data Write
I2C0DAT=a;
I2C0CONCLR=0x08;
temp=I2C0STAT;
while(temp!=0x28)
{
temp=I2C0STAT;//& 0x28;
delay();
}
//STOP CONDITION
I2C0CONSET=0x10;
I2C0CONCLR=0x8;
delay1();
}
int putchar(int ch)
{
while (!(U0LSR&0x20)) {}
return(U0THR=ch);
}
void main()
{
PINSEL0=0x00000055 ;
VPBDIV=0x01 ;
I2C0CONCLR=0x6C; //clear I2C0CONCLR register
I2C0CONSET=0x40; //Enable I2C.
I2C0SCLH=110;
I2C0SCLL=90;
while(1)
{
for(int i=0;i<=10;i++)
i2c_write(i2c_data[i],0x40);
for(int i=0;i<=10;i++)
i2c_write(i2c_data[i],0x42);
for(int i=0;i<=10;i++)
i2c_write(i2c_data[i],0x44);
for(int i=0;i<=10;i++)
i2c_write(i2c_data[i],0x46);
for(int i=0;i<=10;i++)
i2c_write(i2c_data[i],0x48);
for(int i=0;i<=10;i++)
i2c_write(i2c_data[i],0x4A);
}
}
RESULT:
10. SERIAL TRANSMISSION AND RECEPTION OF A CHARACTER IN C BY POLLING METHOD
AIM:
To write a cprogram for serial transmission and reception of a character by polling method.
APPARATUS REQUIRED:
1. Personal computer
2. IAR embedded software
3. Embedded kit
4. Connecting cables
PROCEDURE:
1. Open IAR Embedded software in the desktop.
2. Select, project → create new project → C → ok.
3. Create new folder in desktop and save the project.
4. Enter the program in the workspace.
5. Save the program.
6. In options select, general option as core ARM7TDMI-S
7. Select the output converter as intel extended.
8. Select the path for linker.
9. Rebuild all
10. Open wintalk and verify the output.
FLOW CHART
PROGRAM:
#include<nxp/iolpc2148.h>
#define f 12000000
void serial_Init(void)
{
unsigned int baudrate;
PINSEL0=0X00000005;
VPBDIV=0X01;
baudrate = (f/(9600*16));
U0LCR=0X80;
U0DLL = baudrate & 0X00FF;
U0DLM=( baudrate>>8) & 0X00FF;
U0LCR=0X03; } char serialrx(void)
{
unsigned char rxdata;
while(!(U0LSR&0x01));
rxdata=U0RBR;
return rxdata;
} void serialtx(char txdata)
{
while(!(U0LSR&0x20));
U0RBR=txdata;
}
void main()
{
unsigned char msg[]="\r\nEnter the Data : ";
unsigned int i,rxdata; serial_Init();
while(1)
{
for(i=0;msg[i]!='\0';i++)
{
serialtx(msg[i]);
}
rxdata = serialrx();
serialtx(rxdata);
}}
RESULT:
11. SERIAL TRANSMISSION AND RECEPTION OF A CHARACTER IN C BY INTERRUPT METHOD
AIM:
To write a program for serial transmission and reception of a character in c by interrupt method.
APPARATUS REQUIRED:
1. Personal computer
2. IAR embedded software
3. Embedded kit
4. Connecting cables
PROCEDURE:
1. Open IAR Embedded software in the desktop.
2. Select, project → create new project → C → ok.
3. Create new folder in desktop and save the project.
4. Enter the program in the workspace.
5. Save the program.
6. In options select, general option as core ARM7TDMI-S
7. Select the output converter as intel extended.
8. Select the path for linker.
9. Rebuild all
10. Open wintalk and verify the output.
FLOW CHART:
PROGRAM:
#include <NXP/iolpc2148.h>
#include <intrinsics.h>
#include <stdio.h>
void UART0_ISR();
void UART0_init();
void feed (void);
void serialtx(char txdata);
__irq __arm void irq_handler (void);
__fiq __arm void fiq_handler (void);
void main(void)
{
unsigned char msg[]="\r\n UART0 Interrupt Program. ";
PINSEL2 = 0X00000000;
IO1DIR = 0xff000000;
UART0_init();
__enable_interrupt();
for(int i=0;msg[i]!='\0';i++)
{
serialtx(msg[i]);
}
while(1)
{
IO1PIN = 0x55000000;
}
}
void UART0_ISR()
{
int temp,buf;
__disable_interrupt();
IO1PIN = 0xAA000000;
for(int i = 0; i < 10000; ++i)
temp = U0IIR;
temp =( temp>>1 )& 0x07;
if (temp==2)
{
while (U0LSR & 0x01)
{
buf=U0RBR;
serialtx(buf);
}
}
__enable_interrupt();
VICVectAddr = 0;
}
void UART0_init()
{
PLLCON_bit.PLLC = PLLCON_bit.PLLE = 0;
feed();
VPBDIV_bit.VPBDIV = 0;
PINSEL0=0X00000005;
VPBDIV=0X01;
int baudrate = (12000000/(9600*16));
U0LCR=0X80;
U0DLL = baudrate & 0X00FF;
U0DLM=( baudrate>>8) & 0X00FF;
U0LCR=0X03;
U0IER = 0x01;
VICIntSelect = 0;
VICIntEnClear = 0xFFFFFFFF;
VICProtection = 0;
VICVectAddr = 0;
VICProtection = 0;
VICIntSelect &= ~(1<<VIC_UART0);
VICVectAddr0 = (unsigned int)&UART0_ISR;
VICVectCntl0 = 0x20 | VIC_UART0;
VICIntEnable |= (1<<VIC_UART0);
}
__irq __arm void irq_handler (void)
{
void (*interrupt_function)();
interrupt_function = (void(*)())VICVectAddr;
(*interrupt_function)();
VICVectAddr = 0;
}
__fiq __arm void fiq_handler (void)
{
while(1);
}
void feed (void)
{
PLLFEED=0xAA;
PLLFEED=0x55;
}
void serialtx(char txdata)
{
while(!(U0LSR&0x20));
U0RBR=txdata;
}
RESULT:
12. ACCESSING INTERNAL ADC OF THE ARM PROCESSOR AND TO DISPLAY IN LED
AIM:
Write a C Programs for reading an internal ADC and to display the binary output in LED.
APPARATUS REQUIRED:
1. Personal computer
2. IAR embedded software
3. Embedded kit
4. Connecting cables
PROCEDURE:
1. Open IAR Embedded software in the desktop.
2. Select, project → create new project → C → ok.
3. Create new folder in desktop and save the project.
4. Enter the program in the workspace.
5. Save the program.
6. In options select, general option as core ARM7TDMI-S
7. Select the output converter as intel extended.
8. Select the path for linker.
9. Rebuild all
10. Open wintalk and verify the output.
FLOWCHART:
PROGRAM
#include<nxp/iolpc2148.h>
#include<stdio.h>
#define DESIRED_BAUDRATE 19200
#define CRYSTAL_FREQUENCY_IN_HZ 12000000
#define PCLK CRYSTAL_FREQUENCY_IN_HZ // since VPBDIV=0x01
#define DIVISOR (PCLK/(16*DESIRED_BAUDRATE))
void main()
{
PINSEL1 = 0x01000000; //ADC0.1 CHANNEL SELECT
PINSEL2 = 0x00000000;
IO1DIR = 0xff000000; // only P1.24 to p1.31 pin will be configured as Output Pin.
}
}
RESULT: