You are on page 1of 4

Ex.

No 5a

Interface Programming With LED


Aim
To write an interface program to work with LED

Apparatus Required
• LED Kit
• Assembler

Program
#include <lpc17xx.h>
void delay_ms(unsigned int ms)
{
unsigned int i,j;
for(i=0; i<ms; i++)
for(j=0; j<20000; j++);
}
int main() /* start the main program */
{
SystemInit(); //Clock and PLL configuration
LPC_GPIO1->FIODIR = 0X07F80000; //Configure the PORT1 pins as output
while(1)
{
LPC_GPIO1->FIOSET = 0X07F80000; //Make all the port pins as high
delay_ms(200);
LPC_GPIO1->FIOCLR = 0X07F80000; //Make all the port pins as high
delay_ms(200);
}
}
Procedure:
i. Open new project in Keil4 and create a file
ii. Enter the program and save it as .c file
iii. Add the file to source group and add system files too
iv. Translate and built the file
v. Create Hex file using target option and rebuild all
vi. Open Flash Magic
vii. Through loop device program mode select Hex file and execute it
viii. Transfer the program to LED kit
Result
Thus, the interface programming was written to work with LED.
Ex. No 5b

Interface Programming With 7 Segment Display


Aim
To write an interface program to work with 7 segment display

Apparatus Required
• 7 Segment display Kit
• Assembler

Program
#include <lpc17xx.h>
void delay_ms(unsigned int ms)
{
unsigned int i,j;
for(i=0; i<ms; i++)
for(j=0; j<40000; j++);
}
Int main() /* start the main program */
{
SystemInit(); //Clock and PLL configuration
LPC_GPIO0->FIODIR = 0X00000100; //Configure the PORT0 pins as output
LPC_GPIO1->FIODIR = 0X00004713;
while(1)
{
LPC_GPIO0->FIOSET = 0X00000100; //Make all the port pins as high
LPC_GPIO1->FIOCLR = 0X00004713; //Clear all the segments
LPC_GPIO1->FIOSET = 0X00004000; //Set g to make 0
delay_ms(200);
LPC_GPIO1->FIOCLR = 0X00004713; //Clear all the segments
LPC_GPIO1->FIOSET = 0X00004701; //Set a, d, e, f, g to make 1
delay_ms(200);
LPC_GPIO1->FIOCLR = 0X00004713; //Clear all the segments
LPC_GPIO1->FIOSET = 0X00000410; //Set c, f to make 2
delay_ms(200);
LPC_GPIO1->FIOCLR = 0X00004713; //Clear all the segments
LPC_GPIO1->FIOSET = 0X00000600; //Set e, f to make 3
delay_ms(200);
LPC_GPIO1->FIOCLR = 0X00004713; //Clear all the segments
LPC_GPIO1->FIOSET = 0X00000301; //Set a, d, e to make 4
delay_ms(200);
LPC_GPIO1->FIOCLR = 0X00004713; //Clear all the segments
LPC_GPIO1->FIOSET = 0X00000202; //Set b, e to make 5
delay_ms(200);
LPC_GPIO1->FIOCLR = 0X00004713; //Clear all the segments
LPC_GPIO1->FIOSET = 0X00000002; //Set b to make 6
delay_ms(200);
LPC_GPIO1->FIOCLR = 0X00004713; //Clear all the segments
LPC_GPIO1->FIOSET = 0X00004700; //Set d, e, f, g to make 7
delay_ms(200);
}
}
Procedure:
i. Open new project in Keil4 and create a file
ii. Enter the program and save it as .c file
iii. Add the file to source group and add system files too
iv. Translate and built the file
v. Create Hex file using target option and rebuild all
vi. Open Flash Magic
vii. Through loop device program mode select Hex file and execute it
viii. Transfer the program to 7 segment display kit
Result
Thus, the interface programming was written to work with 7 segment display

You might also like