0% found this document useful (0 votes)
3 views

Exp2 Digital Output through 7 segment LED display to increment and decrement the number with SRAM memory mapping

Uploaded by

ckarmakar2004
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Exp2 Digital Output through 7 segment LED display to increment and decrement the number with SRAM memory mapping

Uploaded by

ckarmakar2004
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Embedded System on AVR Microcontroller

(ATMEGA32)

Exp2: Digital Output through 7 segment LED


display to increment and decrement the number
with SRAM memory mapping

Submitted by
Ronit Dutta, MS in IOT and Signal Processing
Department of Electrical Engineering, IIT Kharagpur

Under the guidance of


Aurobinda Routray, Professor, Electrical Engineering

Department of Electrical Engineering


Indian Institute of Technology Kharagpur
January, 2024
Embedded System on AVR ATMEGA32:Exp2

 Seven Segment LED Display


Light Emitting Diode (LED) is the most widely used semiconductor which emits either
visible light or invisible infrared light when forward biased. A Light-emitting diode
(LED) is optical-electrical energy into light energy when voltage is applied. A seven-
segment LED is a digital display module specialized to display numerical information.
Light-emitting diodes (LEDs) arranged in the shape of numbers offer an easily visible
display. They are sometimes called "seven-segment displays" or "seven-segment
indicators."
The 7-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.

Fig.1: Seven Segment Display Package with pinout

The parts of the seven-segment LED are as follows:

I. Light-emitting components (a–g): 7 Segments (Seg)


II. Dot light-emitting component: Decimal point (DP)
III. Common LED Pins: 2 pins from same common node

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.

 Truth Table for Common Cathode Display

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

 Seven Segment LED Display to Increment the Number


Memory Mapped SRAM
// Seven Segment Display Increment

.INCLUDE "M32DEF.INC"
.ORG 0X0000

LDI R16,HIGH(RAMEND)
OUT SPH,R16
LDI R16,LOW(RAMEND)
OUT SPL,R16

LDI R16,0x3F //Seven Segment Bits for 0


MOV R0,R16

LDI R16,0x06 //Seven Segment Bits for 1


MOV R1,R16

LDI R16,0x5B //Seven Segment Bits for 2


MOV R2,R16

LDI R16,0x4F //Seven Segment Bits for 3


MOV R3,R16

LDI R16,0x66 //Seven Segment Bits for 4


MOV R4,R16

LDI R16,0x6D //Seven Segment Bits for 5


MOV R5,R16

LDI R16,0x7D //Seven Segment Bits for 6


MOV R6,R16

LDI R16,0x07 //Seven Segment Bits for 7


MOV R7,R16

LDI R16,0x7F //Seven Segment Bits for 8


MOV R8,R16

LDI R16,0x6F //Seven Segment Bits for 9


MOV R9,R16
5
Embedded System on AVR ATMEGA32:Exp2

LDI R16,0XFF
OUT DDRA,R16

LDI R27,0x00; // XH of the register pair X


LDI R26,0x00; // XL of the register pair X

MAIN: LD R16,X+
OUT PORTA,R16
CALL Delay
CPI R26,0x0A
BRNE MAIN
LDI R26,0x00
JMP MAIN

Delay: LDI R17,0xFF


L1: LDI R18,0xFF
L2: LDI R19,0x04
L3: NOP
DEC R19
BRNE L3
DEC R18
BRNE L2
DEC R17
BRNE L1
RET

 Instruction Sets of ATmega32


http://www.avr-asm-tutorial.net/avr_en/micro_beginner/instructions.html

 Make the below Circuit on SimulIDE to simulate


Components Required:
1. ATmega32
2. Seven Segment LED Display
3. 100 Ohm DIP Resistor
4. Fixed Voltage
5. Push Button
6. 10KOhm Resistor
7. 100nF Capacitor

6
Embedded System on AVR ATMEGA32:Exp2

After uploading the HEX file, verify the simulation by TA.

Assignment1: Write the C code for the above Experiment

 Seven Segment LED Display to Decrement the Number


Memory Mapped SRAM

// Seven Segment Display Decrement

.INCLUDE "M32DEF.INC"
.ORG 0X0000

LDI R16,HIGH(RAMEND)
OUT SPH,R16
LDI R16,LOW(RAMEND)
OUT SPL,R16

LDI R16,0x3F //Seven Segment Bits for 0


