0% found this document useful (0 votes)
29 views34 pages

VE4072-RTES-lab Manual

Uploaded by

harika183n
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views34 pages

VE4072-RTES-lab Manual

Uploaded by

harika183n
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 34

VE4072 REAL TIME EMBEDDED SYSTEMS LABORATORY

Submitted in III Semester in partial fulfillment for the award of the degree of

MASTER OF ENGINEERING

DEPARTMENT OF COMMUNICATION SYSTEMS

II Year / 3 rd SEMESTER

Name :
Register No. :
BONAFIDE CERTIFICATE

Certified that this is the bonafide record work of

Register No. of THIRD Semester, M.E VE4072

REAL TIME EMBEDDED SYSTEMS LABORATORY during the academic year 2024–

2025.

STAFF INCHARGE HEAD OF THE DEPARTMENT

Submitted for the practical examination of Bachelor of Engineering held at


SRI VENKATESWARAA COLLEGE OF TECHNOLOGY on

INTERNAL EXAMINER EXTERNAL EXAMINER


PAGE SIGNATURE
S.NO DATE NAME OF THE EXPERIMENT MARKS OF THE
NO
STAFF

1
Read input from switch and automatic
control/flash led for arm processor

2 Interfacing real time clock and serial port.

3 Interfacing eprom and interrupt

4
Working of a thread is to trace a realtime
program using rtlinux

5
Interfacing stepper motor and temperature
sensor

List of Experiments
4

1.READ INPUT FROM SWITCH AND AUTOMATIC CONTROL/FLASH LED


FOR ARM PROCESSOR
Aim

To write a C program for Switch & LED ON or OFF depending on the status of the pin.

Apparatus & Software Required

1. LPC2148 Development board.

2. Keilµ Vision 5 software.

3. Flash Magic.

4. USB cable.

5. CRO.

Theory
LEDs are based on the semiconductor diode. When the diode is forward biased (switched on),
Electrons are able to recombine with holes and energy is released in the form of light. This effect is
called electroluminescence and the color of the light is determined by the energy gap of
the semiconductor

Procedure
1. Follow the steps to create a New project

2. Type the below code and save it with the name (anyname.c)

3. Follow the steps to create a New Project to compile and build the program

4. Follow the procedures in to download your Hex code to processor using


Flash Magic Software.
5

Program:

#include <lpc214x.h>
#include <stdint.h>
int main(void)
{
//PINSEL0 = 0x00000000; /* Configuring P0.0 to P0.15 as GPIO */
/* No need for this as PINSEL0 reset value is 0x00000000 */
IO0DIR = 0x00000001; /* Make P0.0 bit as output bit, P0.1 bit as an input pin */
while(1)
{
if ( IO0PIN & (1<<1) ) /* If switch is open, pin is HIGH */
{ IO0CLR = 0x00000001; /* Turn on LED */
}
else /* If switch is closed, pin is LOW */
{
IO0SET = 0x00000001; /* Turn off LED */
}
}
}

Result :

Thus C code is generated for Switch & LED and output is verified in LED’s by Switches.
6

2. INTERFACING REAL TIME CLOCK PROGRAM AND SERIAL PORT

Aim

To develop a C-Language program for reading the RTC, convert into decimal and to
display it.
Apparatus & Software Required

1. LPC2148 Development board.

2. Keilµ Vision 5 software.

3. Flash Magic.

4. USB cable.

5. RS232 Serial cable.

Theory

The Real Time Clock (RTC) is a set of counters for measuring time when system power is on,
and optionally when it is off. It uses little power in Power-down mode. On the
LPC2141/2/4/6/8, the RTC can be clocked by a separate 32.768 KHz oscillator, or by a
programmable prescale divider based on the VPB clock. Also, the RTC is powered by its own
power supply pin,VBAT,which can be connected to a battery or to the same 3.3 V supply used
by the rest of the device.
7

Serial Communication

Serial communication takes a byte of data and transmits the 8 bits in the byte one at a time.
The advantage is that a serial port needs only one wire to transmit the 8 bits (while a parallel
port needs 8). The disadvantage is that it takes 8 times longer to transmit the data than it would
if there were 8 wires. Serial ports lower cable costs and make cables smaller.

