Embedded System Hardware Exp
Embedded System Hardware Exp
Program:
#include <LPC17xx.H>
void clock_wise(void);
void anti_clock_wise(void);
unsigned long int var1,var2;
unsigned int i=0,j=0,k=0;
int main(void)
{
LPC_PINCON->PINSEL4 = 0x00000000; //P2.0 to P2.3 GPIO
LPC_GPIO2->FIODIR = 0x0000000F; //P2.0 to P2.3 output
while(1)
{
for(j=0;j<50;j++) //50 times in Clock wise Rotation
clock_wise();
Result:
Observe the stepper motor rotation it should rotate Clockwise & Anti Clockwise direction.
This rotation of the motor will be continuously in loop.
Experiment 10:
Triangular wave:
#include <LPC17xx.H>
int main ()
LPC_GPIO0->FIOMASK = 0XFFFFF00F;
while(1)
/*output 0 to FE*/
for(i=0;i!=0xFF;i++)
temp=i;
LPC_GPIO0->FIOPIN = temp;
/* output FF to 1*/
for(i=0xFF; i!=0;i--)
temp=i;
}
//End of
while(1)
#include <LPC17xx.H>
void delay(void);
int main ()
LPC_PINCON->PINSEL0 = 0x00000000; //
Configure P0.4 to P0.11 as GPIO
LPC_GPIO0->FIOMASK = 0XFFFFF00F;
while(1)
LPC_GPIO0->FIOPIN = 0x00000FF0 ;
delay();
LPC_GPIO0->FIOCLR = 0x00000FF0 ;
delay();
void delay(void)
for(i=0;i<=9500;i++);
//3ms delay
}
A) Square Wave:
• Download the file “Square.hex” to trainer using Flash Magic 6.01 version.
B) Triangle Wave:
• Download the file “Triangle.hex” to trainer using Flash Magic 6.01 version.
NOTE: POT3 is provided to control the Reference voltage for DAC output (Vref).User will get
maximum 2.5V peak to peak for uni-polar and 5V peak to peak for Bipolar
Experiment 11:
Display the Hex digits 0 to F on a 7-segment LED interface, with a suitable delay in between.
Program:
----
f| g |b
|----|
e| |c
---- . dot
a = P0.04
b = P0.05
c = P0.06
d = P0.07
e = P0.08
f = P0.09
g = P0.10
dot = P0.11
*/
#include <LPC17xx.h>
LPC_PINCON->PINSEL0 = 0x00000000;
LPC_PINCON->PINSEL1 = 0x00000000;
LPC_GPIO0->FIODIR = 0x00180ff0;
while(1)
LPC_GPIO0->FIOSET |= ALLDISP;
LPC_GPIO0->FIOCLR = 0x00000ff0;
// clear the data lines to 7-segment displays
for(j=0;j<3;j++)
for(delay=0;delay<30000;delay++);
// delay
Switchcount++;
if(Switchcount == 0x10)
// 0 to F has been displayed ? go back to 0
Switchcount = 0;
LPC_GPIO0->FIOCLR = 0x00180ff0;
}
• Download the file “Seven_seg.hex” to trainer using Flash Magic 6.01 version.
• Both pins of SW5 should be in ON position. Switch off SW3, Un-short JP7. Press the reset
switch (SW1) to run the program.
Result:
Observe display changing from 00 to FF. This process is continuously in loop.
Experiment 12:
Interface a simple Switch and display its status through Relay, Buzzer and LED
Program:
#include <LPC17xx.H>
int main(void)
{
LPC_PINCON->PINSEL1 = 0x00000000; //P0.24,P0.25 GPIO
LPC_GPIO0->FIODIR = 0x03000000;
//P0.24 configured output for buzzer,P0.25 configured output for
Relay/Led
while(1)
{
if(!(LPC_GPIO2->FIOPIN & 0x00000800))
//Is GP_SW(SW4) is pressed??
{
LPC_GPIO0->FIOSET = 0x03000000;
//relay on
}
else
{
LPC_GPIO0->FIOCLR = 0x03000000;
//relay off
}
}
}
• Download the file “RELAY.hex” to trainer using Flash Magic 6.01 version.
• Short jumper JP12.
Result:
Press SW4 on the buzzer section, see that Relay RLY2, Led L4 and Buzzer BZ1 are On and
when user releases the push button the Relay RLY2, L4 and Buzzer should be in Off
condition. Relay Common and NO are brought out to CN5 connector.