MOV R0,R16

LDI R16,0x06 //Seven Segment Bits for 1


MOV R1,R16

LDI R16,0x5B //Seven Segment Bits for 2

7
Embedded System on AVR ATMEGA32:Exp2

MOV R2,R16

LDI R16,0x4F //Seven Segment Bits for 3


MOV R3,R16

LDI R16,0x66 //Seven Segment Bits for 4


MOV R4,R16

LDI R16,0x6D //Seven Segment Bits for 5


MOV R5,R16

LDI R16,0x7D //Seven Segment Bits for 6


MOV R6,R16

LDI R16,0x07 //Seven Segment Bits for 7


MOV R7,R16

LDI R16,0x7F //Seven Segment Bits for 8


MOV R8,R16

LDI R16,0x6F //Seven Segment Bits for 9


MOV R9,R16

LDI R16,0XFF
OUT DDRA,R16

LDI R27,0x00; // XH of the register pair X


LDI R26,0x0A; // XL of the register pair X

MAIN: LD R16,-X
OUT PORTA,R16
CALL Delay
CPI R26,0X00
BRNE MAIN
LDI R26,0x0A
JMP MAIN

Delay: LDI R17,0xFF


L1: LDI R18,0xFF
L2: LDI R19,0x04
L3: NOP
DEC R19

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.

Assignment2: Write the C code for the above Experiment

 A Real-Time Example: Road Traffic Signaling


// Road Traffic Signaling

.INCLUDE "M32DEF.INC"
.ORG 0X0000

LDI R16,HIGH(RAMEND)
OUT SPH,R16
LDI R16,LOW(RAMEND)
OUT SPL,R16

LDI R16,0x3F //Seven Segment Bits for 0


MOV R0,R16

LDI R16,0x06 //Seven Segment Bits for 1


MOV R1,R16

LDI R16,0x5B //Seven Segment Bits for 2


MOV R2,R16

LDI R16,0x4F //Seven Segment Bits for 3


MOV R3,R16

LDI R16,0x66 //Seven Segment Bits for 4


MOV R4,R16

LDI R16,0x6D //Seven Segment Bits for 5


MOV R5,R16

LDI R16,0x7D //Seven Segment Bits for 6

9
Embedded System on AVR ATMEGA32:Exp2

MOV R6,R16

LDI R16,0x07 //Seven Segment Bits for 7


MOV R7,R16

LDI R16,0x7F //Seven Segment Bits for 8


MOV R8,R16

LDI R16,0x6F //Seven Segment Bits for 9


MOV R9,R16

LDI R16,0XFF
OUT DDRA,R16 //For 7 Segment Display

LDI R16,0x03
OUT DDRC,R16 //For Signaling LEDs

LDI R27,0x00; // XH of the register pair X


LDI R26,0x0A; // XL of the register pair X

MAIN: SBI PORTC,PINC0


CBI PORTC,PINC1
MLOOP1: LD R16,-X
OUT PORTA,R16
CALL Delay
CPI R26,0X00
BRNE MLOOP1
LDI R26,0x0A

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

Delay: LDI R17,0xFF


L1: LDI R18,0xFF
L2: LDI R19,0x04

10
Embedded System on AVR ATMEGA32:Exp2

L3: NOP
DEC R19
BRNE L3
DEC R18
BRNE L2
DEC R17
BRNE L1
RET

 Make the below Circuit on SimulIDE to simulate


Components Required:
1. ATmega32
2. Seven Segment LED Display
3. 100 Ohm DIP Resistor
4. Fixed Voltage
5. Push Button
6. 10KOhm Resistor
7. 100nF Capacitor
8. Two 100 Ohm Resistor
9. One Green LED
10. One Red LED

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

 Hardware Simulation of Experiments


Components Required:
1. ATmega32
2. AVR development board
3. USBasp
4. Seven Segment LED Display (Common Cathode)
5. 100 Ohm Resistors: 9Pcs
6. One Green LED
7. One Red LED
8. Bread Board
9. Jumper Wires Female to Male: 10Pcs
10. Single Stand Wires as Required
Make the circuit on bread board as the Last Experiment on SimulIDE
and Flash the Microcontroller with respective HEX file.

Assignment4: Experiment on SimulIDE with Double Digit


Multiplex Display for the Road Traffic Signalling to decrement
the digit value from 30 to 00.

12

You might also like