Procedure
1. Follow the steps to create a New project
2. Type the below code and save it with the name (anyname.c)
3. Follow the steps to create a New Project to compile and build the program
4. Follow the procedures in to download your Hex code to processor using
Flash Magic Software.
8

/**************************************************************/
RTC.C
/**************************************************************/

/* Place lcd.c file into following directories C:\Keil\ARM\INC\Philips.******/


/* This program is used to interface the RTC.You can change the date and time*/
/* If you want. This Program can both Read and write data into RTC.RTC has a*/
/* Battery backup for continuous Running. ************************************/
/*
pclk = 30,000,000 Hz
PREINT = (int)(pclk/32768)-1
PREFRAC = pclk - ((PREINT+1) x 32768)
*/
#include<LPC214X.
H> #include<lcd.c>
int main()
{
unsigned int
hrs,min,sec; wait();
wait();
wait();
wait();
lcdinit();cl
rs cr(2);
printstr("SM MICRROSYSTEM",0,0);
printstr(" ARMDEVKIT ",0,1);
VPBDIV = 0x00000002; // VPB bus clock is one half of the processor
clock(cclk)
PREINT = 0x00000392; // Set RTC prescaler for 30MHz Pclk
// PREINT = (int) (30,000,000/32768(RTCcrystal))-1 = 914
PREFRAC = 0x00004380;
CIIR=0x00000001; // Enable seconds counterinterrupt
CCR=0x00000001; // Start theRTC
YEAR=2009; // Year
MONTH=11; //Month
DOM=25; // Day of month
DOY=0; // Day ofyear
DOW=0; // Day of week
HOUR=18; //Hours
MIN=30; // Minutes
SEC =30;
printstr(" ",0,1);
while(1)
{
gotoxy(0,1);hrs
= HOUR; min
= MIN; sec
= SEC;
9

split_numbers(hrs);
lcdd at(tens+0x30);
lcddat(ones+0x30);
lcddat(':');
split_numbers(min);lc
d dat(tens+0x30);

lcddat(ones+0x30);
lcddat(':');
split_numbers(sec);l
cdd at(tens+0x30);
lcddat(ones+0x30);
//lcddat(':');
}
}

RTC PROGRAM PORT DETAILS

PORT
10

SERIAL PORT PROGRAM


/**************************************************************/
/* Uart0 Initialization */

/* This is a test program to send and receive data via uart0 in theARMLPC2148 */
Development board itself
/
******************************************************************
******************
#include<LPC214x.H> /* LPC214x definitions*/
#include"uart0.h" /* contains prototypes of
driverfunctions*/

int main (void)


