You are on page 1of 18

2016

Seven Segment Display


with
NXP LPC1769
using LPCXpresso

Author: Gurudatta Palankar


Reviewers:
Version: 1.0

Step 1: Open LPCXpresso IDE.

Fig. 1

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

Step 2: To create a New project. Go to File >> New >> Project. Select LPCXpresso C
project.

Fig. 2

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

Step 3: Select LPC1769, C Project and give name to your project. Select target MCU as
LPC1769.

Fig. 3

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

Step 4: Now select CMSIS Core library. Click on Next and keep all the other
configurations as default and Finish.

Fig. 4

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

Step 5: Now we can see our project onto the workspace. Now by double clicking on
Seven_Segment.c file, we can start writing code in an editor window. Here we are going
to writing a code for blinking an LED.

Fig. 5

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

Step 6: Write a code as shown below.

Fig. 6

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

CODE:
#ifdef __USE_CMSIS
#include "LPC17xx.h"
#endif
void delay(int );
int main(void)
{
LPC_GPIO0->FIODIR0 = 0xFF;
while(1)
{
int i;
for( i=0; i<=9; i++)
{
switch(i)
{
case 0:
LPC_GPIO0->FIOSET0 = 0xC0;
delay(1000);
LPC_GPIO0->FIOCLR0 = 0xC0;
break;
case 1:
LPC_GPIO0->FIOSET0 = 0xF9;
delay(1000);
LPC_GPIO0->FIOCLR0 = 0xF9;
break;
case 2:
LPC_GPIO0->FIOSET0 = 0xA4;
delay(1000);
LPC_GPIO0->FIOCLR0 = 0xA4;
break;
case 3:
LPC_GPIO0->FIOSET0 = 0xB0;
delay(1000);
LPC_GPIO0->FIOCLR0 = 0xB0;
break;
case 4:
LPC_GPIO0->FIOSET0 = 0x99;
delay(1000);
LPC_GPIO0->FIOCLR0 = 0x99;
# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

break;
case 5:
LPC_GPIO0->FIOSET0 = 0x92;
delay(1000);
LPC_GPIO0->FIOCLR0 = 0x92;
break;
case 6:
LPC_GPIO0->FIOSET0 = 0x82;
delay(1000);
LPC_GPIO0->FIOCLR0 = 0x82;
break;
case 7:
LPC_GPIO0->FIOSET0 = 0xF8;
delay(1000);
LPC_GPIO0->FIOCLR0 = 0xF8;
break;
case 8:
LPC_GPIO0->FIOSET0 = 0x80;
delay(1000);
LPC_GPIO0->FIOCLR0 = 0x80;
break;
case 9:
LPC_GPIO0->FIOSET0 = 0x90;
delay(1000);
LPC_GPIO0->FIOCLR0 = 0x90;
break;
}
}
}
return 0 ;
}
void delay(int a)
{
int i, j;
for(i=0; i<5000; i++)
for(j=0; j<=a; j++);
}

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

Step 7: After writing code, Build the project by clicking on Build Seven_Segment,
on the Quickstart Panel on the bottom left of the window.

Fig. 7

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

Step 8: Now, if everything goes well, connect the USB cable to LPC1769 and connect
it to your computer. To upload the project file, click on the Program flash.

Fig. 8

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

Step 9: Now select the Project file Seven_segment.axf. We can find it in a Debug folder
of our project folder.

Fig. 9a

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

Fig. 9b

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

Step 10: Now this window shows we have finally dumped our code into LPC1769.

Fig. 10

CIRCUIT EXPLAINATION:
Before connection we should be aware of what common anode and common
cathode means. As shown in the figure, in common anode we can turn ON a segment by
driving a logic 0. And in common cathode we can turn ON a segment by driving a Logic
1. We have used common anode in this project. As you can see table below, to turn ON a
specific LED we drive logic 0.

Fig. 11
# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

COMMON ANODE CONFIGURATION

Fig. 12

Display
number

DP

(P0.7) (P0.6) (P0.5) (P0.4) (P0.3) (P0.2) (P0.1) (P0.0)

Hex
values

0xC0

0xF9

0xA4

0xB0

0x99

0x92

0x82

0xF8

0x80

0x90

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

PIN DETAILS:

P0.0

P0.1

P0.2

P0.3

P0.4

P0.5

P0.6

P0.7

DP

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

OUTPUT:

Fig. 13

Fig. 14
# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726

Fig. 15

For product link:


1.

http://www.tenettech.com/product/1548/lpc1769-lpcxpresso-board

2.

http://tenettech.com/product/6655/universal-gpio-board

For more information please log on to www.tenettech.com


For technical query please send us an e-mail: info@tenettech.com

# 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: info@tenettech.com, Phone: 080 - 26722726