2013-10-24

Max7219 shutdown test OK

It took me some 15 minutes to troubleshoot.  I found the 3V3/5V0 not working properly.  So I used 3V3 SPI to direct drive MAX7219 and found it OK.  The MAX7219 can now blink at 1 Hz.

    // *** Normal operation 1 second, shut down 1 second ***
    while (1)
    {
    writeMax7219CommandToBuffer(digitControlRegisterBuffer, SHUTDOWN_ADDR, 
                                NORMAL_OPERATION_MODE);
setSselLow();
SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
setSselHigh();

delayTime(ONE_SECOND);

    writeMax7219CommandToBuffer(digitControlRegisterBuffer, SHUTDOWN_ADDR, SHUTDOWN_MODE);
setSselLow();
SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
setSselHigh();

delayTime(ONE_SECOND);
    }

// ***********************************************************************
// spi050.h 2013oct24hk2228
// ***********************************************************************

#include "gpio050.h"
#include "led050.h"
#include "lpc11xx_ssp.h"
#include "semihosting.h"
#include "stdio.h"

// ***********************************************************************
// Max7219 Functions
// ***********************************************************************

void max7219v01() // 2013oct24hkt2229
{
    // *** Print project title ***********************************************
printf("*** MAX7219 Test - 2013oct24hk0937 ***\n\n");


// *** Setup MAX7219 digit control register buffer ***********************
// Digit control register buffer
#define BUFFER_SIZE 2
#define ADDRESS_INDEX 0
#define DATA_INDEX 1

uint8_t digitControlRegisterBuffer[BUFFER_SIZE];
uint8_t dummyReceiveBuffer[BUFFER_SIZE];


// *** Set up SPI ********************************************************
// Setup SCLK and SSEL
setUpSpi050(SCK0_PIO0_6);
setupSpiSsel();

// Setup xferConfig
    SSP_DATA_SETUP_Type xferConfig;
    xferConfig.tx_data = (void*)digitControlRegisterBuffer;
    xferConfig.rx_data = (void*)dummyReceiveBuffer;
    xferConfig.length = BUFFER_SIZE;


// *** Setup Max7219 digit and control ***********************************
    // Register addresses
#define NO_OP_ADDR 0x00
#define DIGIT_0_ADDR 0x01
    #define DIGIT_1_ADDR 0x02
#define DIGIT_2_ADDR 0x03
#define DIGIT_3_ADDR 0x04
#define DIGIT_4_ADDR 0x05
#define DIGIT_5_ADDR 0x06
#define DIGIT_6_ADDR 0x07
#define DIGIT_7_ADDR 0x08
#define DECODE_MODE_ADDR 0x09
#define INTENSITY       0x0a
#define SCAN_LIMIT_ADDR 0x0b
#define SHUTDOWN_ADDR   0x0c
#define DISPLAY_TEST     0x0f

// Control byte
#define SHUTDOWN_MODE 0x00
#define NORMAL_OPERATION_MODE 0x01

    // *** Test Max7219 ******************************************************

    // *** Normal operation 1 second, shut down 1 second ***
    while (1)
    {
    writeMax7219CommandToBuffer(digitControlRegisterBuffer, SHUTDOWN_ADDR, NORMAL_OPERATION_MODE);
setSselLow();
SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
setSselHigh();

delayTime(ONE_SECOND);

    writeMax7219CommandToBuffer(digitControlRegisterBuffer, SHUTDOWN_ADDR, SHUTDOWN_MODE);
setSselLow();
SSP_ReadWrite(LPC_SSP0, &xferConfig, SSP_TRANSFER_POLLING);
setSselHigh();

delayTime(ONE_SECOND);
    }
}

void writeMax7219CommandToBuffer(uint8_t digitControlRegisterBuffer[BUFFER_SIZE], \
                    uint8_t commandRegisterAddress, uint8_t command)
{
digitControlRegisterBuffer[ADDRESS_INDEX] = commandRegisterAddress;
digitControlRegisterBuffer[DATA_INDEX] = command;
}

// ***********************************************************************
// End of max7219
// ***********************************************************************

.END

No comments:

Post a Comment