{
unsigned char *s1;
initserial(); /* uart0 initialization */
send_string("******************************************
**"); send_string(" SMMicrroSystem
");
send_string(" Tambaram ");
send_string(" Chennai
");
send_string("******************************************
**"); send_string("");send_string("");
send_string("This program Echos the string entered byuser.");
send_string("So,type some strings and press ENTERkey");

while(1) /* Loop forever*/


{
s1 = receive_string();
send_string(s1);
}

}
/
***********************************************************************
*************/ SERIAL PORT PROGRAM

/****************************************************************************/
/* Uart1 Initialization */
/
****************************************************************************/
#include<lpc214x.h>#inc
lude<stdio.h>
#include<stdlib.h>
#include "uart1_driver.c"
int main()
{
unsigned char *a;
//unsigned char
*w;
11
a=malloc(sizeof(1
00));
12

inituart1();
sendstring1("ABCDEFGHIJKLMNOPQRSTUVWXYZ
");
sendstring1("ABCDEFGHIJKLMNOPQRSTUVWXYZ
");
sendstring1("ABCDEFGHIJKLMNOPQRSTUVW
XYZ");
sendstring1("ABCDEFGHIJKLMNOPQRSTUVW
XYZ");
sendstring1("ABCDEFGHIJKLMNOPQRSTUVW
XYZ");
/*sendstring1(" * ");
sendstring1(" ** ");
sendstring1(" *** "); s
endstring1(" * *** "); sendstring1(" *
* * * * ");
sendstring1(" SM MICRRO ");
sendstring1(" * * * * * ");
sendstring1(" * *** "); sendstring1("
*** ");
sendstring1(" ** ");
sendstring1(" * "); */

while(1)
{
receivestring1(a);sen
d string1(a);

}
}
SERIAL PROGRAM

PORTDETAILSUART0
ARM DETAILS
P0.0 TXDO
P0.1 RXDO
UART1
ARM DETAILS
P0.8 TXD1
P0.9 RXD1

Result

The C-Language program for reading RTC and displaying it in LCD was written & output is
verified with running the RTC from a default/specified time.
13

3. INTERFACING EPROM AND INTERRUPT

Aim

To develop a C-Language program to write and read a data in EEPROM and also
to analyze its performance with the interrupt

Apparatus & Software Required

1. LPC2148 Development board.


2. Keil µVision5 software.
3. Flash Magic.
4. USB cable.

Theory
Serial-interface EEPROM’s are used in a broad spectrum of consumer, automotive,
telecommunication, medical, industrial and PC related markets. Primarily used to store
personal preference data and configuration/setup data, Serial EEPROM’s are the most flexible
type of nonvolatile memory utilized today. Compared to other NVM solutions, Serial
EEPROM devices offer a lower pin count, smaller packages, lower voltages, as well as lower
power consumption.
14

Procedure
1. Follow the steps to create a New project
2. Type the below code and save it with the name (anyname.c)
3. Follow the steps to create a New Project to compile and build the program
4. Follow the procedures in to download your Hex code to processor using
Flash Magic Software.
15

EPROM PROGRAM
/******************************************************************************/
I2C .C
/**************************************************************************/

/* This Program For I2C


Interface */
#include<LPC214x.H>
#include "lcd.c"

void InitI2C (void);


void SendI2C Address(unsigned char
Addr_S); void WriteI2C (unsigned char
Data);
void StopI2C (void);
void StartI2C (void);
#define STA 0x20
#define SIC 0x08
#define SI 0x08
#define STO 0x10
#define STAC
0x20 #define AA
0x04
void InitI2C (void)
{
I2C 0CONCLR = 0xFF;
PINSEL0 |=0x50; // Set pinouts as scl andsda
I2C 0SCLL =19; //speed at 100Khz for a VPBClockDivider = 4 at 12
MHz I2C 0SCLH =19;
I2C 0CONSET=0x40; //Active Master Mode on I2C bus
}
void SendI2C Address(unsigned char Addr_S)
{
while(I2C 0STAT!=0x08); // Wait for start to becompleted
I2C 0DAT =Addr_S; // Charge slaveAddress
I2C 0CONCLR = SIC|STAC; // Clear I2C interrupt bit to send
the data while(!( I2C 0CONSET &SI)); // wait till
statusavailable
}

unsigned char ReadI2C (void)


{
unsigned char r;
I2C 0CONCLR = SIC;
I2C 0CONSET=0x04; // clearSIC;

while(!(I2C 0CONSET&0x8)); // wait till statusavailable


r=I2C 0STAT;
wait(); // check forerror
if (r==0x50){ // look for "Data byte has been received; ACKhas
been returned" lcdcmd(0x01);
16

printstr("Read Sucess",0,0);
}

return I2C 0DAT;


}

void WriteI2C (unsigned char Data)


{
unsigned char r;
I2C 0DAT =Data; // ChargeData
I2C 0CONCLR=0x8; // SIC; Clear I2C interrupt bit to send thedata
while(!(I2C 0CONSET&0x8)); // wait till statusavailable
r=I2C 0STAT;
if (r == 0x28)
{ // look for "Data byte in S1DAT has been transmitted; ACKhas
been received" lcdcmd(0x01);
printstr("Write Sucess",0,0);
}
}
void StopI2C (void)
{
I2C 0CONCLR =
SIC; I2C
0CONSET =
STO;
while((I2C 0CONSET&STO)); // wait for Stopped busI2C
}

void StartI2C (void)


{
I2C 0CONCLR=0xFF; // clear I2C - included if User forgot to "StopI2C ()"
// else this function would hang.
I2C 0CONSET=0x40; // Active Master Mode on I2C
bus I2C 0CONSET=0x00000020; // Startcondition
}
int main()
{

unsigned char r;

wait();
wait();
wait();
wait();
lcdinit();clr
sc r(2);
printstr("SM MICRRO SYSTEM",0,0);
printstr(" ARMDEVKIT
",0,1); InitI2C ();
StartI2C ();
SendI2C Address(0xa0); // EEPROM device
17

address WriteI2C (0); // Set the control


portvalue
WriteI2C ('B');
StopI2C
();wait();
wait();
StartI2C ();
SendI2C Address(0xa0); // EEPROM device
address WriteI2C (0); // Set the control
portvalue
StopI2C ();
StartI2C ();
SendI2C Address(0xa1); // Start the
read r=ReadI2C (); // read the
result StopI2C ();
gotoxy(0,1);
split_numbers(r);
lcddat(0x30+hundreds);l
cdda t(0x30+tens);
lcddat(0x30+ones);
while(1);

}
/
*************************************************************************************
******/
LCD.C
/
*************************************************************************************
******/

#defineRS 0x00000400 /* P0.10 */


#defineCE 0x00001800 /* P1.11
*/ void clrscr(char ch); void
lcdinit(void);
void
lcdcmd(char);
void
lcddat(char);
void gotoxy(char,char); //x,y ; x-char position(0 - 16) y-line
number 0 or1 voidprintstr(char*,char,char);

//string,column(x),line(y) void wait (void);


void split_numbers(unsigned int
number); #define SET1
#define OFF0
unsigned int thousands,hundreds,tens,ones;
voidwait(void) { /* wait
function */ intd;
for (d = 0; d <100000;d++); /* only to delay for LED flashes*/
}

void lcdinit()
{
18
19

IODIR0 = 0xFFFFFFFF;
IOCLR0 =0X00000FFF;
lcdcmd(0x8);
lcdcmd(0x28);
lcdcmd(0x0c);
lcdcmd(0x06);
lcdcmd(0x01);
lcdcmd(0x0f);
wait();//(1600)
;
}
void gotoxy(char x, char y)
{
if(y == 0)
lcdcmd(0x80+x);
else
lcdcmd(0xc0+x);
}
void printstr(char *str, char x, char y)
{
char i; gotoxy(x,y);
wait();//(500);
for(i=0;str[i]!='\0';i+
+)lcddat(str[i]);
}
void lcdcmd(charcmd)
{
unsigned charLCDDAT;
LCDDAT = (cmd&0xf0); //higher
nibble IOSET0 =LCDDAT;
IOCLR0 = RS;
IOSET0 =
CE;
wait();//(100); //enablelcd
IOCLR0 = CE;
IOCLR0 = 0X00000FFF;

LCDDAT = ((cmd<<0x04)&0xf0); //lower


nibble IOSET0 =LCDDAT;
IOCLR0 = RS;
IOSET0 =
CE;
wait();//(100); //enablelcd
IOCLR0 = CE;
IOCLR0 = 0X00000FFF;
}
void lcddat(char cmd)
{
unsigned charLCDDAT;
LCDDAT = (cmd&0xf0); //higher
nibble IOSET0 =LCDDAT;
IOSET0 = RS;
IOSET0 =CE;
20

wait();//(100); //enablelcd
IOCLR0 = CE;
IOCLR0 = 0X00000FFF;
LCDDAT = ((cmd<<0x04)&0xf0); //lower
nibble IOSET0 =LCDDAT;
IOSET0 = RS;
IOSET0 =
CE;
wait();//(100); //enablelcd
IOCLR0 = CE;
IOCLR0 = 0X00000FFF;
}
void clrscr(char ch)
{
if(ch==0)
{
printstr(" ",0,0);
gotoxy(0,0);
}
else if(ch ==1)
{
printstr(" ",0,1);
gotoxy(0,1);
}
els
e
lcdcmd(0x01);
{ //delay(100);

}
}

void split_numbers(unsigned int number)


{
thousands = (number
/1000); number %=
1000;
hundreds = (number /
100); number %= 100;
tens = (number /
10); number %=
10; ones =
number ;
}

EPROM (I2C ) PROGRAM PORT SETAILS


ARM DETAILS
PO.10 RS LCD PIN
P1.11 CE LCD PIN
P0.11 SCL
P0.14 SDA
21

INTERRUPT BUZZER PROGRAM


/***************************************************************************/
ExtDriver.C
/***********************************************************************/

#include
<LPC214x.h>
void
init_VIC(void)
{
/* initialize VIC*/
VICIntEnClr

=0xffffffff;
VICVectAddr =0;
VICIntSelect =0;
}

void ExtInt_ISR(void)irq
{
//EXTINT=(1<<2); /* clear EINT2 flag by writing HIGH to corespondingbit*/
//IOCLR0 = 0x40000000; /* Trigger the relay*/
IOCLR1 = 0x400f0000; /* P1.18 Trigger the relay*/
//IOPIN1 =
0x00000000; EXTINT =
(1<<2);
VICVectAddr=0; /* Acknowledge Interrupt*/
}
void init_Interrupt(void)
{
PINSEL0=0x80000000; // select P0.15 for EINT2
VICIntEnable = (1<<16); // External interrupt
2(EINT2)
VICVectCntl0=(1<<5)|(16); // set the VIC control reg for
EINT2 VICVectAddr0 = (unsignedlong)ExtInt_ISR;
EXTMODE&=~(1<<2);// set VIC for egdse sensitive forEINT2
// EXTPOLAR = ~(1<<2); // set VIC for falling edge sensitive forEINT2
}
void init_ports(void)
{
IODIR0 =
0x40000000; IODIR1
= 0x400f0000;
IOPIN1 =
0xff010000; IOSET0
= 0x40000000;
IOSET1 = 0x400f0000;

}
/*void wait_for_turnoffRelay(void)
{
22
int val;
val=IOPIN1; // read the ports for key board input
while((~(val>>20))!=0); // wait until 1st key in the matrixkeyboard
is
pressed IOCLR0=0x00010000; // switch off therelay
}*/
23

/***********************************************************************************/
XINTR _RELAY.C
/
********************************************************************
**************/ #include <LPC214x.h>
#include
"ext.h" int
main()
{
init_VIC();
init_Interrupt();init
_po rts();
while(1)
{
//wait_for_turnoffRelay();
}
}

INTERRUPT BUZZERPROGRAM
ARM DETAILS
P1.18 TRIGGER THE RELAY
P0.15 EINT2

Result

The C program to write and read a data in EEPROM and also to analyze its
performance with the interrupt is developed and is verified.
24

4.WORKING OF A THREAD IS TO TRACE A REALTIME PROGRAM

USING RTLINUX
Aim
To write C Program to understand the working of a thread is to trace a realtime program using
RTlinux

Apparatus & Software Required

1. LPC2148 Development board.


2. Keilµ Vision 5 software.
3. Flash Magic.
4. USB cable.

Theory
A realtime application is usually composed of several ``threads'' of execution. Threads are

light-weight processes which share a common address space. In RTLinux, all threads share the

Linux kernel address space. The advantage of using threads is that switching between threads

is quite inexpensive when compared with context switch. We can have complete control over

the execution of a thread by using different functions.

Procedure
1. RTLinux uses the kernel space for executing the programs and there will be not be any protection
against errors in the user's code. Programming errors may lead to system down.
2. Use the debugger which the RTLinux supplies in order to reduce the risk of system crashes.
3. If the floating point unit is required in the task, we must explicitly set permissions, because by
4. default RTLinux tasks are not having floating point unit access.
5. Command prompt arguments can't be passed in RTLinux
25
Program

#include <rtl.h>
#include <time.h>
#include <pthread.h>

pthread_t thread;

void * thread_code(void)
{
pthread_make_periodic_np(pthread_self(), gethrtime(), 1000000000);

while (1)
{
pthread_wait_np ();
rtl_printf("Hello World\n");
}

return 0;
}

int init_module(void)
{
return pthread_create(&thread, NULL, thread_code, NULL);
}

void cleanup_module(void)
{
pthread_delete_np(thread);
}

Result
Thus C Program to understand the working of a thread is to trace a realtime program is verified
using RTlinux
26

5. INTERFACING STEPPER MOTOR AND TEMPERATURE SENSOR

Aim

To write C Programs for running stepper motor either in clock- wise or counter-clock- wise and
the direction of the rotation of the stepper motor depends on the variation in the temperature
sensor.

Apparatus & Software Required

1. LPC2148 Development board.


2. Keilµ Vision 5 software.
3. Flash Magic.
4. USB cable.
5. Stepper Motor.

Theory

Stepper motors, effectively have multiple "toothed" electromagnets arranged around a


central metal gear. To make the motor shaft turn, first one electromagnet is given power, which
makes the gear's teeth magnetically attracted to the electromagnet's teeth. When the gear's teeth
are thus aligned to the first electromagnet, they are slightly offset from the next electromagnet.

So when the next electromagnet is turned on and the first willturn off, the gear rotates
slightly to align with the next one and from there the process is repeated. Each of those slight
rotations is called a "step." In that way, the motor can be turned to a précised angle. There are
two basic arrangements for the electromagnetic coils: bipolar and unipolar.
27

Procedure
1. Follow the steps to create a New project
2. Type the below code and save it with the name (anyname.c)
3. Follow the steps to create a New Project to compile and build the program
4. Follow the procedures in to download your Hex code to processor using Flash Magic
Software.

STEPPER MOTOR PROGRAM

/* This is a test program to stepper motor interface in theARMLPC2148 */


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

#definestep1 0x00010000 /* P1.16 */


#definestep2 0x00020000 /* P1.17 */

void wait (void)


{ /* wait function*/
int d;
for (d = 0; d <10000;d++); /* only to delay for LED flashes*/
}

call_stepper_forw()
{
IOCLR1 = 0X00FF0000;
IOSET1 = 0X00040000;
//wait();
//wait();
wait();
wait();
IOCLR1 = 0X00FF0000;
IOSET1 = 0X00060000;
//wait();
//wait();
28

wait();
wait();
IOCLR1 =
0X00FF0000;
IOSET1 =
0X00070000;
//wait();
//wait();
wait();
wait();
IOCLR1 =
0X00FF0000;
IOSET1 =
0X00050000;
//wait();
//wait();
wait();
wait();
}

int main (void)


{
IODIR1 |= 0xFFFFFFFF; IOCLR1
|= 0X00FF0000;
wait();
while(1) /*LoopForever*/
{
call_stepper_forw();
// wait();
// wait();
wait();
wait();
IOCLR1 = 0X00FF0000;
}
}

STEPPER MOTOR PROGRAM PORT DETAILS


ARM DETAILS
P1.16 STEP 1
P1.17 STEP 2
29

TEMPERATURE SENSOR PROGRAM

/*************************************************************/
MAIN ADC TEST
/*************************************************************/
/* This is a test program to temperature sensor in the ARM LPC2148 developmentboard*/
/************************************************************************************/
#include<LPC214x.H> /* LPC214x definitions*/
#include"ADC_Driver.c" /* contains prototypes of driverfunctions*/
#include"lcd.c" #include <stdio.h>

int main (void)


{
unsigned int
adc_val;
unsigned int
temp;
unsigned char buf[4] ={0,0,0,0};
ADCInit(); lcdinit();
//wait();
clrscr(10);
printstr("ADC Test",0,0); wait();
while(1) /* Loop forever*/
{
adc_val = ADC_ReadChannel();
temp = (unsigned int)((3*adc_val*100)/1024);
sprintf(buf,"%d",temp);
printstr(buf,0,1);

}
}

/************************************************************************************/
LCD.C
/************************************************************************************/

#include <LPC214x.h>

#defineRS 0x00000400 /* P0.10


*/
#defineCE 0x00001800 /* P1.11
*/

void clrscr(char ch);


void lcdinit(void);
void lcdcmd(char);
void lcddat(char);
void gotoxy(char,char); //x,y ; x-char position(0 - 16) y-line number 0 or1
void printstr(unsignedchar*,char,char);//string,column(x),line(y)
30
31

void wait (void);


void split_numbers(unsigned int number);

#define
SET1
#define
OFF0
unsigned int thousands,hundreds,tens,ones;

voidwait(void) { /* wait
function */ intd;
for (d = 0; d <100000;d++); /* only to delay for LED flashes*/
}

void lcdinit()
{
IODIR0 |= 0xFFFFFFFF;
IOCLR0 |=
0X00000FFF;
lcdcmd(0x28);
lcd cmd(0x28);
lcdcmd(0x0c);
lcdcmd(0x06);
lcdcmd(0x01);
lcdcmd(0x0f);
wait();
}

void gotoxy(char x, char y)


{
if(y == 0)
lcdcmd(0x80+x);
else
lcdcmd(0xc0+x);

void printstr(unsigned char *str, char x, char y)


{
char i; gotoxy(x,y);
wait();//(500);
for(i=0;str[i]!='\0';i+
+)lcddat(str[i
]);

}
void lcdcmd(charcmd)
{
unsigned charLCDDAT;
LCDDAT = (cmd&0xf0);//higher nibble
32

IOSET0 =LCDDAT;
IOCLR0 = RS;
IOSET0= CE;
wait();//(100);//enablelcd
IOCLR0 = CE;
IOCLR0 = 0X00000FFF;
LCDDAT = ((cmd<<0x04)&0xf0);//lower nibble
IOSET0 =LCDDAT;
IOCLR0 = RS;
IOSET0 = CE;
wait();//(100);//enablelcd
IOCLR0 = CE;
IOCLR0 = 0X00000FFF;
}
void lcddat(char cmd)
{
unsigned charLCDDAT;
LCDDAT = (cmd&0xf0); //higher nibble IOSET0 =LCDDAT;
IOSET0 = RS; IOSET0 = CE;
wait();//(100); //enablelcd
IOCLR0 = CE;
IOCLR0 = 0X00000FFF;

LCDDAT = ((cmd<<0x04)&0xf0); //lower nibble IOSET0 =LCDDAT;


IOSET0 = RS; IOSET0 = CE;
wait();//(100); //enablelcd
IOCLR0 = CE;
IOCLR0 = 0X00000FFF;
}

void clrscr(char ch)


{
if(ch==0)
{
printstr(" ",0,0);
gotoxy(0,0);
}
else if(ch ==1)
{
printstr(" ",0,1);
gotoxy(0,1);
}
else
{
lcdcmd(0x01);
//delay(100);
}
}
33
void split_numbers(unsigned int number)
{
thousands = (number /1000); number %= 1000;
hundreds = (number / 100); number %= 100;
tens = (number / 10); number %= 10; ones = number ;
}

void Wait_Msg(void)
{
lcdcmd(0x01);
printstr(" Please Wait ", 0,0);
}
void Welcome_Msg(void)
{
lcdcmd(0x01);
printstr(" Welcometo ", 0,0);
printstr(" SMMICRRO ", 0,1);
}
34

ADC_ DRIVER.C
/**************************************************************/

#include<LPC214x.H> /* LPC214x
definitions */ Void ADCInit(void)
{
PINSEL1|=0x04000000; /*For Channel AD0.2
is P0.29*/ IODIR0 |=~(0x04000000);
AD0CR |=0x00200204; /*0x04 selects AD0.2 to mux output, 0x20 makes
ADCin operational*/ AD0GDR; /*A read on AD0GDR clears the
DONEbit*/
}
void ADC_StartConversion(void)
{
AD0CR |= (1<<24);
}
void ADC_StopConversion(void)
{
AD0CR &= (~(1<<24));
}
unsigned int ADC_ReadChannel(void)
{
// unsigned int i;
unsigned long
ADC_Val, t;
ADC_StartConversion(
);
while((AD0DR2&0x80000000)==0); /*wait until ADC
conversion completes*/ if(AD0STAT & 0x00000400)
{
//printstr("OVR",0,1);return(0);
}
t = AD0DR2;
ADC_Val = ((t>>6) & 0x000003FF);//(AD0DR2 & 0x000003FF); //((AD0CR>>6) & 0x000003FF);
//
ADC_StopConversion();retu
rn( ADC_Val);
}.
TEMPERATURE SENSOR PROGRAM PORT DETAILS
ARM DETAILS
P0.29 ADC0.2
PO.10 RS LCD PIN
P1.11 CE LCD PIN

Result

The C program for running stepper motor either in clock-wise or counter-clock-wise


depending on the temperature is developed in the sensor LM35 and the output is verified in
LCD.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy