Professional Documents
Culture Documents
COIMBATORE.
24064-EMBEDDED SYSTEMS
LAB MANUAL
( L- Scheme )
Prepared By
K.Shanmuga Priya
Lecturer / ECE
EXP.NO:1
STUDY OF ARM PROCESSOR KIT
DATE:
AIM:
To study about memory mapping of peripherals & I/O, Timer and UART operation with SFRs in
ARM processor kit.
APPARATUS REQUIRED:
1. LPC2148 kit
2. User manual
THEORY:
ARM is a 32bit processor. It is a high performance, low power (3.3v) device works with RISC
principle.
List of peripherals:
1. 32 KB SRAM
2. 512 KB FlashRAM
4. Timers (0 & 1)
5. UART (0 & 1)
7. D/A converter
It is a process of sharing 4GB capacity of LPC2148 between memories and onchip peripherals.
Each pin out of the Microcontroller has several functions, maximum of 4 functions. In order to use
the physical pin out for a specific function, the pin is to be configured for that function. In order to
configure, it needs 2 bits (to carry out any one of 4 functions). For this purpose, there is a register called
PINSEL register.
PINSEL0, 32 bit register is used to configure Pin outs for P0.0 to P0.15 (16 pins), since each pin
needs 2 bits.
PINSEL1 register is used to configure Pin outs for P0.16 to P0.31
PINSEL2 register is used to configure Pin outs for P1 Port, P1.16 to P1.31
After, configuring the pin as I/O line, next it is to be designated as input pin or output pin. It is done by
another register namely IODIR.
IODIR0, 32 bit register is used to designate each I/O line in Port 0. Against the particular bit, if 1 is
written, then that bit in the Port 0 is designated as Output pin. If 0 is written in the particular bit position,
then that I/O pin will act as input pin.
Similarly, IODIR1, the bits 16 to 31 is used to designate the Port1 pins either as output or as input
If the pin is configured as output pin, in order to write 1 level in that pin, IOSET register is used. In
order to write 0 level in that pin, IOCLR register is used. It is to be noted that using single register IOSET
register, it is not possible to clear the bit.
IOSET0, 32 bit register is used to write 1 in any one of the output pin of Port0
IOCLR0, 32 bit register is used to write 0 in any one of the output pin of Port0
IOSET1, 32 bit register is used to write 1 in any one of the output pin of Port1
IOCLR1, 32 bit register is used to write 1 in any one of the output pin of Port1
If the pin is configured as input pin, in order to read the data from that pin, IOPIN register is used.
IOPIN0, 32 bit register is used to read the data from any one of the I/O pins of Port0.
IOPIN1, 32 bit register is used to read the data from any one of the I/O pins of Port1.
There are 2 nos. of 32 bit timers in this Microcontroller. Timer is basically a counter. For timer,
internal clock is given as input. Internally, PCLK, Peripheral clock is given as the input pulses.
Timer0 registers
TC0 Timer Counter Register (32 bit register). For every clock pulse, this register is incremented.
Before the clock pulse is given to TCO, the clock pulses are given to the Prescale Counter namely
PC0 32 bit register. Along with PC0, there is another register namely Prescale Register PR0 32 bit
register. The PC0 gives one output pulse for each prescale register value. For example, if the PR0 has the
value of decimal 10, then the PC0 gives one output pulse for every 10 input clock pulses. The Prescale
Counter output is given as the clock pulse to Timer Counter register TC0. In this way, 32 bit Prescale
divider is included in the timer operation.
TCR0 Timer Control Register. This register is used to reset the counter and disable/enable the
Timer Counter Register TC0.
T0MR0 Match0 Register. It is a 32 bit register. The 32 bit content entered is compared with the
content of Timer/Counter Register TC0 continuously. When the match occurs, the following functions can
be actuated.
1. If the interrupt enable bit is made 1, interrupt flag bit for MR0 is made 1 in T0IR register.
2. The Timer/Counter register can be made to reset.
3. The Timer/Counter register can be disabled.
4. In the corresponding pin MAT0.0 for MR0, output can be generated.
The first 3 functions can be actuated by writing control bits in MCR register Match Control Register.
Similar to T0MR0, there are T0MR1, T0MR2, T0MR3 match registers. They can be also used for
comparing with the contents of Timer/Counter (TC) register. On match, the above functions for the
corresponding match register can be actuated.
T0IR It is an 8 bit interrupt register. For every match, corresponding bit in this interrupt register is
set. On writing again the same bit in the Interrupt Service Routine, the corresponding bit will be cleared.
Similar to match registers, there are 4 capture registers namely T0CR0, T0CR1, T0CR2 and
T0CR3. The content of Timer/Counter (TC) register value is loaded into T0CR0, when an event on
physical pin CAP0.0, one particular physical input.
T0CCR is a 32 bit register which controls which edges of the capture inputs are used to load the
Capture registers and whether or not an interrupt is generated when a capture takes place.
In order to use the timer as counter, T0CTCR register is used. It is used to change to counter mode
and to determine in which pin, physical count input pulses is given.
UART0 has lines TXD, RXD and Gnd lines for interfacing simple serial port.
UART1 has lines apart from the above, control lines for interfacing Modem also. Now, we are going to see
only the registers available in UART0
UART0 is used to send the byte of data serially and receive the byte of the data serially.
At the time of receiving, it receives the bits serially and assembles as parallel 8 bit data and it places
in the receiver buffer register U0RBR. It is the content of the top of the FIFO buffer registers.
At the time of transmitting, the user is supposed to place the 8 bit data in Transmit Hold Register
namely U0THR.
In serial communication, the serial data is sent in the same rate at which the receiving system also
receives. This is called baud rate (bits per second). For example, 9600 baud means 9600 bits per second.
The internal clock is divided by 16 bit no. to arrive at the required baud rate.
The Most Significant 8 bits of the divider value are stored is called U0DLM. The Least Significant
8 bits of the divider value are stored in the register called U0DLL. At the time of writing in these registers
only, DLAB bit in the U0LCR register (Line Control Register) is to be made 1.
Whenever, the U0THR register is empty, the next byte of data can be sent to send it out serially.
There is another register U0IIR, which is used to find what are all the interrupts pending.
The register FIFO control register U0FCR is used to reset TX FIFO (Transmit First In First Out register set)
and RX FIFO (Receive First In First Out) and to enable them.
The register U0LCR, line control register is used to write serial protocol parameters namely, the word
length of the data, no. of stop bits, parity enable, parity select, Break control. The 7th bit in this register
namely DLAB is used to enter the 16 bit divisor data.
Line Status register U0LSR is the status register to know whether data has been received, data can be sent
for transmission, to find out errors.
There is another register U0TER which is used to enable the serial transmitter
4. A to D Converter
There are 2 units of A/D Converters in this controller AD0 and AD1. There are 6 channels in AD0
unit and 8 channels in AD1 unit. It is a 10 bit ADC. The maximum analog voltage that can be given as input
is 3.3V. It uses Successive Approximation techniques to convert analog input to corresponding 10 bit digital
output. It requires clock which will be less than 4 MHz.
AD0CR register is a control register in which the details of the channel to be used, clock speed
divider, switching on the ADC Section and finally start signal to start the converter.
AD0GDR is the global data register. The done bit for the latest conversion and the 10 bit digital data
are available in this register.
AD0STAT is the A/D Status register. This register contains Done and error bits for all the channels
for AD0 unit.
ADGSR is the global start register. It is used to start conversion in both A/D Converters AD0 and
AD1 simultaneously.
AD0INTEN is A/D Interrupt Enable register. This register contain enable bits that allow the DONE
flag of each A/D Channel to raise common A/D interrupt.
EXP.NO:2
SIMULATION OFARITHMETIC OPERATION ON ARM IN
DATE: ASSEMBLY.
There are eight ADDR0, ADDR1, ADDR2, ADDR3, ADDR4, ADDR5, ADDR6 and ADDR7 Data
register. This register contains the result of the most recent conversion completed in the respective channel
RESULT:
Thus the memory mapping of peripherals & I/O, Timer and UART operation with SFRs in ARM
processor kit was studied.
AIM:
To write and simulate the assembly language program for addition, subtraction and multiplication.
APPARATUS REQUIRED:
1. PC
ALGORITHM:
Step 3: By using proper instruction arithmetic operation is performed and the result
stored in destination register.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
Project >> Debug without Downloading.( Here debugging will start & Disassembly
window will open.) Open the other required window also (e.g. Register Window) for visualizing
the output.
Project >> Make & Restart Debugger. (Here the debugging process is ready to check the
output by step by step execution of the code).
PROGRAM:
#include <NXP/iolpc2148.h>
NAME main
PUBLIC __iar_program_start
SECTION .intvec : CODE (2)
CODE32
__iar_program_start
B main
/*-------- Explanation of the code is given, you are recommended to follow this. ---*/
main NOP
LDR R0,=0X5 // Operend-1 ( 11111111 in hexadecimal ) stored in R0 .
LDR R1,=0XA // Operend-2 ( 11111111 in hexadecimal ) stored in R1 .
END
EXP.NO:3
SIMULATION OF SOFT DELAY IN ASSEMBLY.
DATE:
RESULT:
Arithmetic Operation (Addition, Subtraction, and Multiplication) on ARM in assembly was written
& output is verified by checking the output register window in debugging without downloading mode.
AIM:
To write and simulate the assembly language program for soft delay.
APPARATUS REQUIRED:
1. PC
ALGORITHM:
Step 2: Set the port pin value as 1 to produce logic 1 level output.
Step 4: Clear the port pin value as 0 to produce logic 0 level output.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
b. Project >> Debug without Downloading.( Here debugging will start & Disassembly window
will open.) Open the other required window also (e.g. Register Window) for visualizing the
output.
c. Project >> Make & Restart Debugger. (Here the debugging process is ready to check the
output by step by step execution of the code).
PROGRAM:
#include <nxp\iolpc2148.h>
PUBLIC __iar_program_start
CODE32
__iar_program_start
B main
CODE32
delay
BNE Loop2
SUBS R0,R0,#1
BNE Loop1
main
LDR R0,=PINSEL2
MOV R1,#0X00000000
STR R1,[R0]
LDR R0,=IO1DIR
MOV R1,#0Xff000000
STR R1,[R0]
led_glow:
LDR R0,=IO1PIN
MOV R1,#0Xff000000
STR R1,[R0]
BL delay
LDR R0,=IO1PIN
MOV R1,#0X00000000
STR R1,[R0]
BL delay
B led_glow
END
RESULT:
Thus the assembly language program for soft delay was written and the output was simulated and
verified.
AIM:
To write an assembly language program for blinking LED with variable speed.
APPARATUS REQUIRED:
1. PC
2. LPC2148 Kit
ALGORITHM:
Step 2: Set the port pin value as 1 to produce logic 1 level output.
Step 4: Clear the port pin value as 0 to produce logic 0 level output.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
PROGRAM:
#include <nxp\iolpc2148.h>
PUBLIC __iar_program_start
CODE32
__iar_program_start
B main
CODE32
delay
BNE Loop2
SUBS R0,R0,#1
BNE Loop1
main
LDR R0,=PINSEL2
MOV R1,#0X00000000
STR R1,[R0]
LDR R0,=IO1DIR
MOV R1,#0Xff000000
STR R1,[R0]
led_glow:
LDR R0,=IO1PIN
MOV R1,#0Xff000000
STR R1,[R0]
BL delay
LDR R0,=IO1PIN
MOV R1,#0X00000000
STR R1,[R0]
BL delay
EXP.NO:5
REALIZATION OF INPUT AND OUTPUT PORT IN ASM
DATE:
B led_glow
END
RESULT:
Thus the assembly language program for LED blinking with variable speed was written and the
output was verified using LEDs.
AIM:
To write an assembly language program so as to realize the input and output port in LPC2148 kit.
APPARATUS REQUIRED:
1. PC
2. LPC2148 Kit
ALGORITHM:
Step 2: Set the port pin value in port 0 & corresponding output can be found in port 1.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
PROGRAM:
#include <nxp\iolpc2148.h>
PUBLIC __iar_program_start
CODE32
__iar_program_start
B main
CODE32
//----------- Delay Subroutine -------------------
delay:
LOOP:
SUBS R0,R0,#1
BNE LOOP
main: NOP
LDR R0,=PINSEL1
STR R1,[R0]
LDR R0,=PINSEL2
STR R1,[R0]
LDR R0,=IO1DIR
STR R1,[R0]
LDR R0,=IO0DIR
STR R1,[R0]
GLOW_LED
MOV R2,#0XFF000000
EXP.NO:6
SIMPLE LED BLINKING WITH VARIABLE SPEED IN C
DATE:
END
RESULT:
Thus the assembly language program realizing the input and output port in LPC2148 kit was written
and the output was verified.
AIM:
To write an assembly language program for blinking LED with variable speed in C.
APPARATUS REQUIRED:
1. PC
2. LPC2148 Kit
Step 1: Start
Step 2: Set the port pin value as 1 to produce logic 1 level output.
Step 4: Clear the port pin value as 0 to produce logic 0 level output.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
PROGRAM:
#include<nxp/iolpc2148.h>
int i;
for(i=0;i<60000;i++);
}
void main()
IO1DIR = 0xff000000;
while(1)
IO1SET=0xff00f000 ;
delay_ms();
IO1CLR=0xff00f000 ;
delay_ms();
RESULT:
Thus the C language program for LED blinking with variable speed was written and the output was
EXP.NO:7
SEVENSEGMENT LED DISPLAY INTERFACE IN C
DATE:
AIM:
To write a program in Embedded C for 7 segment LED display and verify the output using LPC2148
kit.
APPARATUS REQUIRED:
1. PC
2. LPC2148 Kit
ALGORITHM:
Step 1: Start
Step 5: Stop.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
#include <nxp\iolpc2148.h>
for(int i=0;i<k;i++);
}
void i2c_config(void)
PINSEL0|=0X00000050;
I2C0CONCLR=0X6C;
I2C0CONSET=0X40;
I2C0SCLH=70;
I2C0SCLL=50;
I2C0CONSET=0X20;
delay(50);
while(I2C0STAT!=0x08);
I2C0CONCLR=0X28;
I2C0DAT=address;
delay(50);
while(I2C0STAT!=0x18);
I2C0CONCLR=0x08;
I2C0DAT=data;
delay(50);
while(I2C0STAT!=0x28);
//stop condition
I2C0CONSET=0X10;
I2C0CONCLR=0x08;
delay(50);
int cnt;
{ i=0;
{ j=0;
{k=0;
j=0;
l=0;
void main(void)
RESULT:
Thus the program in Embedded C for 7 segment LED display was written and the output was verified using
AIM:
To write a program for 7 segment LED display in Embedded C by using ASM delay and verify the
output using LPC2148 kit.
APPARATUS REQUIRED:
1. PC
2. LPC2148 Kit
ALGORITHM:
Step 1: Start
Step 5: Stop.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
#include<nxp/iolpc2148.h>
extern void delay(void); // Definition of this function is available in
// " asm_delay.s " so you must add this file with the project.
void i2c_config(void)
PINSEL0|=0X00000050; // To select the Port pins p0.2 and p0.3 as i2c configurable
I2C0SCLH=70;
I2C0CONSET=0X20;
while(I2C0STAT!=0x08);
I2C0CONCLR=0X28;
I2C0DAT=address;
while(I2C0STAT!=0x18);
I2C0CONCLR=0x08;
I2C0DAT=data;
while(I2C0STAT!=0x28);
//stop condition
I2C0CONSET=0X10;
I2C0CONCLR=0x08 ;}
{
unsigned char data[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
int cnt;
{ i=0;
{ j=0;
{k=0;
{ i=0;
j=0;
l=0;
}
}
void main(void)
Program: 2 asm-delay.s
#include <nxp\iolpc2148.h>
EXTERN rand
CODE32
delay
LOOP:
SUBS R0,R0,#1
BNE LOOP
END
RESULT:
Thus the program for 7 segment LED display in Embedded C by using ASM delay was written and the output
EXP.NO:9
REALIZING TIMER PERIPHERAL BY POLLING METHOD
DATE:
AIM:
To write a program for realizing the timer peripheral in ARM by polling method and verify the
output using LPC2148 kit.
APPARATUS REQUIRED:
1. PC
2. LPC2148 Kit
ALGORITHM:
Step 1: Start
Step 6: Stop.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
PROGRAM:
#include<nxp\iolpc2148.h>
void timer_init()
VPBDIV = 1;
T0PR = 12000*timer_delay ;
T0MR0 = 1;
T0MCR = 2;
T0TCR = 1;
int main(void)
IO1DIR = 0xFF000000;
timer_init();
while(1)
if( T0TC==0 )
IO1PIN = 0xF0000000;
while(T0TC==0);
else
IO1PIN = 0x0F000000;
}
}
RESULT:
Thus the program for realizing the Timer peripheral in ARM by polling method was written and the output
AIM:
To write a program for realizing the timer peripheral in ARM by interrupt driven method and verify
the output using LPC2148 kit.
APPARATUS REQUIRED:
1. PC
2. LPC2148 Kit
ALGORITHM:
Step 1: Start
Step 7: Stop.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
PROGRAM:
#include<nxp\iolpc2148.h>
void Timer0_Init(void);
int main(void)
VPBDIV = 0x01;
IO1DIR = 0xFF000000;
Timer0_Init();
while(1)
IO1PIN = 0x55000000; // LED glow in this pattern (0x55)in default ( when no interrupt )
void Timer0_Init(void)
T0PR = 12000*timer_delay;
T0MR0 = 1;
T0MCR = 3;
T0TCR = 1;
VICIntEnable = 0x10;
VICVectCntl4 = 0x20 | 4;
regVal = T0IR;
IO1PIN ^= 0xFF000000;
T0IR = regVal;
VICVectAddr = 0x0;
}
RESULT:
Thus the program for realizing the Timer peripheral in ARM by interrupt driven method was written and the
output was verified using LPC2148 kit.
AIM:
To write a program for serial transmission and reception of a character in C by polling method and
verify the output.
APPARATUS REQUIRED:
1. PC
2. LPC2148 Kit
ALGORITHM:
Step 1: Start
Step 5: Stop.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
Now observe the texts/message in hyper terminal, it should display Enter the Data: now press any
key on the computer keyboard, you should see the corresponding letters in the Hyper Terminal.
i.e. When you will press the key the corresponding data will be received by the LPC2148 board and
the same will be transmitted back by the LPC2148 board to the Hyper Terminal.
PROGRAM:
#include<nxp/iolpc2148.h>
PINSEL0=0X00000005;
VPBDIV=0X01;
U0LCR=0X80;
U0LCR=0X03;
}
char serialrx(void) // Function to receive the data serially
while(!(U0LSR&0x01));
rxdata=U0RBR;
return rxdata;
while(!(U0LSR&0x20));
U0RBR=txdata;
void main()
while(1)
for(i=0;msg[i]!='\0';i++)
}
RESULT:
Thus the program for serial transmission and reception of a character in C by polling method was written and
the output was verified.
AIM:
To write a program for serial transmission and reception of a character in C by interrupt method and
verify the output.
APPARATUS REQUIRED:
1. PC
2. LPC2148 Kit
ALGORITHM:
Step 1: Start
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
Now observe the texts/message in hyper terminal, it should display Enter the Data: now press any
key on the computer keyboard, you should see the corresponding letters in the Hyper Terminal.
i.e. When you will press the key the corresponding data will be received by the LPC2148 board and
the same will be transmitted back by the LPC2148 board to the Hyper Terminal.
PROGRAM:
#include <NXP/iolpc2148.h>
#include <stdio.h>
void main(void)
for(int i=0;msg[i]!='\0';i++)
while(1)
IO1PIN = 0x55000000;
int temp,buf;
buf=U0RBR; // Receiving the data from RxD pin ( from the key-board.)
U0LCR=0X80;
U0LCR=0X03;
PLLFEED=0xAA;
PLLFEED=0x55;
}
RESULT:
Thus the program for serial transmission and reception of a character in C by polling method was written and
the output was verified.
AIM:
To write a program for displaying the alpha numeric characters in 2x16 LCD display and verify the
output using LPC2148 kit.
APPARATUS REQUIRED:
1. PC
2. LPC2148 Kit
Step 1: Start
Step 6: Stop.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
PROGRAM:
#include<nxp\iolpc2148.h>
#define EN 0x800
#define RW 0X200
#define RS 0x100
void delay(void)
unsigned int i;
for(i=0;i<0x1fff;i++);
void EN_Pulse(void)
IO0SET = EN ;
delay();
IO0CLR = EN ;
IO1PIN = addr<<16;
IO0CLR = RS;
EN_Pulse();
IO1PIN = data<<16;
IO0SET = RS;
EN_Pulse();
void lcd_initialize(void)
send_cmd(0X38); delay();
send_cmd(0X0F); delay();
send_cmd(0X01); delay();
send_cmd(0X06); delay();
send_cmd(0X80); delay();
int main(void)
IO0DIR = 0x00000F00;
IO1DIR = 0x00FF0000;
IO0CLR = RW;
lcd_initialize();
for(j=0;j<1;j++)
for(i=0;i<16;i++)
send_cmd(line1+i); delay();
send_data(alphabets[i]); delay();
for(i=0;i<16;i++)
send_cmd(line2+i); delay();
send_data(numbers[i]); delay();
}
}
RESULT:
Thus the program for displaying the alpha numeric characters in 2x16 LCD display was written and the output
was verified.
AIM:
To write a program for converting the hexadecimal value to decimal value and also display the same
in LCD display.
APPARATUS REQUIRED:
1. PC
2. LPC2148 Kit
3. Serial port cable & power cable.
ALGORITHM:
Step 1: Start
Step 7: Stop.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
#include<nxp\iolpc2148.h>
#define EN 0x800
#define RW 0X200
#define RS 0x100
void delay(void)
unsigned int i;
for(i=0;i<0x1fff;i++);
void EN_Pulse(void)
IO0SET = EN;
delay();
IO0CLR = EN;
IO1PIN = addr<<16;
IO1PIN = data<<16;
void lcd_initialize(void)
send_cmd(0X38); delay();
send_cmd(0X0F); delay();
send_cmd(0X01); delay();
send_cmd(0X06); delay();
send_cmd(0X80); delay();
}
int main(void)
int num,i,d1,d2,d3;
IO0DIR = 0x00000F00;
IO1DIR = 0x00FF0000;
IO0CLR = RW;
lcd_initialize();
num = 0xFF;
d1 = num % 10;
d2 = num % 10;
d3 = num;
send_cmd(0x80); delay();
for(i=0;i<=15; i++)
send_data(display[i]);
send_data(d3+48); delay();
send_data(d2+48); delay();
send_data(d1+48); delay();
while(1)
}
}
RESULT:
Thus the program for hexadecimal to decimal conversion was written and the output was verified.
AIM:
To write a program for accessing the ADC value from ARM processor and also display the same in
LCD display.
APPARATUS REQUIRED:
1. PC
2. LPC2148 Kit
ALGORITHM:
Step 1: Start
Step 5: Set the control register value for clock frequency and bits.
Step 7: Stop.
PROCEDURE:
Compile, Debug & Simulate the above code in IAR, and see the output in register view window.
Follow to Steps given below to see/verify the output :
#include<nxp\iolpc2148.h>
#define EN 0x800
#define RW 0X200
#define RS 0x100
unsigned int i;
for(i=0;i<0x1fff;i++);
void EN_Pulse(void)
IO0SET = EN ;
delay();
IO0CLR = EN ;
IO1PIN = addr<<16;
IO1PIN = data<<16;
void lcd_initialize(void)
send_cmd(0X38); delay();
send_cmd(0X0F); delay();
send_cmd(0X01); delay();
send_cmd(0X06); delay();
send_cmd(0X80); delay();
}
int main(void)
int num,i,d1,d2,d3,d4;
IO0DIR = 0x00000F00;
IO1DIR = 0x00FF0000;
IO0CLR = RW;
AD0CR |= START;
lcd_initialize();
send_cmd(0x80); delay();
for(i=0;i<=15; i++)
send_data(display[i]);
while(1)
do
Val = AD0GDR;
}
while ((Val & DONE) == 0);
num = Val;
d1 = num % 10;
d2 = num % 10;
d3 = num % 10;
d4 = num;
send_data(d4+48); delay();
send_data(d3+48); delay();
send_data(d2+48); delay();
send_data(d1+48); delay();
}}
RESULT:
Thus the program for accessing the ADC value from ARM processor was written and the output was verified
in LCD display.
869; RANGANATHAN POLYTECHNIC COLLEGE
COIMBATORE
(L Scheme)
LECTURER/ECE
COIMBATORE.