## Introduction: ROLLING DISPLAY USING LED MATRIX

Hello All,

This is an instructable about creating a rolling display by connecting an LED matrix with TM4C123GXL development board.

I have tried to put forth a detailed explanation about the LED matrix and the technique to display the desired text using 8X8 Matrix.

## Step 1: Understanding LED Matrix

The 8 X 8 LED Matrix has 64 LEDs. The control of 64 LEDs would require 64 connections, making it impractical to use. A smarter and energy efficient (explained later) way is to connect the LEDs in a row/column configuration (making a matrix) thereby requiring 16 connections. Individual LED is switched on by supplying voltage across the corresponding row and column.

In the attached image(left) vertical lines of LEDs represent rows and right most vertical line corresponds to row 1. Similarly, a horizontal line of LEDs represents a column and topmost horizontal line corresponds to column 1.

The controller MAX7219 is used to display the data using the LED Matrix. Each row of the Matrix corresponds to one data register (Digits 0-7 for MAX7129) and the data corresponding to only one row is displayed at a time. we can also consider each row of the LED Matrix to be a 7 Segment Display with all the segments arranged in a straight line. The interesting part is that the rows are displayed at such a high speed that the human eye is unable to detect it and we see the complete image.

So each LED glows for a very small period thereby saving power in real terms.

The most critical part of displaying something is that we need to figure out the pattern of LEDs and convert it into a 8-bit format to be stored in the data registers.

The data to be displayed is stored in the internal RAM and the controller scans the rows at a high speed to display the content.

Suppose that I want to display a character R, I need to store {0x01,0x02,0x04, 0xF8,0x88, 0x88,0XFF,0XFF} in the data registers.

## Step 2: Using TM4C123GH6PM and MAX7219

TM4C123GH6PM is system-on-Chip(SoC) device designed around the ARM Cortex M4F core. TM4C123GH6PM and MAX7219 communicate using SSI. The MCU has 3 SSI modules and the corresponding GPIO pins should be activated to communicate with the LED Matrix.

MAX7219 needs to be programmed in No decode mode and appropriate Scan-Limit Register format should be selected to display all the digits(each digit corresponds to a row of LED Matrix).

Program the Shutdown Register format to Normal Operation mode.

The 8-bit pattern(display text) should be stored in an array.

A counter should be initialized to point to the initial element and then incremented be one to display the next set of 7 rows. To create a rolling effect appropriate delay should be programmed between each frame of 7 rows.

## Step 3: Program and Connections

Connect the corresponding pins of the two boards.

The complete program for displaying "RWDD" is as below:

#include<stdint.h>

#include<stdbool.h>

#include"tm4c123gh6pm.h"

#include"sysctl.h"

volatile unsigned long j=0;

volatile unsigned long a=0x0;

volatile unsigned long i=0;

void writedata(unsigned long data)

{ while((SSI0_SR_R&0X02)==0) { } SSI0_DR_R=data; }

void writecom(unsigned char data)

{ while((SSI0_SR_R&0X10)==0x10) { }

GPIO_PORTA_DATA_R&=~0X40;

SSI0_DR_R=data;

while((SSI0_SR_R&0X10)==0x10) { }

GPIO_PORTA_DATA_R|=0X40; }

const unsigned long name1[]= {

//{0xF1FF, 0xF2FF, 0xF388, 0xF488, 0xF588, 0xF688,0xF7FF,0xF8FF } // 30 0 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xFF,0xFF,0x88, 0x88, 0xF8,0x04,0x02, 0x01 // 31 1 // 31 1 , 0x00 , 0xFF,0x02,0x04, 0x08, 0x08, 0x04, 0x02,0xFF // 32 2 ,0x00 , 0xFF, 0x81,0x81, 0x42, 0x24,0x18 // 33 3

,0x00 ,0xFF, 0x81,0x81, 0x42, 0x24,0x18 ,0x00

};

void LED_Init()

{ SYSCTL_RCGCSSI_R|= 0x00000001;

SYSCTL_RCGC2_R|= 0x00000001;

SYSCTL_RCGC2_R|= 0x00000020;

i=0;

while(i<1000)

{ i=i+1; }

GPIO_PORTA_AFSEL_R=0X3F;

GPIO_PORTA_PCTL_R=0X00222200;

GPIO_PORTA_AMSEL_R=0X00;

GPIO_PORTA_DEN_R|=0XFF;

GPIO_PORTA_PUR_R|=0X08;

//GPIO_PORTA_PDR_R&=0XF7;

GPIO_PORTA_DIR_R|=0XEC; SSI0_CR1_R=0;

//SSI0_CC_R = (SSI0_CC_R&~SSI_CC_CS_M)+SSI_CC_CS_SYSPLL;

SSI0_CC_R =0X00;

SSI0_CR0_R=0X0F;

SSI0_CPSR_R|=0X02;

SSI0_CR1_R=0x02;

GPIO_PORTA_DATA_R&=~0X80; i=0;

while(i<20) {i=i+1; }

//SSI0_CR1_R=0x02;

GPIO_PORTA_DATA_R|=0X80;

GPIO_PORTA_DATA_R&=~0X40;

while((SSI0_SR_R&0X10)==0X10) { }

while((SSI0_SR_R&0X10)==0X10) { }

GPIO_PORTF_DIR_R=0XFF;

GPIO_PORTF_DEN_R=0XFF;

GPIO_PORTA_DATA_R|=0XC0; }

int main()

{LED_Init();

GPIO_PORTF_DATA_R=0XF5;

writedata(0xF900);

writedata(0xFBF7);

writedata(0xFFF0);

writedata(0xFCF1); i=0;

while (1) {

while(i<33)

{ writedata(0xF800+name1[i]);

writedata(0xF700+name1[i+1]);

writedata(0xF600+name1[i+2]);

writedata(0xF500+name1[i+3]);

writedata(0xF400+name1[i+4]);

writedata(0xF300+name1[i+5]);

writedata(0xF200+name1[i+6]);

writedata(0xF100+name1[i+7]);

j=0;

while(j<500000)

{j=j+1; }

i=i+1;

}

while(i<40)

{

writedata(0xF800+name1[i]);

if(i+1>=40) {writedata(0xF700+name1[i+1-40+8]);}

else {writedata(0xF700+name1[i+1]);}

if(i+2>=40) {writedata(0xF600+name1[i+2-40+8]);}

else {writedata(0xF600+name1[i+2]);}

if(i+3>=40) {writedata(0xF500+name1[i+3-40+8]);}

else {writedata(0xF500+name1[i+3]);}

if(i+4>=40) {writedata(0xF400+name1[i+4-40+8]);}

else {writedata(0xF400+name1[i+4]);}

if(i+5>=40) {writedata(0xF300+name1[i+5-40+8]);}

else {writedata(0xF300+name1[i+5]);}

if(i+6>=40) {writedata(0xF200+name1[i+6-40+8]);}

else {writedata(0xF200+name1[i+6]);}

if(i+7>=40) {writedata(0xF100+name1[i+7-40+8]);}

else {writedata(0xF100+name1[i+7]);}

j=0; while(j<500000) {j=j+1; }

i=i+1; }

if(i==40) {i=8; }

}

}