SEVEN
SEGMENT: Seven segment display (SSD),
or seven-segment indicator, is a form of electronic display
device for displaying decimal numerals that is an
alternative to the more complex dot matrix displays.
Interfacing of
seven segment with ARM Cortex:
PROGRAM 1:
#include "NUC1xx.h"
#include "GPIO.h"
#include "SYS.h"
int main()
{ int i;
DrvGPIO_Open(E_GPC,12,E_IO_OUTPUT);
DrvGPIO_Open(E_GPC,13,E_IO_OUTPUT);
DrvGPIO_Open(E_GPC,14,E_IO_OUTPUT);
DrvGPIO_Open(E_GPC,15,E_IO_OUTPUT);
while(1)
{
for(i=12;i<=15;i++)
{
DrvGPIO_ClrBit(E_GPC,i);
DrvSYS_Delay(300000);
DrvGPIO_SetBit(E_GPC,i);
DrvSYS_Delay(300000);
}
void loop()
{
for(int temp=0;temp<10;temp++)
{
char temp2=segment_digit[temp];
for(int k=0;k<8;k++)
{
char temp1=temp2&0x01;
temp2=temp2>>1;
digitalWrite(segment_pins[k],temp1);
}
delay(1000);
}
}
}
}
PROGRAM 2: Display 0-9.
#include <stdio.h>
#include <string.h>
#include "NUC1xx.h"
#include "GPIO.h"
#include "SYS.h"
#define seven GPIOE->DOUT
unsigned char arr[]={0x82,0xee,0x07,0x46,0x6a,0x52,0x12,0xe6,0x02,0x42};
int main()
{
int i;
for(i=0;i<8;i++)
DrvGPIO_Open(E_GPE, i, E_IO_OUTPUT);
DrvGPIO_Open(E_GPC,12,E_IO_OUTPUT);
while(1)
{
DrvGPIO_SetBit(E_GPC,4);
DrvGPIO_ClrBit(E_GPC,5);
DrvGPIO_ClrBit(E_GPC,6);
DrvGPIO_ClrBit(E_GPC,7);
for(i=0;i<=9;i++)
{
seven=arr[i];
DrvSYS_Delay(40000000);
}
}
}
PROGRAM 2: Display 0-99.
#include <stdio.h>
#include <string.h>
#include "NUC1xx.h"
#include "GPIO.h"
#include "SYS.h"
#define seven GPIOE->DOUT
#define seven1 GPIOA->DOUT
unsigned char arr[]={0xee,0x82,0x07,0x46,0x6a,0x52,0x12,0xe6,0x02,0x42};
int main()
{
int i,j;
for(i=0;i<8;i++)
DrvGPIO_Open(E_GPE, i, E_IO_OUTPUT);
for(i=0;i<8;i++)
DrvGPIO_Open(E_GPA, i, E_IO_OUTPUT);
//DrvGPIO_Open(E_GPC,12,E_IO_OUTPUT);
while(1)
{
for(i=0;i<=9;i++)
{
seven=arr[i];
for(j=0;j<=9;j++)
{seven1=arr[j];
DrvSYS_Delay(40000000);
}
}
}
}
PROGRAM 2: Display 0-99. using Multiplexing
#include <stdio.h>
#include <string.h>
#include "NUC1xx.h"
#include "GPIO.h"
#include "SYS.h"
#define seven GPIOE->DOUT
unsigned char arr[]={0x82,0xee,0x07,0x46,0x6a,0x52,0x12,0xe6,0x02,0x42};
int main()
{
int i,j,k;
for(i=0;i<8;i++)
DrvGPIO_Open(E_GPE, i, E_IO_OUTPUT);
DrvGPIO_Open(E_GPC,12,E_IO_OUTPUT);
while(1)
{
DrvGPIO_SetBit(E_GPC,4);
DrvGPIO_ClrBit(E_GPC,5);
DrvGPIO_ClrBit(E_GPC,6);
DrvGPIO_ClrBit(E_GPC,7);
for(k=0;k<=9;k++)
{
for(i=0;i<=9;i++)
{
for(j=0;j<=9;j++)
{
DrvGPIO_SetBit(E_GPC,5);
DrvGPIO_ClrBit(E_GPC,4);
seven=arr[k];
DrvSYS_Delay(40000);
DrvGPIO_SetBit(E_GPC,4);
DrvGPIO_ClrBit(E_GPC,5);
seven=arr[i];
DrvSYS_Delay(40000);
}
}
}
}
}
PROGRAM 2: Display 0-999. using Multiplexing
#include <stdio.h>
#include <string.h>
#include "NUC1xx.h"
#include "GPIO.h"
#include "SYS.h"
#define seven GPIOE->DOUT
unsigned char arr[]={0x82,0xee,0x07,0x46,0x6a,0x52,0x12,0xe6,0x02,0x42};
int main()
{
int i,j,k,l;
for(i=0;i<8;i++)
DrvGPIO_Open(E_GPE, i, E_IO_OUTPUT);
DrvGPIO_Open(E_GPC,12,E_IO_OUTPUT);
while(1)
{
DrvGPIO_SetBit(E_GPC,4);
DrvGPIO_ClrBit(E_GPC,5);
DrvGPIO_ClrBit(E_GPC,6);
DrvGPIO_ClrBit(E_GPC,7);
for(k=0;k<=9;k++)
{
for(i=0;i<=9;i++)
{
for(l=0;l<=9;l++)
{
for(j=0;j<=9;j++)
{ DrvGPIO_SetBit(E_GPC,6);
DrvGPIO_ClrBit(E_GPC,5);
DrvGPIO_ClrBit(E_GPC,4);
seven=arr[k];
DrvSYS_Delay(4000);
DrvGPIO_ClrBit(E_GPC,6);
DrvGPIO_SetBit(E_GPC,5);
DrvGPIO_ClrBit(E_GPC,4);
seven=arr[i];
DrvSYS_Delay(4000);
DrvGPIO_ClrBit(E_GPC,6);
DrvGPIO_ClrBit(E_GPC,5);
DrvGPIO_SetBit(E_GPC,4);
seven=arr[l];
DrvSYS_Delay(4000);
}
}
}
}
}
}
seven
segment display consists of seven LEDs (hence its name) arranged in a
rectangular fashion as shown. Each of the seven LEDs is called a segment
because when illuminated the segment forms part of a numerical digit (both
Decimal and Hex) to be displayed. An additional 8th LED is sometimes used
within the same package thus allowing the indication of a decimal point, (DP)
when two or more 7-segment displays are connected together to display numbers
greater than ten.
Each one of the seven LEDs in the display is given a positional
segment with one of its connection pins being brought straight out of the
rectangular plastic package. These individually LED pins are labelled from
a through to g representing each individual LED. The other LED pins
are connected together and wired to form common pin.
So by forward biasing the
appropriate pins of the LED segments in a particular order, some segments will
be light and others will be dark allowing the desired character pattern of the
number to be generated on the display. This then allows us to display each of
the ten decimal digits 0 through to 9 on the same 7-segment display.
The displays common pin is generally used to identify which type of 7-segment
display it is. As each LED has two connecting pins, one called the “Anode” and
the other called the “Cathode”.
There are two types of seven
segments:
1) Common Cathode
2) Common Anode
1) Common Cathode: In the common
cathode display, all the cathode connections of the LED segments are joined
together to logic 0 or ground. The individual segments are illuminated by
application of a HIGH, or logic 1 signal via a current limiting resistor to
forward bias the individual Anode terminals (a-g).
2) Common Anode: In the common anode
display, all the anode connections of the LED segments are joined together to
logic “1”. The individual segments are illuminated by applying a ground, logic
“0” or “LOW” signal via a suitable current limiting resistor to the Cathode of
the particular segment (a-g).
PIN Diagram of 7 segment:
7 Segment Display Segments for all Numbers:
Hexadecimal encodings for 7
Segment common cathode:
Digit
|
gfedcba
|
abcdefg
|
a
|
b
|
c
|
d
|
e
|
f
|
g
|
0
|
0×3F
|
0×7E
|
on
|
on
|
on
|
on
|
on
|
on
|
off
|
1
|
0×06
|
0×30
|
off
|
on
|
on
|
off
|
off
|
off
|
off
|
2
|
0×5B
|
0×6D
|
on
|
on
|
off
|
on
|
on
|
off
|
on
|
3
|
0×4F
|
0×79
|
on
|
on
|
on
|
on
|
off
|
off
|
on
|
4
|
0×66
|
0×33
|
off
|
on
|
on
|
off
|
off
|
on
|
on
|
5
|
0×6D
|
0×5B
|
on
|
off
|
on
|
on
|
off
|
on
|
on
|
6
|
0×7D
|
0×5F
|
on
|
off
|
on
|
on
|
on
|
on
|
on
|
7
|
0×07
|
0×70
|
on
|
on
|
on
|
off
|
off
|
on
|
off
|
8
|
0×7F
|
0×7F
|
on
|
on
|
on
|
on
|
on
|
on
|
on
|
9
|
0×6F
|
0×7B
|
on
|
on
|
on
|
on
|
off
|
on
|
on
|
A
|
0×77
|
0×77
|
on
|
on
|
on
|
off
|
on
|
on
|
on
|
b
|
0×7C
|
0×1F
|
off
|
off
|
on
|
on
|
on
|
on
|
on
|
C
|
0×39
|
0×4E
|
on
|
off
|
off
|
on
|
on
|
on
|
off
|
d
|
0×5E
|
0×3D
|
off
|
on
|
on
|
on
|
on
|
off
|
on
|
E
|
0×79
|
0×4F
|
on
|
off
|
off
|
on
|
on
|
on
|
on
|
F
|
0×71
|
0×47
|
on
|
off
|
off
|
off
|
on
|
on
|
on
|
Hexadecimal encodings for 7
Segment common anode:
PROGRAM 1:
#include "NUC1xx.h"
#include "GPIO.h"
#include "SYS.h"
int main()
{ int i;
DrvGPIO_Open(E_GPC,12,E_IO_OUTPUT);
DrvGPIO_Open(E_GPC,13,E_IO_OUTPUT);
DrvGPIO_Open(E_GPC,14,E_IO_OUTPUT);
DrvGPIO_Open(E_GPC,15,E_IO_OUTPUT);
while(1)
{
for(i=12;i<=15;i++)
{
DrvGPIO_ClrBit(E_GPC,i);
DrvSYS_Delay(300000);
DrvGPIO_SetBit(E_GPC,i);
DrvSYS_Delay(300000);
}
void loop()
{
for(int temp=0;temp<10;temp++)
{
char temp2=segment_digit[temp];
for(int k=0;k<8;k++)
{
char temp1=temp2&0x01;
temp2=temp2>>1;
digitalWrite(segment_pins[k],temp1);
}
delay(1000);
}
}
}
}
PROGRAM 2: Display 0-9.
#include <stdio.h>
#include <string.h>
#include "NUC1xx.h"
#include "GPIO.h"
#include "SYS.h"
#define seven GPIOE->DOUT
unsigned char arr[]={0x82,0xee,0x07,0x46,0x6a,0x52,0x12,0xe6,0x02,0x42};
int main()
{
int i;
for(i=0;i<8;i++)
DrvGPIO_Open(E_GPE, i, E_IO_OUTPUT);
DrvGPIO_Open(E_GPC,12,E_IO_OUTPUT);
while(1)
{
DrvGPIO_SetBit(E_GPC,4);
DrvGPIO_ClrBit(E_GPC,5);
DrvGPIO_ClrBit(E_GPC,6);
DrvGPIO_ClrBit(E_GPC,7);
for(i=0;i<=9;i++)
{
seven=arr[i];
DrvSYS_Delay(40000000);
}
}
}
PROGRAM 2: Display 0-99.
#include <stdio.h>
#include <string.h>
#include "NUC1xx.h"
#include "GPIO.h"
#include "SYS.h"
#define seven GPIOE->DOUT
#define seven1 GPIOA->DOUT
unsigned char arr[]={0xee,0x82,0x07,0x46,0x6a,0x52,0x12,0xe6,0x02,0x42};
int main()
{
int i,j;
for(i=0;i<8;i++)
DrvGPIO_Open(E_GPE, i, E_IO_OUTPUT);
for(i=0;i<8;i++)
DrvGPIO_Open(E_GPA, i, E_IO_OUTPUT);
//DrvGPIO_Open(E_GPC,12,E_IO_OUTPUT);
while(1)
{
for(i=0;i<=9;i++)
{
seven=arr[i];
for(j=0;j<=9;j++)
{seven1=arr[j];
DrvSYS_Delay(40000000);
}
}
}
}
PROGRAM 2: Display 0-99. using Multiplexing
#include <stdio.h>
#include <string.h>
#include "NUC1xx.h"
#include "GPIO.h"
#include "SYS.h"
#define seven GPIOE->DOUT
unsigned char arr[]={0x82,0xee,0x07,0x46,0x6a,0x52,0x12,0xe6,0x02,0x42};
int main()
{
int i,j,k;
for(i=0;i<8;i++)
DrvGPIO_Open(E_GPE, i, E_IO_OUTPUT);
DrvGPIO_Open(E_GPC,12,E_IO_OUTPUT);
while(1)
{
DrvGPIO_SetBit(E_GPC,4);
DrvGPIO_ClrBit(E_GPC,5);
DrvGPIO_ClrBit(E_GPC,6);
DrvGPIO_ClrBit(E_GPC,7);
for(k=0;k<=9;k++)
{
for(i=0;i<=9;i++)
{
for(j=0;j<=9;j++)
{
DrvGPIO_SetBit(E_GPC,5);
DrvGPIO_ClrBit(E_GPC,4);
seven=arr[k];
DrvSYS_Delay(40000);
DrvGPIO_SetBit(E_GPC,4);
DrvGPIO_ClrBit(E_GPC,5);
seven=arr[i];
DrvSYS_Delay(40000);
}
}
}
}
}
PROGRAM 2: Display 0-999. using Multiplexing
#include <stdio.h>
#include <string.h>
#include "NUC1xx.h"
#include "GPIO.h"
#include "SYS.h"
#define seven GPIOE->DOUT
unsigned char arr[]={0x82,0xee,0x07,0x46,0x6a,0x52,0x12,0xe6,0x02,0x42};
int main()
{
int i,j,k,l;
for(i=0;i<8;i++)
DrvGPIO_Open(E_GPE, i, E_IO_OUTPUT);
DrvGPIO_Open(E_GPC,12,E_IO_OUTPUT);
while(1)
{
DrvGPIO_SetBit(E_GPC,4);
DrvGPIO_ClrBit(E_GPC,5);
DrvGPIO_ClrBit(E_GPC,6);
DrvGPIO_ClrBit(E_GPC,7);
for(k=0;k<=9;k++)
{
for(i=0;i<=9;i++)
{
for(l=0;l<=9;l++)
{
for(j=0;j<=9;j++)
{ DrvGPIO_SetBit(E_GPC,6);
DrvGPIO_ClrBit(E_GPC,5);
DrvGPIO_ClrBit(E_GPC,4);
seven=arr[k];
DrvSYS_Delay(4000);
DrvGPIO_ClrBit(E_GPC,6);
DrvGPIO_SetBit(E_GPC,5);
DrvGPIO_ClrBit(E_GPC,4);
seven=arr[i];
DrvSYS_Delay(4000);
DrvGPIO_ClrBit(E_GPC,6);
DrvGPIO_ClrBit(E_GPC,5);
DrvGPIO_SetBit(E_GPC,4);
seven=arr[l];
DrvSYS_Delay(4000);
}
}
}
}
}
}
0 comments:
Post a Comment
if you have any doubt please let me know