Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Using MAX7219 Display Driver

Status
Not open for further replies.

thunderdog

Newbie level 5
Joined
Nov 10, 2009
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
california
Activity points
1,368
Hi, I am using the MAX7219 to control a LED display. However, I can't seem to get it to light any of the digits. To start, I would like to go into test mode to light all digits. The wiring seems to be correct. Also, the MAX7219 just seems to stay in shutdown mode (all digits high, segments low). I am probing all the pins to verify. I am bit-banging the instruction for test mode. Here is the function used:
static void MAX7219_SendByte (unsigned char dataout)
{
char i;
for (i=8; i>0; i--) {
unsigned char mask = 1 << (i - 1); // calculate bitmask
PTFD_PTFD2 = 0 ; // bring CLK low
if (dataout & mask) // output one data bit
PTFD_PTFD5 = 1; // "1"
else // or
PTFD_PTFD5 = 0; // "0"
PTFD_PTFD2 = 1 ; // bring CLK high
PTFD_PTFD2 = 0 ; // bring CLK low
}
}
Single stepping through the code, I'm measuring the inputs to the relevant pins on the MAX7219 and they seem to be getting the correct inputs (CLK, Data and Load).
I am just sending 2 bytes as follows:
// Load low
SendByte (0x0F);
SendByte (0x01);
// Load (CS) high, then low

I expect to see all digits lit at this point.
Any suggestions welcome.
 

HI

1) Upload your schematic

2) Where is the CS signal in your code?

All the best

Bobi

The microcontroller specialist
 

Hi,

I think the problem is that you don't initialize the chip before using it ...

Try this :

/*
* Project name:
Serial_7seg_x8_Test
* Copyright:
(c) Mikroelektronika, 2009.
* Revision History:
- initial release - 2007.
- modified by Slavisa Zlatanovic - 14.05.2009.
* Description:
This code demonstrates working with MAX7219 on the Serial 7-Seg 8-Digit board.
Eight 7-Seg displays are connected to MAX7219 which communicates with MCU via SPI.
* Test configuration:
MCU: P16F887
Dev.Board: EasyPIC5
Oscillator: HS, 8.0 MHz
Ext. Modules: Serial 7-Seg 8-Digit board on PORTC
SW: mikroC PRO for PIC
Notes: Turn on PIC and CS0 switches on Serial 7-Seg 8-Digit board
*/

#define CHIP_SELECT F0

char i;

void max7219_init1() {
PORTC.CHIP_SELECT = 0; // Select MAX7219
SPI1_write(0x09); // BCD mode for digit decoding
SPI1_write(0xFF);
PORTC.CHIP_SELECT = 1; // Deselect MAX7219

PORTC.CHIP_SELECT = 0; // Select MAX7219
SPI1_write(0x0A);
SPI1_write(0x0F); // Segment luminosity intensity
PORTC.CHIP_SELECT = 1; // Deselect MAX7219

PORTC.CHIP_SELECT = 0; // Select MAX7219
SPI1_write(0x0B); // Set scan-limit
SPI1_write(0x07); // Display all 8 digits
PORTC.CHIP_SELECT = 1; // Deselect MAX7219

PORTC.CHIP_SELECT = 0; // Select MAX7219
SPI1_write(0x0C); // Set Shutdown register
SPI1_write(0x01); // Normal operation
PORTC.CHIP_SELECT = 1; // Deselect MAX7219

PORTC.CHIP_SELECT = 0; // Select MAX7219
SPI1_write(0x00);
SPI1_write(0xFF); // No test
PORTC.CHIP_SELECT = 1; // Deselect MAX7219
}

void main() {

TRISC.CHIP_SELECT = 0; // Set RC0 pin as output

SPI1_init(); // Initialize SPI module

max7219_init1(); // Initialize MAX7219


for (i = 1; i<=8; i++) {
PORTC.CHIP_SELECT = 0; // Select MAX7219
SPI1_write(i); // Send i to MAX7219 (digit place)
SPI1_write(8-i); // Send 8-i to MAX7219 (digit value)
PORTC.CHIP_SELECT = 1; // Deselect MAX7219
}
// The result is "01234567" written on the 7-Seg displays
}//~!
 

After hacking on this for awhile this afternoon, I finally got the circuit working. It seems that the bus clock on the uP was too fast. Thanks for your suggestions.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top