This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHXL2-RM57L: Connect a 8x16 LED Matrix to LAUNCHXL2-RM57L

Part Number: LAUNCHXL2-RM57L
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

Hello,

the LED Matrix (RPi LED Matrix http://anleitung.joy-it.net/wp-content/uploads/2016/12/rpi_led_matrix.pdf) is supported by raspberry  pi and is using two MAX7219 (Link: https://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf).

In this project I am using the spi4 connected to the matrix as following:

5V --->   (J3_pin 1)

GND ---> (J3_pin2)

CS ---> SPI4NCS_1 (J1_pin9)

MOSI ---> SPI4MOSI (J2_pin1)

CLK ---> SPI4_clk (J10_pin20)

At first I am only trying to make the matrix work therfore I wrote this example but still :(

Here is the code:

/* USER CODE BEGIN (0) */
#include "HL_spi.h"
#include "HL_gio.h"
/* USER CODE END */

/* Include Files */

#include "HL_system.h"
#include "HL_sys_common.h"

/* USER CODE BEGIN (1) */

#define TEST 0x0F
#define BRIGHTNESS 0x0A
#define SCAN_LIMIT 0x0B
#define DECODE_MODE 0x09
#define SHUTDOWN 0x0C

spiDAT1_t dataconfig1_t;

uint64_t i;

void maxInit();

void TransferCOMMAND(uint16 address, uint16 value);

void TransferDATA(uint16 address, uint16 value, uint16 v2);

/* USER CODE END */


/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/

/* USER CODE BEGIN (2) */
/* USER CODE END */

void main(void)
{
/* USER CODE BEGIN (3) */
dataconfig1_t.CS_HOLD = FALSE;      
dataconfig1_t.WDEL = TRUE;              
dataconfig1_t.DFSEL = SPI_FMT_0;     
dataconfig1_t.CSNR = SPI_CS_1;   
spiInit();
gioInit();
maxInit();
gioSetDirection(spiPORT4, 0x02);  // use the CS_1 as gio pin (was also defined in Halcogen in /SPI4 Port/SCS[1] Pin Mode   to   GIO)
gioSetBit(spiPORT4, 1, 1);
_enable_IRQ();
/* USER CODE END */

while(1){
for(i=1; i<9; i++){
TransferDATA(i,0xFA, 0xAF);   // Just an example to see if it works
}
}
}


/* USER CODE BEGIN (4) */
void maxInit(){
TransferCOMMAND(DECODE_MODE, 0x00); // uses normal mode
TransferCOMMAND(BRIGHTNESS, 0x03);  // brightness level 3
TransferCOMMAND(SCAN_LIMIT, 0x07);
for(i=1; i<9; i++){   // Init all LEDS
TransferDATA(i,0x00, 0x00);
}
TransferCOMMAND(SHUTDOWN, 0x01);
TransferCOMMAND(TEST, 0x00); // normal mode
}

void TransferCOMMAND(uint16 address, uint16 value) {
gioSetBit(spiPORT4, 1, 0);
spiTransmitData(spiREG4, &dataconfig1_t, 1, address); // Transmit address.
spiTransmitData(spiREG4, &dataconfig1_t, 1, value); // Transmit the value.
spiTransmitData(spiREG4, &dataconfig1_t, 1, address); // Transmit address.
spiTransmitData(spiREG4, &dataconfig1_t, 1, value); // Transmit the value.
gioSetBit(spiPORT4, 1, 1);
};

void TransferDATA(uint16 address, uint16 value, uint16 v2) {
gioSetBit(spiPORT4, 1, 0);
spiTransmitData(spiREG4, &dataconfig1_t, 1, address); // Transmit address.
spiTransmitData(spiREG4, &dataconfig1_t, 1, value); // Transmit the value.
spiTransmitData(spiREG4, &dataconfig1_t, 1, address); // Transmit address.
spiTransmitData(spiREG4, &dataconfig1_t, 1, v2); // Transmit the second value.
gioSetBit(spiPORT4, 1, 1);
}