Exp2 Digital Output through 7 segment LED display to increment and decrement the number with SRAM memory mapping
Exp2 Digital Output through 7 segment LED display to increment and decrement the number with SRAM memory mapping
(ATMEGA32)
Submitted by
Ronit Dutta, MS in IOT and Signal Processing
Department of Electrical Engineering, IIT Kharagpur
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.
2
Embedded System on AVR ATMEGA32:Exp2
As each LED has two connecting pins, one called the “Anode” and the other called the
“Cathode”, there are therefore two types of LED 7-segment display called: Common
Cathode (CC) and Common Anode (CA). The displays common pin is generally used to
identify which type of 7-segment display it is.
Common Cathode (CC): 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).
3
Embedded System on AVR ATMEGA32:Exp2
Common Anode (CA): 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).
In the LAB, the Common Cathode(CC) Seven Segment Display is used for the
experiment purpose.
Therefore, Boolean expressions for each decimal digit that requires respective light-
emitting diodes (LEDs) are ON or OFF. Seven segment displays must be controlled by
other external devices where different types of microcontrollers are useful to
communicate with these.
4
Embedded System on AVR ATMEGA32:Exp2
.INCLUDE "M32DEF.INC"
.ORG 0X0000
LDI R16,HIGH(RAMEND)
OUT SPH,R16
LDI R16,LOW(RAMEND)
OUT SPL,R16
LDI R16,0XFF
OUT DDRA,R16
MAIN: LD R16,X+
OUT PORTA,R16
CALL Delay
CPI R26,0x0A
BRNE MAIN
LDI R26,0x00
JMP MAIN
6
Embedded System on AVR ATMEGA32:Exp2
.INCLUDE "M32DEF.INC"
.ORG 0X0000
LDI R16,HIGH(RAMEND)
OUT SPH,R16
LDI R16,LOW(RAMEND)
OUT SPL,R16
7
Embedded System on AVR ATMEGA32:Exp2
MOV R2,R16
LDI R16,0XFF
OUT DDRA,R16
MAIN: LD R16,-X
OUT PORTA,R16
CALL Delay
CPI R26,0X00
BRNE MAIN
LDI R26,0x0A
JMP MAIN
8
Embedded System on AVR ATMEGA32:Exp2
BRNE L3
DEC R18
BRNE L2
DEC R17
BRNE L1
RET
Upload the HEX file in the same circuit on SimulIDE discussed above and verify the
simulation by TA.
.INCLUDE "M32DEF.INC"
.ORG 0X0000
LDI R16,HIGH(RAMEND)
OUT SPH,R16
LDI R16,LOW(RAMEND)
OUT SPL,R16
9
Embedded System on AVR ATMEGA32:Exp2
MOV R6,R16
LDI R16,0XFF
OUT DDRA,R16 //For 7 Segment Display
LDI R16,0x03
OUT DDRC,R16 //For Signaling LEDs
CBI PORTC,PINC0
SBI PORTC,PINC1
MLOOP2: LD R16,-X
OUT PORTA,R16
CALL Delay
CPI R26,0X00
BRNE MLOOP2
LDI R26,0x0A
JMP MAIN
10
Embedded System on AVR ATMEGA32:Exp2
L3: NOP
DEC R19
BRNE L3
DEC R18
BRNE L2
DEC R17
BRNE L1
RET
Upload the HEX file in the same circuit on SimulIDE discussed above and verify the
simulation by TA.
Assignment3: Write the C code for the above Experiment
11
Embedded System on AVR ATMEGA32:Exp2
12