0% found this document useful (0 votes)
53 views4 pages

Interface Programming With LED: Ex. No 5a

This document contains two programs that write interface code to work with LEDs and 7-segment displays. The first program blinks LEDs by turning all output pins on a port high and low with delays. The second program displays the digits 0-7 on a 7-segment display by turning specific output pins high and low in a loop with delays. Both programs initialize the system, configure ports as outputs, and write main loops to toggle the outputs while adding procedures to build and run the programs on the appropriate hardware kits.

Uploaded by

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

Interface Programming With LED: Ex. No 5a

This document contains two programs that write interface code to work with LEDs and 7-segment displays. The first program blinks LEDs by turning all output pins on a port high and low with delays. The second program displays the digits 0-7 on a 7-segment display by turning specific output pins high and low in a loop with delays. Both programs initialize the system, configure ports as outputs, and write main loops to toggle the outputs while adding procedures to build and run the programs on the appropriate hardware kits.

Uploaded by

Prajwal B Naik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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