Embedded Lab Manual Final
Embedded Lab Manual Final
Engineering
Aim:
To Write an Embedded C Program to interface the 8 bit Led with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
LED7
R11
P1.29
LED6
R12
P1.28
LED5
R13
P1.27
LED4
R14
P1.26
LED3
R15
P1.25
LED2
R16
P1.24
LED1
z
Start
Result:
Thus the Embedded C program to interface LED Interface with LPC2148 has been tested
successfully.
Ex. No: 1 A) Switch Interface
Aim:
To Write an Embedded C Program to interface the 8 bit Switch with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include<lpc214x.h>
/*void delay(void)
{
unsigned int i=0xffffff;
while(i--)
}
*/
unsigned int num;
int main(void)
{
PINSEL2=0X00;
IODIR1=0XFF00FFFF;
IOSET1=0XFF000000;
while(1)
{
num=IOPIN1&0X00FF0000;
num=num<<8;
IOCLR1=0XFF<<24;
IOSET1=num;
}
}
Switch Interface Diagram VCC
P1.16
R1 SW8
1 2
P1.17
R2 SW7
1 2
R5 SW5
1 2
R6 SW4
1 2
P1.21
R4 SW3
1 2
P1.22
R7 SW2
1 2
P1.23
R8 SW1
1 2
Start
Result:
Thus the Embedded C program to interface Switch Interface with LPC2148 has been tested
successfully.
Ex. No: 2 A) Buzzer Interface
Aim:
To Write an Embedded C Program to interface the 8 bit Buzzer Interface with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include <LPC214X.H>
#define BUZ 1<<31 //BUZZER IS INTERFACED WITH P0.31
unsigned int del,del1,del2;
void delay(unsigned int i)
{
while(i--);
}
int main(void)
while(1)
} //REPEAT
}
Buzzer Interface Diagram
+5V
LS1
2
BUZZER
R54
PNP BCE
BUZZER
Q9
P0.31
Start
Set the O/P port value high, now buzzer is in OFF state
Call Delay
Call Delay
Result:
Thus the Embedded C program to interface Buzzer Interface with LPC2148 has been tested
successfully.
Ex. No: 2 B) Relay Interface
Aim:
To Write an Embedded C Program to interface the 8 bit Relay Interface with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include <LPC214X.H>
//ASSIGN P0.30 IS RELAY INTERFACE PIN
#define relay 1<<30
// DELAY SUBROUTINE
//----------------------------------
void DELAY(void)
{
unsigned int i;
i=0xffffff;
while(i--);
}
//----------------------------------
//----------------------------------
//MAIN PROGRAM STARTS HERE
int main(void)
{
IODIR0=1<<30;
while(1) //INFINITE LOOP
{
IOSET0=1<<30; //SWITCH OFF RELAY
DELAY(); //CALL DELAY
IOCLR0=1<<30; //SWITCH ON RELAY
DELAY(); //CALL DELAY
} //REPEAT
}
Relay Interface Diagram
+5V
NC +5V +3V
5
R30
3
COM
4
D15
1
NO
R28
R27
2
LED
RELAY
1
TR1 2 P0.30
OPTO ISOLATOR-A
3
Flow Chart for Relay Interface
Start
Call Delay
Result:
Thus the Embedded C program to interface Relay Interface with LPC2148 has been tested
successfully.
Ex. No: 2 C) Stepper Motor Interface
Aim:
To Write an Embedded C Program to interface the Stepper Motor Interface with LPC 2148
Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include <LPC214X.H>
unsigned char tim,tim1_0,tim1;
unsigned int yy;
void delay(void)
{
unsigned int j;
for(j=0;j<0x7fff;j++)
{
;
}
}
void del(void)
{
unsigned int j;
for(j=0;j<0x7ffFff;j++)
{
;
}
}
//THIS FUNCTION SHIFT THE INITIALSED VARIABLE 255 TIMES LEFT IN
INTERVALS
//tim is initialised with 33h
void reverse(void)
{
unsigned int n;
n=0xff;
do (P.T.O)
{
tim1_0= (tim & 0x1)<<1 | (tim & 2)<<1 | (tim & 4)<<1 | (tim & 8)>>3; //SHIFT LEFT
tim=tim1_0;
IOCLR1 |=0XF<<16; //CLEAR PREVIOUS
DATA INPORT1
IOSET1 |=tim<<16; //LOAD SHIFTED
VALUE IN TO PORT1
delay();
delay();
}while(n--!=0);
}
//THIS FUNCTION SHIFT THE INITIALSED VARIABLE 255 TIMES right IN INTERVALS
//tim is initialised with 33h
void forward(void)
{
unsigned int n;
n=0xff;
tim1_0=0;
do
{
tim1_0= (tim & 0x8)>>1 | (tim & 4)>>1 | (tim & 2)>>1 | (tim & 1)<<3; //shift right
tim=tim1_0;
IOCLR1 |=0XF<<16; //clear previous value in port1
IOSET1 |=tim<<16; //load new value
delay();
delay();
}while(n--!=0); //wait until 255 count
}
int main(void)
{
IODIR1=0XF<<16; //configure stepper moto port as output
tim=0X33; //load initial value in tim
while(1)
{
reverse(); //call reverse
del();
//pause
forward(); //call forward
del();
//pause
}
}
Stepper Motor Interface Diagram
+5V
+5V +5V
R32
R31
R23
R19
A C
D16
D17
P1.19 1 2 TR5 P1.17 5 6 TR3
R18 R22
7407 7407
TIP33
TIP4
R6 R6 T I P 42 2 T IP3
TIP4 TIP2
1
D3
R17
D9 +5V
D4
D10 1
STEPPER
2
D5 3
D11 4
5
6
+5V
+5V +5V
R35
R36
R25
R21
B D
P1.18 3 4 P1.16 9 8 TR2
TR4
D19
D18
R20 R24
7407
7407
R26
R6
TIP23
TIP1
TIP3 TIP1 T IP1 2 2 T IP2
D12
1
D6
R37
D7 D13
D8 D14
Start
O/P ports 16 & 17 are cleared & port 8 & 9 are high
Result:
Thus the Embedded C program to interface Stepper Motor Interface with LPC2148 has been
tested successfully.
Ex. No: 3 External Interrupt
Aim:
To Write an Embedded C Program to interface the External Interrupt with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include <LPC214X.H>
#include "lcd.h"
unsigned char ll;
#define EINT1 0XC0 //pnisel value for eint1
//unsigned char ascii[]="0123456789ABCDEF";
unsigned int count,temp;
unsigned char dig0,dig1,dig2,dig3,dig4;
void del(void)
{
unsigned int i;
for(i=0;i<0xfffff;i++)
{
;
}
}
//external interrupt ISR
void isr(void) __irq
{
del(); //CALL DELAY
EXTINT =0x2; //CLEAR EINT1 INTERRUPT FLAG
count++; //UPDATE COUNT VALUE
VICVectAddr=0XFF; //MODIFY VECT ADDR REGISTER VALUE
}
//HEX TO BCD
void hex_bcd(long long a)
{
if(a>9)
{
dig4=a/10000; //REATIN QUOTIENT
temp=(a%10000); //REMINDER
dig3=temp/1000;
temp=(temp%1000);
dig2=temp/100;
temp=(temp%100);
dig1=temp/10;
dig0=temp%10;
}
else
{
dig4=dig3=dig2=dig1=0; //ALL DIGIT BUT DIG0 IS 0
dig0=a;
}
}
int main(void)
{
LCD_SETUP(); //CALL LCD SETUP
DISP(0," LPC2148 "); //DISPLAY MESSAGE IN ROW 0
DISP(1, "EINT2:"); //DISPLAY EINT1 AT ROW2
count=0; //INITIALIZE COUNT
PINSEL0 |=EINT1; //CONFIGURE P0.3 AS EINT1
EXTMODE=0x2; //EINT1 EDGE SENSITIVE
EXTPOLAR =0x0; //FOLLING ENGE
VICIntSelect =0<<15; //SELECT EINT1 AS IRQ TYPE
VICIntEnable =1<<15; //ENABLE EINT1
VICVectAddr0 =(unsigned long) isr; //LOAD ISR ADDRESS TO SLOT0 REG
VICVectCntl0 =0x20 | 15; //ENABLE SLOT0 INT
while(1)
{
hex_bcd(count); //CONVER COUNT IN TO BCD
CMD_WRITE(0XC6); //SELECT ROW0 6TH CHR
DATA_WRITE(ascii[dig4]); //DISLAY MSD
DATA_WRITE(ascii[dig3]);
DATA_WRITE(ascii[dig2]);
DATA_WRITE(ascii[dig1]);
DATA_WRITE(ascii[dig0]); //DISPLAY LSD
delay(); //WAIT
} //REPEAT
}
Stepper External Interrupt Diagram
VCC
R41
EINT
P0.3/EINT 1 2
Start
Output:
It will count the External applied pulse & Display in the LED interface Board
Result:
Thus the Embedded C program to interface External Interrupt with LPC2148 has been tested
successfully.
Ex. No: 4 Timer Counter
Aim:
To Write an Embedded C Program to interface the Timer Program with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include <LPC214X.H>
//#include "lcd.h"
unsigned char
seg[]={0x40,0xf9,0xa4,0xb0,0x19,0x12,0x2,0xf8,00,0x10,0x8,0x3,0x46,0x21,0x6,0xe};
unsigned int COUNT,ch,temp;
unsigned char dig0,dig1,dig2,dig3,dig4;
void timer(void) __irq
{
unsigned char tmtcnt=0;
T0IR=1;
VICVectAddr=0xff;
Timer_Loop:
if(tmtcnt++ !=0x5)
goto Timer_Loop;
COUNT++;
if(COUNT<=9)
{
IOCLR0=0XFF<<4;
IOSET0=seg[COUNT&0xf]<<4;
}
else
{
COUNT=0;
}
}
// void hex_bcd(long long a)
//{
//if(a>9)
//{
//dig4=a/10000; //REATIN QUOTIENT
//temp=(a%10000); //REMINDER
//dig3=temp/1000;
//temp=(temp%1000);
//dig2=temp/100;
//temp=(temp%100);
//dig1=temp/10;
//dig0=temp%10;
//}
//else
//{
// dig4=dig3=dig2=dig1=0; //ALL DIGIT BUT DIG0 IS 0
// dig0=a;
//}
//}
void timer_init(void)
{
VPBDIV=0X1;
T0MR0=(5000000000/83);
T0MCR=0X3;
VICIntSelect =0<<4; //SELECT EINT1 AS IRQ TYPE
VICIntEnable =1<<4; //ENABLE EINT1
VICVectAddr0 =(unsigned long) timer; //LOAD ISR ADDRESS TO SLOT0 REG
Start
Output:
It will count the peripheral clock & display the digital value in LED Switch interface Card
Result:
Thus the Embedded C program to interface Timer Counter with LPC2148 has been tested
successfully.
Ex. No: 5 7 Segment Display
Aim:
To Write an Embedded C Program to interface the 7 Segment Display with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include <LPC214X.H>
unsigned char seg[]={0x3f,0x6,0x5b,0x4f,0x66,0x6d,0x7d,0x7,0x7f,0x67,0x77,0x7c,0x39,0x5e,0x79,0x71};
//unsigned char
seg[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x98,0x88,0x83,0xC6,0xA1,0x86,0x8E};
unsigned char dig[]={0XFE,0XFD,0xfB,0xf7}; //digit select code
unsigned char m[]={0,1,2,3}; //DIGIT ARRAY DIGIT TO BE
DISPLAYED
#define dig_addr 0x78 //0x48 or 0x78
#define seg_addr 0x70
#define start 5 //START CONDITION OF I2C
#define stop 4 //STOP CONDITION
#define si 3 //SERIAL INTERRUPT FLAG
#define ack 2 //ACK BIT
unsigned char check,dg;
void delay(void)
{ unsigned int jk;
for(jk=0;jk<0x3fF;jk++)
{
;
}
}
void disp(unsigned char address,unsigned char dat)
{
switch(I2C0STAT) //READ I2C STATUS CODE
{
case 0x8: //IF IT IS=0X8 PROCEED, IF NOT GOTO NEXT
CASE
I2C0DAT=address; //LOAD ADDRESS OF SLAVE DEVICE
I2C0CONCLR=1<<start; //CLEAR START CONDITION
break; //BREAK
case 0x18: //IF STATUS CODE =0X18,PROCEED,IF NOT GOTO NEXT CASE
I2C0DAT=dat; //SEND DATA TO SLAVE
break; //BREAK
case 0x28: //IF STATUS CODE =0X28,PROCEED,IF NOT GOTO NEXT CASE
I2C0CONSET=0X10; //SEND STOP CONDITION
delay(); //WAIT
check=0x55;
break; //BREAK
default : //DEFAULT
break;
}
I2C0CONCLR=0X8; //CLEAR SERIAL INTERRUPT FLAG
}
void i2c_init(void)
{
PINSEL0=0X50; //CONFIGURE I2C PORT
I2C0CONCLR=0X6C; //CLEAR CONSET REGISTER
I2C0CONSET=0X40; //ENABLE I2C0 PORT
I2C0SCLH=16; //LOAD ONTIME OF SERIAL CLOCK
I2C0SCLL=14; //LOAD OFF TIME OF SERIAL CLOCK
}
/*************************
DESCRIPTION : SEND START CONDION TO I2C MODULE AND CALL DISP.WAIT UNTIL
SUCCESSFUL WRITE
*****************/
void ddisp(unsigned char address,unsigned char dat)
{
check=0xaa; //check id=0xaa
I2C0CONSET=0X60; //send start conditon
do
{
disp(address,dat); //call disp
}while(check==0xaa); //WAIT UNTIL SUCCESSFUL WRITE OF I2C VALUE
}
int main(void)
{
i2c_init(); //CALL I2C INIT
dg=0; //DIGIT SELECT VARIABLE=0
while(1)
{
ddisp(dig_addr,0xff); //CALL DDISP TO BLANK DISPLAY
delay(); //MUX DELAY
ddisp(seg_addr,~seg[m[dg]]); //CALL DDISP FOR SEGMENT VALUE (COMPLEMENT)LOAD
delay(); //MUX DELAY
ddisp(dig_addr,dig[dg]); //CALL DDISP ENABLE DIGIT
if(dg++>3) //IS ALL THE DIGITS REFRESHED?
{
dg=0; //IF YES DG=0;
}
}
}
Diagram for 7 segment Display
+3V +3V
P0.4 RA1 A1 B1
COM1
A B
A
B
F
P0.5 RB1
10
9
8
7
6
+3V +3V
SEVEN SEGMENT
RC1 C1 D1
a
b
f
cm
P0.6
C D
P0.7 RD1
SEVEN SEGMENT
+3V +3V
P0.8 RE1 E1 F1
dp
E F
e
d
3
c
P0.9 RF1
E 1
D 2
COM13
C 4
H 5
+3V
P0.10 RG1 G1
G
R5
Start
Increment K
Output:
Result:
Thus the Embedded C program to interface 7 Segment Display with LPC2148 has been tested
successfully.
Ex. No: 6 PWM Signals
Aim:
To Write an Embedded C Program to interface the PWM Signals with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include <LPC214X.H>
unsigned int op1,op2;
void delay(void)
{
unsigned int h;
h=0xf;
while(h--);
}
void delay1(void)
{
unsigned int h;
h=0xfffff;
while(h--);
}
int main(void)
{
PINSEL0=2<<0; //STEP 1 SELECT P0.0 AS PWM1
//STEP 2
PWMPC=0;
PWMPR=0;
//STEP 3 CONFIGURE PWMMR0
//STEP 4 LOAD PWM PERIOD TO PWMMR0 TO RESET ON MATCH & INT
PWMMCR=0X3;
#define PWM_PERIOD 1000000
PWMMR0=PWM_PERIOD;
//STEP 5 LOAD ONTIME =100 TO PWMR2
#define ON_TIME 5000
op1= ON_TIME;
PWMMR1=ON_TIME;
//STEP 6 LATCH PWMR0 VALUE AND PWMMR2 VALUE
PWMLER = 1<< 1; // | 1<<4;
//STEP 7 SELECT PWM1 IN SINGLE EDGE MODE AND ENABLE
PWMPCR =1<<9; //0<<4 | 1 <<12;
PWMTCR=0X9; //STEP 8 START PWMTC
op2=0; //STEP 9 STOP
while (1)
{
if(op2==0)
{
op1++;
}
if(op2==1)
{
op1--;
}
delay();
PWMMR1 = op1;
PWMLER = 1<<1;
if(op1>PWM_PERIOD)
{
op2=1;
delay1();
delay1();
delay1();
}
if(op1< ON_TIME)
{
op2=0;
delay1();
delay1();
delay1();
}
}
}
Flow Chart for PWM Signals
Start
Output:
Result:
Thus the Embedded C program to interface PWM Signals with LPC2148 has been tested
successfully.
Ex. No: 7 Displaying a Message in a 2 Line X16 Characters LCD
Aim:
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include <lpc214x.h>
#include <string.h>
void delay(void) // delay routine
{
unsigned int i;
i = 0xfff:
While (i--);
}
void write(unsigned char data)
{
IOSET0 = data <<16; // data is shifted left by 16 bits for sending to data bits (P0.23 P0.16)
delay(); // delay is called
IOSET1 = 1 << 31 // enable bit is set to 1
delay(); // delay is called
IOCLR1 = 1 << 31; // enable bit is made to 0
delay(); // delay is called
IOCLR0 = data <<16; // data lines are cleared
}
void cmd_write(unsigned char data)
{
IOCLR1 = 1 << 30; // make RS as 0
IOCLR1 = 1 <<31; // make enable bit as 0
write(data); // write routine is called
}
}
void lcd_init()
{
cmd_write(0x38); // 5/8 matrix and 8 bit data
cmd_write(0xe); // first byte of the initialization sequence
cmd_write(0x1); // clear the display
cmd_write(0x6); // the cursor moves right when a data is entered
}
void disp(unsigned char *msg) // display message routine, * denotes the address pointer of the msg array
{
unsigned int i,j;
J = strlen(msg); // function to find the length of the message
for (i = 0; i<j; i ++) // for the string length, for loop is repeated
{
data_write (msg[i]); // each character is written }
}
int main(void) // main program
{
PINSEL1 = 0 ; // P0.16 to P0.31 are I/O
IODIR0 = 0xff << 16; // P0.16 to P0.23 are output lines (data lines)
PINSEL2 = 0; // P1 is I/O
IODIR1 = 0x3 <<30; // make P1.30 and P1.31 as output lines
lcd_init(); // LCD initialization routine is called
delay(); // delay routine is called
cmd_write(0x80); // cursor is in I row and I column
P.T.O
Start
Initialize the cursor in 1st Row Send a Command to make right when data
& in 1st Column is entered
Delay Routine
Move the cursor into 2nd Row
& 1st Row
Output:
LCD Display
Welcome to Electronics Dept
Result:
Thus the Embedded c Program to Displaying a Message in a 2 Line X16 Characters LCD with
LPC2148 has been tested successfully.
Ex. No: 8 Transmission from kit & Reception from PC using serial port
Aim:
To Write an Embedded C Program to interface the Transmission from kit & Reception from
PC using serial port with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include <lpc214x.h>
#include <string.h> // header for string function
#define pclk 60000000; // using Phase Lock Loop, 12 MHz frequency is multiplied
// by 5 and 60 MHz is obtained as chip clock. 60 MHz is defined
unsigned int baud_value
unsigned char val;
void uart0_init(unsigned int baud_rate)//uart0_init routine; parameter baud_rate is to be passed
{ PINSEL0 = 0x5; // P0.0 and P0.1 are configured as TXD and RXD
U0LCR = 0x83; // Divisor Latch Access Bit (D7) should be 1
// for 8 bit data, no parity, stop bit 1, bit 0 and 1 should be 1
baud_value = (pclk/16/baud_rate);// baud_value is 16 bit no. It is obtained by this formula
U0DLM = baud_value/256; // Higher order byte of baud_value
U0DLL =baud_value%256; // Lower order byte of buad_value
U0LCR = 0x3; // after accessing the divisor, DLAB bit is to be made as 0
U0FCR = 0x07; // FIFO buffer register is enabled with reset
}
void feed(void) // routine to be written whenever PLL registers are modified
{ PLL0FEED = 0xaa; // feed sequence 1
PLL0FEED = 0x55; //feed sequence 2
}
void pll_init(void)
{ PLL0CFG = 0x04; //PLL0CFG MSEL value is 4 to get multiply by 5
feed(); // feed sequence routine is executed
PLL0CON = 0x01; // PLL Enable bit is set
feed(); // feed sequence routine is executed
while(! (PLL0STAT & 0x0400));// after writing in the registers, wait till PLL Lock
PLL0CON = 0x3; // thereafter, the PLL connect signal is given, 0 bit and 1 bit are 1
feed(); // feed sequence routine is executed
VPDIV = 0x1; // PCLK = CCLK = 60 MHz
}
unsigned char receive(void)
{ while(! (U0LSR & 0x01)); // 0th bit in Line Status Reg. receive data ready
return (U0RBR); // the data in Receive Buffer register is returned
}
void transmit (unsigned char ch)
{ while(! (U0LSR & 1<<5)); // 5th bit in Line Status Reg. transmit hold reg. empty
U0THR = ch; // when it is empty, new character to transmit is placed in the reg.
}
void transstring (unsigned char *msg)
{ unsigned int i,l;
l = strlen(msg); // length of the string
for (i = 0; i<l; i++);
{ while (! (U0LSR & 1 <<5));// each character is sent from the array and it is transmitted
U0THR = msg[i];
}
transmit(0xd); // carriage return character
transmit(0xa); // line feed character
}
int main(void)
{ pll_init(); // pll_init routine is executed
uart0_init(9600); // uart0_init routine is executed with 9600 as baud rate
do
{ val = receive(); //after initialization, it is waiting for the data to be received
if (val == 1) // if the data received from the keyboard is 1.
{ transstring(Welcome );// the content of this string is transmitted
}
if (val == 2) // if the received data is 2, then
{ transstring(Electronics Dept.);// the content of this string is transmitted
}
if (val = 3) // if the received data is 3, then
{ transstring(Good bye); // the content of this string is transmitted
}
} while (val ! = 3); // this do loop is repeated till the received data is not 3
while(1); // idling
}
Flow Chart for Displaying a Message in a 2 Line X16 Characters LCD
Start
LCD Initialize Routine
PLL Initialize routine
called
Configure the PLL to multiply by 5
Output:
1 Welcome
2 Electronics Department
3 Good bye (& come out of loop)
Result:
Thus the Embedded c Program to Transmission from kit & Reception from PC using serial
port with LPC2148 has been tested successfully.
Ex. No:9 Program for 4X4 Matrix Keyboard Interface
Aim:
To Write an Embedded C Program to interface the Program for 4X4 Matrix Keyboard
Interface with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include <LPC214X.H>
#define ROW0 1<<0 //ROW0 ASSIGNED WITH P0.0
#define ROW1 1<<1 //ROW1 ASSIGNED WITH P0.1
#define ROW2 1<<2 //ROW2 ASSIGNED WITH P0.2
#define ROW3 1<<3 //ROW3 ASSIGNED WITH P0.3
#define CLM0 1<<25 //CLM0 ASSIGNED WITH P0.25
#define CLM1 1<<12 //CLM1 ASSIGNED WITH P0.12
#define CLM2 1<<13 //CLM2 ASSIGNED WITH P0.13
#define CLM3 1<<15 //CLM3 ASSIGNED WITH P0.15
const clm0_lookup[]={0,0,0,0,0,0,0,0xC,0,0,0,0x8,0,4,0,0}; //COLUM0 KEY LOOKUP TABLE
const clm1_lookup[]={0,0,0,0,0,0,0,0xD,0,0,0,0x9,0,5,1,0}; //COLUM1 KEY LOOKUP TABLE
const clm3_lookup[]={0,0,0,0,0,0,0,0xF,0,0,0,0xB,0,7,3,0}; //COLUM2 KEY LOOKUP TABLE
const clm2_lookup[]={0,0,0,0,0,0,0,0xE,0,0,0,0xA,0,6,2,0}; //COLUM3 KEY LOOKUP TABLE
unsigned char seg[]={0x40,0xf9,0xa4,0xb0,0x19,0x12,0x2,0xf8,00,0x10,0x8,0x3,0x46,0x21,0x6,0xe};//SEGMENT
LOOKUP TABLE
#define buz 1<<31; //BUZZER PIN
unsigned char key_buf,temp,temp1; //8 BIT VARIABLES
void delay(void)
{
unsigned int i;
i=0xffffff;
while(i--);
}
unsigned char key_scan(unsigned int clm)
{
//clear previous value at colum port
IOCLR0=CLM0;
IOCLR0=CLM1;
IOCLR0=CLM2;
IOCLR0=CLM3;
//set all colum port pin
IOSET0=CLM0;
IOSET0=CLM1;
IOSET0=CLM2;
IOSET0=CLM3;
IOCLR0=clm; //clear the desired colum pin
if((temp=IOPIN0 & 0XF) !=0XF) //read port0 status in temp
{
key_buf=temp; //load status in to key_buf if any key deppressed
}
else
{
key_buf=0xff; //if no key deppressed load ff in to key_buf
}
return(key_buf); //return the key_buf
}
int main(void)
{
PINSEL0=0;
//configure all pin of port0 as gpio
IODIR0=0XFFFFFFF0 ; //configure p0.0 to p0.3 as input
IOSET0=1<<30; //switch off RELAY
IOSET0=0X7F<<4; //disable segments
IOSET0=1<<31; //SWITCH OFF BUZZER
while(1)
{
IOSET0=1<<31; //SWITCH OFF BUZZER
if((temp1=key_scan(CLM0)) !=0XFF) //IF COLUM0 SCAN VALUE IS NOT 0XFF ENTER
{
temp1=clm0_lookup[temp1]; // TEMP1= KEY NUMBER FROM LOOKUP
goto last; // SKIP OFF FROM SCANING
}
if((temp1=key_scan(CLM1)) !=0XFF)
{ //IF COLUM1 SCAN VALUE IS NOT 0XFF ENTER
temp1=clm1_lookup[temp1];
goto last; // SKIP OFF FROM SCANING
}
if((temp1=key_scan(CLM2)) !=0XFF) //IF COLUM2 SCAN VALUE IS NOT 0XFF ENTER
{
temp1=clm2_lookup[temp1];
goto last; // SKIP OFF FROM SCANING
}
if((temp1=key_scan(CLM3)) !=0XFF) //IF COLUM3 SCAN VALUE IS NOT 0XFF ENTER
{
temp1=clm3_lookup[temp1];
}
IOSET0=1<<31; //BUZZER OFF
last:
if(temp1!=0xff) //IF TEMP1=0XFF SKIP THI LOOP
{
IOCLR0=1<<31; //IF TEMP1 IS NOT =0XFF SWITCH ON BEEP
while((IOPIN0 & 0XF) !=0XF); //DEBOUNZE //IF THE SWITCH STILL PRESSED REMAIN HERE
IOCLR0=0XFF<<4; //CLEAR COLUM VALUE
IOSET0=seg[temp1 & 0xf]<<4; //DISPLAY DEPRESSED VALUE IN SEGMENT DISPLAY
IOSET0=1<<31; //SWITCH OFF BEEP
}
}
}
Flow Chart for Program for 4X4 Matrix Keyboard Interface
Start
Configure P0.0 to
P0.15 as I/P pins &
O/P pins
If any
key is
pressed
Check the Column 1 Clear the column value & Display the dipressed
value in the Display
If any key
is pressed
If any
key is
pressed If any
key is
pressed
Result:
Thus the Embedded c program to interface the 4X4 Matrix keyboard with LPC2148 has been
tested successfully.
Ex. No: 10 A) Analog to Digital Convertor
Aim:
To Write an Embedded C Program to interface the Analog to Digital Convertor with LPC
2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include <LPC214X.H>
#include "lcd.h"
#define AD0_2_PINSEL 1<<26 //AD0.2 PINSEL VALUE
Start
Select AD0.2 & start the A to D
conversion through global start
Configure AD0.2 register
as I/P through
PINSEL & set 2nd
bit is 1 to move A
to D convert Move the data register value to Val
operational
Configure the port 1 pins as I/O
& assign those pins as O/P pins
through I/O dir and initialize
clear all the LEDS If 31st
pin is
1
Output:
Equivalent digital value for analog value will display in LED switch interface according to the
applied analog voltage.
Result:
Thus the Embedded C program to interface Analog to Digital converter with LPC2148 has
been tested successfully.
Ex. No: 10 B) Thermister
Aim:
To Write an Embedded C Program to interface the Thermister with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
int main(void)
{
PINSEL1=AD0_1_PINSEL;
//CONFIGURE P0.28 AS AD0.1
AD0CR=clkdiv | burst | clks | pdn |start |edge; // CONFIGURE AD0.1 IN SOFTWARE MODE
LCD_SETUP(); //CALL LCD SETUP
DISP(0,"TEMP=");
while(1)
{
adc_scan(); //CALL ADC_SCAN
val1=(val1*322)/100; //RESOLUTION VREF/1024
dig3=val1/1000; //HEX TO BCD
temp0=val1%1000;
dig2=temp0/100;
temp0=temp0%100;
dig1=temp0/10;
dig0=temp0%10;
CMD_WRITE(0X8A); //DISPLAY FROM 10TH CHR OF ROW1
DATA_WRITE(ascii[dig3]);
DATA_WRITE(ascii[dig2]);
DATA_WRITE(ascii[dig1]);
DATA_WRITE('.');
DATA_WRITE(ascii[dig0]);
DATA_WRITE('C');
delay1();
}
}
Flow Chart for Thermister
Start
Select AD0.2 & start the A to D
conversion through global start
Configure AD0.2 register
as I/P through
PINSEL & set 2nd
bit is 1 to move A
to D convert Move the data register value to Val
operational
Configure the port 1 pins as I/O
& assign those pins as O/P pins
through I/O dir and initialize
clear all the LEDS If 31st
pin is
1
Output:
Equivalent digital value will be displayed in the LED Switch interface board according to the
received temperature & Thermister.
Result:
Thus the Embedded C program to interface Thermister with LPC2148 has been tested
successfully.
Ex. No: 11 Multi 7 Segment Display
Aim:
To Write an Embedded C Program to interface the Multi 7 Segment Display with LPC 2148
Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
Start
Pass display cov to display the values in dig 0 for a particular time delay
display the every incrementing values in digit zero
If Make temp = 0
Pass the display cov values to the sec dig. D is all the increment values in digit 1
If Make temp = 0
If Make temp = 0
Output:
It will count the internal clock & display the value in 6 digit 7 segment display.
Result:
Thus the Embedded C program to interface Multi 7 Segment with LPC2148 has been tested
successfully.
Ex. No: 12 Assembly Language Program
Aim:
To Write an Embedded C Program to interface the Multi 7 Segment Display with LPC 2148
Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
A) Addition
AREA PROGRAM,CODE,READONLY
ENTRY
INCLUDE LIB.H
export __main
EXPORT __use_two_region_memory
__use_two_region_memory
__main
LDR R0,=-0X4
ADD R0,R0,LSL#2
LDR R0,=0X12345678 ;OP1 HIGHER ORDER NUM
LDR R1,=0X87654321 ;OP1 LOWER ORDER NUM
LDR R2,=0X12345678 ;OP2 HIGHER ORDER NUM
LDR R3,=0X87654321 ;OP2 LOWER ORDER NUM
ADDS R5,R1,R3 ;ADD LOWER ORDER DIGIT AND STORE
IN R5
ADC R4,R0,R2 ;ADD HIGHER OREDR DIGIT AND STORE
IN R4
STOP
B STOP
END
B) Subtraction
AREA PROGRAM,CODE,READONLY
ENTRY
INCLUDE LIB.H
export __main
EXPORT __use_two_region_memory
__use_two_region_memory
__main
C) Multiplication
AREA PROGRAM,CODE,READONLY
ENTRY
INCLUDE LIB.H
export __main
EXPORT __use_two_region_memory
__use_two_region_memory
__main
AREA PROGRAM,CODE,READONLY
ENTRY
INCLUDE LIB.H
export __main
EXPORT __use_two_region_memory
__use_two_region_memory
__main
LOOP
SUBS R0,R0,R1
BMI NER0
ADD R2,R2,#1
B LOOP
NER0
ADD R0,R0,R1
STOP
B STOP
END
Result:
Thus the Assembly Language program for Addition, Subtraction, Multiplication & Division has
been tested successfully.
Ex. No: 13 I2C Serial EEPROM
Aim:
To Write an Embedded C Program to interface the I2C Serial EEPROM with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include <LPC214X.H>
#include "lcd.h"
void delay(void);
unsigned int temp;
unsigned char i,vh,var;
void epr_delay(void);
void i2c_init()
{
PINSEL0 |=0X30C00000;
I2C1CONCLR=0X6C; //CLEARING ALL FLAGS
I2C1CONSET=0X40; //ENABLE I2C
I2C1SCLH =16; //0XC;
I2C1SCLL=14; //0XD; //100KHZ
}
void def(void)
{
unsigned int i;
for(i=0;i<0xfffff;i++)
{
;
}
}
void epr_delay(void)
{
unsigned int jk;
for(jk=0;jk<0xfffF;jk++)
{
;
}
}
//THIS FUNCTION WRITES AN 8 BIT DATA TO A PARTICULR ADDRESS OF I2C EEPROM
void epr_write(unsigned char adrh,unsigned char adrl,unsigned char dat)
{
epr_delay();
I2C1CONSET=0X60; //send start conditon
epr_delay(); //wait
if((temp=I2C1STAT)==0x8)
{
I2C1DAT=0xa0; //write device address
I2C1CONCLR =0x28; //clear start,si
}
epr_delay();
if((temp=I2C1STAT)==0x18)
{
I2C1DAT=adrh; //write higher order address
I2C1CONCLR =0x8; //clear si
}
epr_delay();
if((temp=I2C1STAT)==0x28)
{
I2C1DAT=adrl; //write low byte address
I2C1CONCLR =0x8; //clear si
}
epr_delay();
if((temp=I2C1STAT)==0x28){
I2C1DAT=dat; //write data
I2C1CONCLR =0x8; //clear si
epr_delay();
}
I2C1CONSET =0x10; //send stop condition
I2C1CONCLR=0x8; //clear si
}
//THIS FUNCTIONAL CALL RETURNS AN 8BIT DATA ARTER READING A PARTICULAR ADDRESS OF
EEPROM
unsigned char epr_read(unsigned char adrh,unsigned char adrl)
{
epr_delay();
I2C1CONSET=0X60; //send start conditon
epr_delay();
if((temp=I2C1STAT)==0x8) //check return status code
{
int main(void)
{
i2c_init(); //initialise i2c for 400khz
LCD_SETUP(); //INITIALISE LCD SET UP
def();
DISP(0x0,"Serial_eeprom");
DISP(0x1,"Count:");
while(1)
{
var =epr_read(0x0,0x11); //READ DATA FROM 0011 H OF SERIAL EEPROM
CMD_WRITE(0XC6); //START DISPLAY FROM ROW0 AT 6TH CHR
DATA_WRITE(ascii[var >> 4 & 0xf]); //DISPLAY MSD OF DATA
DATA_WRITE(ascii[var & 0xf]); //DISPLAY LSD OF DATA
def();
var++; //UPDATE DATA BY 1
epr_write(0x00,0x11,var); //WRITE AT 0011H
} //REPEAT
//return 0;
}
Flow Chart for I2C Serial EEPROM
Start
Negative acknowledgement send
I2C Initialization
function
Stop condition sent
Write data
Write lower order address byte
Output:
It will count the values if we switch off the kit then ON means it will resume the count.
Result:
Thus the Embedded C program to interface I2C Serial EEPROM with LPC2148 has been tested
successfully.
Ex. No: 14 Displaying two different messages in LCD display in two lines
Aim:
To Write an Embedded C Program to interface the Displaying two different messages in LCD
display in two lines with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include "includes.h"
#include "lcd.h"
#define TASKSTART_STK_SIZE 256
#define TASK_STK_SIZE 256 /* Size of each task's stacks (# of WORDs) */
#define N_TASKS 3 /* Number of identical tasks */
OS_STK TaskStk[N_TASKS][TASK_STK_SIZE]; /* Tasks stacks */
char TaskData[N_TASKS]; /* Parameters to pass to each task */
INT8U err;
unsigned int count=0x1234;
unsigned int count1=0x5678;
void TaskStart(void *dataa); /* Function prototypes of Startup task */
void TaskSecond(void *dataa); /* Function prototypes of tasks */
void TaskThird(void *dataa);
OS_EVENT *JK=NULL;
int main (void)
{
// VPBDIV=0;
//P1.16 TO P0.22 AS OUTPU
LCD_SETUP(); //ININIALIZE LCD IN 4BIT
MODE
delay();
DISP(0x0,"COUNT:");
DISP(0x1,"COUNT1:");
JK=OSSemCreate(1);
OSInit(); /* Initialize uC/OS-II*/
OSTaskCreate(TaskStart,
(void *)0,
(OS_STK *)&TaskStk[0][TASK_STK_SIZE - 1],10);
OSTaskCreate(TaskSecond,
(void *)0,
(OS_STK *)&TaskStk[1][TASK_STK_SIZE - 1],11);
OSTaskCreate(TaskThird,
(void *)0,
(OS_STK *)&TaskStk[2][TASK_STK_SIZE - 1],12);
OSStart(); /* Start multitasking */
//for(i = 0; i <= 0x100; i ++);
}
void TaskStart (void *dataa)
{
unsigned long i = 0;
BSP_Init();
for(;;)
{
OSSemPend(JK,0,&err);
for(i = 0; i <= 0x3FFFFF; i ++); //Delay between
switching OFF LEDs
//Get Semaphore
//Ceitical section starts
CMD_WRITE(0X88);
DATA_WRITE(ascii[(count>>12) & 0xf]); //Display MSD OF COUNT
DATA_WRITE(ascii[count >>8 & 0xf]); //Display 2ND DIGIT OF COUNT
DATA_WRITE(ascii[(count>>4) & 0xf]); //Display FIRST DIGIT OF COUNT
DATA_WRITE(ascii[count & 0xf]); //Display OTH
DIGIT OF COUNT
}
void TaskSecond (void * pvdata)
{
unsigned long i = 0;
unsigned char err;
for(;;)
{
OSSemPend(JK,0,&err);
for(i = 0; i <= 0x3FFFFF; i ++); //Delay between
switching OFF LEDs
//Get Semaphore
//Ceitical section starts
CMD_WRITE(0Xc8);
DATA_WRITE(ascii[(count1>>12) & 0xf]); //Display MSD OF COUNT
DATA_WRITE(ascii[count1 >>8 & 0xf]); //Display 2ND DIGIT OF COUNT
DATA_WRITE(ascii[(count1>>4) & 0xf]); //Display FIRST DIGIT OF COUNT
DATA_WRITE(ascii[count1 & 0xf]); //Display OTH DIGIT
OF COUNT
//critical section ends here
OSSemPost(JK);
OSTimeDlyResume(12); //Kill the delay of Third
task
OSTimeDlyHMSM(0,0,0,10);
//Assign 0xf0 to the LEDs
//Kill the delay of First task
}
}
void TaskThird(void * pvdata)
{
unsigned long i = 0;
char err;
for(;;)
{
OSSemPend(JK,0,&err);
for(i = 0; i <= 0x3FFFFF; i ++);
//OSTimeDly(10);
count++;
OSSemPost(JK);
OSTimeDlyResume(10); //Kill the delay of Third
task
//Kill the delay of First
task
}
}
Flow Chart for Displaying two different message in LCD display in two lines
Start
Stop
Output:
LCD Display
Count 1234
Count 1 5678
Result:
Thus the RTOS program to Displaying two different messages in LCD display in two lines has
been tested successfully.
Ex. No: 15 Blinking two LEDS
Aim:
To Write an Embedded C Program to interface the Blinking two LEDS with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include "includes.h"
#include "Step_lcd.h"
#define TASKSTART_STK_SIZE 256
#define TASK_STK_SIZE 256 /* Size of each task's stacks (# of WORDs) */
#define N_TASKS 3 /* Number of identical tasks */
OS_STK TaskStk[N_TASKS][TASK_STK_SIZE]; /* Tasks stacks */
char TaskData[N_TASKS]; /* Parameters to pass to each task */
INT8U err;
unsigned int count=0x1234;
unsigned int count1=0x5678;
void TaskStart(void *dataa); /* Function prototypes of Startup task */
void TaskSecond(void *dataa); /* Function prototypes of tasks */
void TaskThird(void *dataa);
OS_EVENT *JK=NULL;
int main (void)
{
IODIR0=0XFF<<8;
IOSET0=0XFF<<8;
JK=OSSemCreate(1);
OSInit(); /* Initialize uC/OS-II*/
OSTaskCreate(TaskStart,
(void *)0,
(OS_STK *)&TaskStk[0][TASK_STK_SIZE - 1],10);
OSTaskCreate(TaskSecond,
(void *)0,
(OS_STK *)&TaskStk[1][TASK_STK_SIZE - 1],11);
OSTaskCreate(TaskThird,
(void *)0,
(OS_STK *)&TaskStk[2][TASK_STK_SIZE - 1],12);
OSStart(); /* Start multitasking */
}
void TaskStart (void *dataa)
{
unsigned long i = 0;
BSP_Init();
for(i = 0; i <= 0x3FFF; i ++);
while(1)
{
OSTimeDlyHMSM(0,0,0,5); //5MS DELAY
IOSET0=1<<8;
//P0.8 OFF
OSTimeDlyHMSM(0,0,0,10);
IOCLR0=1<<8;
OSTimeDlyHMSM(0,0,0,5);
}
void TaskSecond (void * pvdata)
{
unsigned long i = 0;
unsigned char err;
// for(;;)
while(1)
{
IOSET0=1<<9;
OSTimeDlyHMSM(0,0,0,20);
IOCLR0=1<<9;
OSTimeDlyHMSM(0,0,0,20);
OSTimeDlyResume(12); //Kill the delay of Third task
OSTimeDlyHMSM(0,0,0,10); //Assign 0xf0 to the LEDs
Start
Initialize OS - case
Configure BSP
Toggle LEDS
for delay xms
Toggle LEDS
Application Layer
for delay yms
multitasking
Collect the datas
from string
Stop
Output:
Two LEDS are blinking with three different tasks
Result:
Thus the RTOS program Blinking two LEDS with LPC2148 has been tested successfully.
Ex. No: 16 Transmission from KIT and reception from PC using serial
Aim:
To Write an Embedded C Program to interface the Transmission from KIT and reception
from PC using serial with LPC 2148 Kit.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include "includes.h"
#define TASKSTART_STK_SIZE 256
#define TASK_STK_SIZE 256 /* Size of each task's stacks (# of WORDs) */
#define N_TASKS 3 /* Number of identical tasks */
OS_STK TaskStk[N_TASKS][TASK_STK_SIZE]; /* Tasks stacks */
char TaskData[N_TASKS]; /* Parameters to pass to each task */
INT8U err;
void TaskStart(void *dataa); /* Function prototypes of Startup task */
void TaskSecond(void *dataa); /* Function prototypes of tasks */
void TaskThird(void *dataa);
OS_EVENT *JK=NULL;
#include <string.h>
#include<stdlib.h>
#include<stdio.h>
#define pclk 60000000
unsigned int baud_value;
//unsigned char msg[]="WELCOME TO NITTTR";
//unsigned char msg1[]="LITTLE ENDIAN";
//unsigned char msg2[]="BIG ENDIAN";
void UART0_INIT(unsigned int baud_rate)
{
PINSEL0 |=0x5;
U0LCR =0x83;
baud_value=(pclk/16)/baud_rate;
U0DLM =baud_value/256;
U0DLL=baud_value % 256;
U0LCR =0x3;
U0FCR =0x07;
}
void delay(void)
{
unsigned int i;
for(i=0;i<0xffffF;i++)
{
}
}
void feed()
{
PLL0FEED=0XAA;
PLL0FEED=0X55;
}
void PLL_INIT()
{
PLL0CFG =0X24; //MULT DEVIDER
feed();
PLL0CON=1; //ENABLE PLL
feed();
while(!(PLL0STAT & 0X0400));
PLL0CON=0X3;
feed();
MAMCR=0X2;
MAMTIM=0X4;
VPBDIV=0X1;
}
unsigned char rec(unsigned char num)
{
while(!(U0LSR & 0X01));
return(U0RBR);
}
void PUTC0(unsigned char ch)
{
while(!(U0LSR & 1<<5));
U0THR=ch;
}
void PUTS0(unsigned char *ms0)
{
unsigned int i,l;
l=strlen(ms0);
for(i=0;i<l;i++)
{
while(!(U0LSR & 0X20));
U0THR=ms0[i];
}
PUTC0(0xd);
PUTC0(0xa);
}
int main (void)
{
IODIR0=0X1<<16;
PLL_INIT();
UART0_INIT(9600);
JK=OSSemCreate(1);
OSInit(); /* Initialize uC/OS-II*/
OSTaskCreate(TaskStart,
(void *)0,
(OS_STK *)&TaskStk[0][TASK_STK_SIZE - 1],10);
OSTaskCreate(TaskSecond,
(void *)0,
(OS_STK *)&TaskStk[1][TASK_STK_SIZE - 1],11);
OSTaskCreate(TaskThird,
(void *)0,
(OS_STK *)&TaskStk[2][TASK_STK_SIZE - 1],12);
OSStart(); /* Start multitasking */
//for(i = 0; i <= 0x100; i ++);
}
void TaskStart (void *dataa)
{
unsigned long i = 0;
BSP_Init();
for(;;)
{
for(i = 0; i <= 0x3FFFFF; i ++); //Delay between switching OFF LEDs
PUTS0("WELCOME TO VASEE ELECTRONICS0\n");
Do not terminate
task
Stop
Output:
Welcome to Vasee Electronics 0
Welcome to Vasee Electronics 1
Welcome to Vasee Electronics 2
Result:
Thus the RTOS program Transmission from KIT and reception from PC using serial port has been tested
successfully
Ex. No: 17 Graphics LCD
Aim:
To Write a program.
Apparatus Required:
S. No Description Quantity
2 Adapter 1
3 RS232 Cable 1
4 Personal Computer 1
Program:
#include "LPC214X.H"
// os _stk adc_task stk [1000];
// os_stk disp_task stk [1000];
//FUNCTION DEFINITION
Void_adc_task (void *p data);
{
For (;;)
{
Read_adc ();
Os time delay (10);
}
}
Void_disp_task (void * p data)
{
For (;;)
{
Disp();
Write_xy ();
Graph_plotting();
Os_time dly (10);
}
}
Void main (void);
{
Bsp_int plsaii ();
Bsp_init ();
Pinsel 2 = 0X0000 0000;
IO0 DIR1 = 0XFFF0 7FFF;
IO1 DIR1 = 0XFFFF FFFF;
Init lcd ();
Clear_display();
For (int i=0; i<0XFFFF; i++);
For (int i=0; i<0XFF; i++);
Clear_display ();
Arm_uart0_int ();
Os_int ();
Os task create (adc_task & adc, task stk (a a a),0);
Os task create (disp_task & disp_task stk (a a a),1);
Os start ();
}
Result:
Thus the program for Temperature from LM35 interface & plot the temperature as time graph using
Graphic LCD was executed & verified.