0% found this document useful (0 votes)
53 views3 pages

Lab Experiment 10

The document describes an experiment using the MAX7221 IC to interface with an AVR microcontroller over SPI to control 7-segment displays. The MAX7221 allows controlling up to 8 7-segment LEDs using fewer pins than connecting them directly. It contains an internal decoder, brightness controls, and test mode. The lab tasks involve writing AVR programs to display "EL" and count from 1 to 9 on a double 7-segment display, configuring the AVR as SPI master to continuously send letter "A", and providing snapshots of simulation results.

Uploaded by

Aisha Shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views3 pages

Lab Experiment 10

The document describes an experiment using the MAX7221 IC to interface with an AVR microcontroller over SPI to control 7-segment displays. The MAX7221 allows controlling up to 8 7-segment LEDs using fewer pins than connecting them directly. It contains an internal decoder, brightness controls, and test mode. The lab tasks involve writing AVR programs to display "EL" and count from 1 to 9 on a double 7-segment display, configuring the AVR as SPI master to continuously send letter "A", and providing snapshots of simulation results.

Uploaded by

Aisha Shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

DEPARTMENT OF ELECTRICAL ENGINEERING

MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO

Introduction to Embedded Systems (4th Semester) 19EL

Lab Experiment#10

Roll No. ___________________________________________ Submission Date: _______________________

LAB DATA ANALYSIS ABILITY TO


SUBJECT CALCULATION OBSERVATION
PERFORMANCE KNOWLEDGE
AND CONDUCT PRESENTATION
AND CODING /RESULTS
SCORE
INDICATOR INTERPRETATION EXPERIMENT

MAX7221 Interfacing and AVR Programing using SPI

Objective: To become familiar with MAX7221 IC and its programming using AVR
Microcontrollers via SPI protocol.

MAX7221 IC:
In many applications you need to connect two or more 7 segment LEDs
to a microcontroller. For example if you want to connect four 7 segment
LEDs directly to a microcontroller you need 4x8=32 pins. This is not
feasible. The MAX 7221 IC is an ideal chip for such applications since
it supports upto 8 7- segment LEDs. We can connect the MAX 7221 to
the AVR chip using SPI protocol and control upto 8 7- segment LEDs.
The MAX7221 contains an internal decoder that can be used to convert
binary numbers to 7 segment codes. The device includes analog and
digital brightness control, an 8x8 static RAM that stores each digit, and
a test mode that forces all LEDs On.

MAX7221 Connections to the AVR


DEPARTMENT OF ELECTRICAL ENGINEERING
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO

Introduction to Embedded Systems (4th Semester) 19EL

Lab Experiment#10

MAX7221 packet format

List of Commands in MAX7221

Set Decoding Mode (Command X9)

Example: Write an AVR program to display 57 on 7 segment

#include <avr/io.h>
# define MOSI 5
# define SCK 7
# define SS 4
void execute( unsigned char cmd, unsigned char data)
{
DEPARTMENT OF ELECTRICAL ENGINEERING
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO

Introduction to Embedded Systems (4th Semester) 19EL

Lab Experiment#10

PORTB &= ~(1<<SS);


SPDR=cmd;
while(!(SPSR & (1<<SPIF)));
SPDR= data;
while(!(SPSR & (1<<SPIF)));
PORTB |=(1<<SS);
}
int main(void)
{
DDRB= (1<<MOSI)|(1<<SCK)|(1<<SS);
SPCR=(1<<SPE)|(1<<MSTR)|(1<<SPR0);
execute(0x09,0b00000011); // enable decoding for digits 1,2
execute(0x0B,0x02); // scan two 7 segments
execute(0x0C,0x01); // turn on the chip
execute(0x01,0x07); // display 7 on digit 1
execute(0x02,0x05); // display 5 on digit 2
while (1);
return 0;
}

Lab Tasks:
 Write an AVR program, to display EL on the two digits of the 7-segment.
 Simulate an AVR program on Proteus which shows counting from 1 to 9.
 Configure AVR in master mode sending letter A continuously and observe the packet on SPI
Debugger.
 Attach the snapshots for the simulation results of all the tasks.

You might also like