2013-11-07

MAX7219 Cascading 3 tested OK
































Now I have built up my confidence in cascading MAX7219s, though I am not very sure if my function can independently entertain one matrix LED without problem.

Anyway, I carried on my pair (SPI 0 and 1 at the same time) and incremental (adding matrix LEDs one by one) development/testing procedure, and tested one more matrix/7 segment LED module.

Now SPI0 talks to only one MAX7219 which drives 8 7-segment LEDs.

SPI1 talks to 3 MAX7219s, which drive 2 8x8 matrix LED, and 1 7-segment LED.

I modified the MAX7219 setup function for BCD Decode B and then test the whole thing again.


void max7219MatrixLed03(uint8_t spiChannelNumber)
{
    // *** Print project title ***********************************************
printf("\n\n*** Matrix LED 03 - 2013nov07hkt1203 ***\n\n");

// *** Setup MAX7219 digit control register buffer ***********************
    #define MAX_DEVICE_NUMBER 16 // maximum 16 MAX7219 devices
#define ADDRESS_INDEX 0
#define DATA_INDEX 1

    uint8_t deviceNumber;

    deviceNumber = 1;

    // *** Setup MAX7219 for digit decode and scan limit ***
    setUpMax7219NoDecode02(deviceNumber, spiChannelNumber);

    // *** Display 8 digits ***

    writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);

    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_7, char_O[0]);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_6, char_O[1]);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_5, char_O[2]);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_4, char_O[3]);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_3, char_O[4]);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_2, PATTERN_ALL_OFF);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_1, PATTERN_ALL_OFF);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_0, PATTERN_ALL_OFF);

    writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, NORMAL);

    deviceNumber = 2;

    // *** Setup MAX7219 for no digit decode and scan limit ***
    setUpMax7219NoDecode02(deviceNumber, spiChannelNumber);

    // *** Display 8 digits ***

    writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);

    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_7, char_K[0]);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_6, char_K[1]);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_5, char_K[2]);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_4, char_K[3]);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_3, char_K[4]);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_2, PATTERN_ALL_OFF);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_1, PATTERN_ALL_OFF);
    displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_0, PATTERN_ALL_OFF);

    writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, NORMAL);

    deviceNumber = 3;

        // *** Setup MAX7219 for digit decode and scan limit ***
        setUpMax7219BcdCodeB03(deviceNumber, spiChannelNumber);

        // *** Display 8 digits ***

        writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, SHUT_DOWN);

        // *** Display 8 digits ***

        displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_7, DIGIT_2);
        displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_6, DIGIT_0);
        displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_5, DIGIT_1);
        displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_4, DIGIT_3);
        displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_3, DIGIT_1);
        displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_2, DIGIT_1);
        displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_1, DIGIT_0);
        displayOneDigit02(deviceNumber, spiChannelNumber, DIGIT_ADDR_0, DIGIT_7);

        writeLedCommand02(deviceNumber, spiChannelNumber, OPERATION_ADDR, NORMAL);
}

...

The test program ran successfully the first time!  

Lunch time.  

.END

No comments:

Post a Comment