Professional Documents
Culture Documents
EEM4016
7-SEGMENT DISPLAYS
1
AVR BOARD
GLCD CS1
GLCD CS2
GLCD RW
GLCD A0
RS CLCD
HEX Switch
Enable
CLCD
Frequency Cinch
Analog
Cinch
GLCD Enable
DA OUT
S15 Graphics Character
S2 LEDs DAC
S3 LCD LCD
PA0
Port A Port C
PA2
Keypad LEDs
GLCD CS2
RTC
GLCD RW
GLCD A0
PF0/ADC0 PB0/SDA
I2CINT
PF1/ADC1 PB1/SCLK
PF2/ADC2 PB2
PF3/ADC3 PB3
Enable CLCD RS CLCD
Port B
Port F
PF4 PB4
PF5 PB5/D
USB JTAG
PF6 PB6/CLK MAX 7219
PF7 PB7/LOAD
Port E
PD4 PE4
GLCD Enable
Buzzer PD5 PE5
S4
2
Using the Bank of 8 7-Segment Displays
PHYSICAL CONNECTION
MAX7219 8
PB5 DIN
EEM4016
PB6 CLK
LOAD 8 1
PB7
AVR
3
Using the 7-Segment Displays
init_7seg(void)
To intialise the interface
EEM4016
4
Using the avrm.h Header File
{ dis_7seg( )
init_7seg( );
.......
dis_7seg_num( )
dis_7seg( ) ;
dis_7seg_num( ) ;
.........
}
dis_7seg( ) and dis_7seg_num( )
need parameters passed.
5
Library Function: init_7seg()
1. Configures interface pins as outputs
2. Configures the external MAX7219 driver chip
MAX7219 8
EEM4016
PB5 DIN 8
PB6 CLK
LOAD 8 1
PB7
AVR
6
Library Function: dis_7seg()
Used to output a single digit to a single 7-segment display
digit position ( 1 - 8 , left to right)
digit to be displayed
EEM4016
dis_7seg( d , n )
1 2 3 4 5 6 7 8 Segment positions
Examples
int pos = 8, num = 2 ;
7
Library Function: dis_7seg_num()
A integer ( 0 - 255 )
EEM4016
dis_7seg_num( d , n )
Examples:
int position = 3 ; num = 123 ;
dis_7seg_num ( 1 , 213 ); // displays 213-----
dis_7seg_num (position , num); // displays --123---
8
7 Segment Display Programming Examples
7SEG1.C
7SEG1.C
Using
Using the
the algorithm
algorithm developed
developed below,
below,
write
write aa program
program toto continually
continually show
EEM4016
show
the
the following
following display:
display:
0011223344556677 with small delay
1122334455667788
2233445566778899 sufficient to see
etc...
etc... each line
9
Memory set up
digit[0] 0
EEM4016
digit[1] 1 dis_7seg( d , n )
digit[2] 2
digit[3] 3
digit[4] 4
digit[5] 5
digit[6] 6
digit[7] 7
AVR
10
Algorithm
1.1. Define
Defineand andintialise
intialisean
anarray
arraynamed
nameddigitdigitto
tohold
holdthe
the
integer
integervalues
values0,1,2,3,4,5,6,7
0,1,2,3,4,5,6,7
2. Initialise
Initialisethe
the77segment
segmentdisplays
displaysusing
usingdig_int(
dig_int())
EEM4016
2.
3.
3. Set
Setaapointer
pointertotohold
holdthe
theaddress
addressof ofthe
thestart
startof
ofarray
array
4.
4. Send
Sendeacheachvalue
valueheld
heldininarray
arrayto
toaadisplay
displaysegment
segment
5.
5. Increment
Incrementeach eachof ofthe
thevalues
valuesininthe
thearray
array
6.
6. Delay
Delayto tosee
seecurrent
currentdisplay
displayoutput
output
7.
7. Loop
Loopto tostage
stage33
11
A:\7SEG1.C
#include avrm.h
#define TRUE 1
void main(void)
{
12
CONTINUED...
13
CONTINUED...
14
void delay(void)
{
unsigned int bigcount ;
EEM4016
15
7 Segment Display Programming Examples
7SEG2.C
7SEG2.C
Write
Write aa program
program to to read
read the
the state
state of
of the
the
EEM4016
bank
bank of
of 88 toggle
toggle switches
switches andand to
to display
display
the
the corresponding
corresponding decimal
decimal number
number on on
the
the bank
bank ofof 7-segment displays..
7-segment displays
16
7SEG2.C
#include avrm.h
#define TRUE 1
void main(void)
{
EEM4016
17
Tasks
1.1. Verify
Verifythe
theoperation
operationofof7SEG1.C
7SEG1.C
2.2. Verify
Verifythe
theoperation
operationofof7SEG2.C
EEM4016
7SEG2.C
3.3. Write
Writeaaprogram
programto todisplay
displayan
anincrementing
incrementingcount
count
(0
(0to
to100)
100)ononthe
theseven
sevensegment
segmentdisplays.
displays. Name
Name
the
thefile
file7SEG3.C
7SEG3.C
18
NOTES
EEM4016
19