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.

Scrolling LED Display using Tiva C series

Hi,

       I am working with TM4C123GXL launchpad and Keil IDE for developing 8*8 LED Matrix Display. I am using two 74HC595 IC's one for row and another for column and interfaced with Tiva using two SPI ports. When checked, the data is getting correctly but there is something went wrong in the led scrolling.I had done several changes in the coding but can't figure out the exact problem. Here I am attaching the coding along with this post and need urgent  solution for this

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_ssi.h"
#include "inc/hw_types.h"
#include "driverlib/ssi.h"
#include "driverlib/gpio.h"
#include "driverlib/uart.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "utils/uartstdio.h"

#define NUM_SSI_DATA 256


char ALPHABETS[NUM_SSI_DATA] = 
							{ 0x7F, 0x88, 0x88, 0x88, 0x7F, 0x00,	0x00, 0x00,
								0xFF, 0x91, 0x91, 0x91, 0x6E, 0x00,	0x00, 0x00,
								0x7E, 0x81, 0x81, 0x81, 0x42, 0x00,	0x00, 0x00,
								0xFF, 0x81, 0x81, 0x42, 0x3C, 0x00,	0x00, 0x00,
								0xFF, 0x91, 0x91, 0x91, 0x81, 0x00,	0x00, 0x00,
								0xFF, 0x90, 0x90, 0x90, 0x80, 0x00,	0x00, 0x00,
								0x7E, 0x81, 0x89, 0x89, 0x4E, 0x00,	0x00, 0x00,
								0xFF, 0x10, 0x10, 0x10, 0xFF, 0x00,	0x00, 0x00,
								0x81, 0x81, 0xFF, 0x81, 0x81, 0x00,	0x00, 0x00,
								0x06, 0x01, 0x01, 0x01, 0xFE, 0x00,	0x00, 0x00,
								0xFF, 0x18, 0x24, 0x42, 0x81, 0x00,	0x00, 0x00,
								0xFF, 0x01, 0x01, 0x01, 0x01, 0x00,	0x00, 0x00,
								0xFF, 0x40, 0x30, 0x40, 0xFF, 0x00,	0x00, 0x00,
								0xFF, 0x40, 0x30, 0x08, 0xFF, 0x00,	0x00, 0x00,
								0x7E, 0x81, 0x81, 0x81, 0x7E, 0x00,	0x00, 0x00,
								0xFF, 0x88, 0x88, 0x88, 0x70, 0x00,	0x00, 0x00,
								0x7E, 0x81, 0x85, 0x82, 0x7D, 0x00,	0x00, 0x00,
								0xFF, 0x88, 0x8C, 0x8A, 0x71, 0x00,	0x00, 0x00,
								0x61, 0x91, 0x91, 0x91, 0x8E, 0x00,	0x00, 0x00,
								0x80, 0x80, 0xFF, 0x80, 0x80, 0x00,	0x00, 0x00,
								0xFE, 0x01, 0x01, 0x01, 0xFE, 0x00,	0x00, 0x00,
								0xF0, 0x0C, 0x03, 0x0C, 0xF0, 0x00,	0x00, 0x00,
								0xFF, 0x02, 0x0C, 0x02, 0xFF, 0x00,	0x00, 0x00,
								0xC3, 0x24, 0x18, 0x24, 0xC3, 0x00,	0x00, 0x00,
								0xE0, 0x10, 0x0F, 0x10, 0xE0, 0x00,	0x00, 0x00,
								0x83, 0x85, 0x99, 0xA1, 0xC1, 0x00,	0x00, 0x00};

								
const char col_arr1[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};	
const char col_arr2[] = {0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF};


//*****************************************************************************
//
// Configure the UART and its pins.  This must be called before UARTprintf().
//
//*****************************************************************************
/*void
ConfigureUART(void)
{
    //
    // Enable the GPIO Peripheral used by the UART.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    //
    // Enable UART0
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    //
    // Configure GPIO Pins for UART mode.
    //
    GPIOPinConfigure(GPIO_PA0_U0RX);
    GPIOPinConfigure(GPIO_PA1_U0TX);
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Use the internal 16MHz oscillator as the UART clock source.
    //
    UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

    //
    // Initialize the UART for console I/O.
    //
    UARTStdioConfig(0, 9600, 16000000);
}
*/
	
	uint8_t ui32tx_cnt;
	uint8_t nxt_alpha = 0;
	uint32_t ui32tx_data;
	uint32_t alpha_cnt, char_cnt;
	uint8_t column;
	uint8_t bit_cnt = 0;
	uint32_t count = 1;
	uint32_t col_cnt = 0;
	//uint8_t col_inc	=	0;



int main(void)
{
	//bool col_inc	=	0;

	
	
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

	GPIOPinConfigure(GPIO_PA2_SSI0CLK);
	GPIOPinConfigure(GPIO_PA3_SSI0FSS);
	GPIOPinConfigure(GPIO_PA5_SSI0TX);
	GPIOPinConfigure(GPIO_PB4_SSI2CLK);
	GPIOPinConfigure(GPIO_PB5_SSI2FSS);
	GPIOPinConfigure(GPIO_PB7_SSI2TX);
	
	GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_5|GPIO_PIN_3|GPIO_PIN_2);
	GPIOPinTypeSSI(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7);

   //ConfigureUART();

    //UARTprintf("*********8X8 LED DOT MATRIX*********\n");
    SysCtlDelay(10000);
	
	SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 100000, 8);
	SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 100000, 8);
	SSIEnable(SSI0_BASE);
	SSIEnable(SSI2_BASE);
	//while(1){

//////////////////////////////////////////////////////////////////////////////////////////
////          Just printing some english alphabets as in the ALPHABETS array     ////////
////////////////////////////////////////////////////////////////////////////////////////
	
for(alpha_cnt = 0;alpha_cnt < 156;alpha_cnt++){

///////////////////////////////////////////////////////////////////////////////////////
/////  Char_cnt determines the speed of the scrolling            /////////////////////
/////////////////////////////////////////////////////////////////////////////////////
 
		for(char_cnt = 0;char_cnt < 14000;char_cnt++){

////////////////////////////////////////////////////////////////////////////////////
///////  ui32tx_cnt determines the scrolling and displaying ///////////////////////
//////////////////////////////////////////////////////////////////////////////////
 
			for(ui32tx_cnt = 1;ui32tx_cnt < count;ui32tx_cnt++)
			{
			ALPHABETS[ui32tx_cnt] = ALPHABETS[ui32tx_cnt + nxt_alpha];
			ui32tx_data = ALPHABETS[ui32tx_cnt];
			GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, 0);
			GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0);
			SSIDataPutNonBlocking(SSI2_BASE, (~ui32tx_data));
			column = col_arr1[ui32tx_cnt];
			SSIDataPutNonBlocking(SSI0_BASE, column);
				
			GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_PIN_3);	
			GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_PIN_5);
			//UARTprintf("%x\t",ui32tx_data);
			//UARTCharPut(UART0_BASE, column);	
			}																				
			//UARTprintf("\n");	
	}																				
		//col_cnt++;
	if(count == 8){
		count = 1;}
		else{
		count++;
		}
		bit_cnt++;
		if(bit_cnt > 8){
		nxt_alpha++;
		}
	}																					
		//column = 0;
		//col_inc = 0;
	//}
}

  • Hi,

    In the absence of some electrical diagrams to understand your project, several "urgent" observations:

    a) the variables alpha_cnt and char_cnt are tested against some weird values, i.e. 156 and 14000 - 

    b) the variable count is initialised with 1 so the for loop executes only once and the programs exit main, going into landscape. Not sure about SPI use, may be wrong, since you double use the SSIFSS pins: you configure them as SSIFSS (automatically managed by the micro) and then manage manually.

    Petrei

  • Hi Petrei,

                       Unfortunately I had posted the wrong source code, here I am attaching the code that I had already checked. About the values 156 and 14000 are used for alphabet counting and speed adjustment. If the value 14000 is increased, the speed of scrolling will reduces

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_ssi.h"
    #include "inc/hw_types.h"
    #include "driverlib/ssi.h"
    #include "driverlib/gpio.h"
    #include "driverlib/uart.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "utils/uartstdio.h"
    #define NUM_SSI_DATA 256
    char ALPHABETS[NUM_SSI_DATA] =
                                { 0x7F, 0x88, 0x88, 0x88, 0x7F, 0x00,   0x00, 0x00,
                                    0xFF, 0x91, 0x91, 0x91, 0x6E, 0x00, 0x00, 0x00,
                                    0x7E, 0x81, 0x81, 0x81, 0x42, 0x00, 0x00, 0x00,
                                    0xFF, 0x81, 0x81, 0x42, 0x3C, 0x00, 0x00, 0x00,
                                    0xFF, 0x91, 0x91, 0x91, 0x81, 0x00, 0x00, 0x00,
                                    0xFF, 0x90, 0x90, 0x90, 0x80, 0x00, 0x00, 0x00,
                                    0x7E, 0x81, 0x89, 0x89, 0x4E, 0x00, 0x00, 0x00,
                                    0xFF, 0x10, 0x10, 0x10, 0xFF, 0x00, 0x00, 0x00,
                                    0x81, 0x81, 0xFF, 0x81, 0x81, 0x00, 0x00, 0x00,
                                    0x06, 0x01, 0x01, 0x01, 0xFE, 0x00, 0x00, 0x00,
                                    0xFF, 0x18, 0x24, 0x42, 0x81, 0x00, 0x00, 0x00,
                                    0xFF, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
                                    0xFF, 0x40, 0x30, 0x40, 0xFF, 0x00, 0x00, 0x00,
                                    0xFF, 0x40, 0x30, 0x08, 0xFF, 0x00, 0x00, 0x00,
                                    0x7E, 0x81, 0x81, 0x81, 0x7E, 0x00, 0x00, 0x00,
                                    0xFF, 0x88, 0x88, 0x88, 0x70, 0x00, 0x00, 0x00,
                                    0x7E, 0x81, 0x85, 0x82, 0x7D, 0x00, 0x00, 0x00,
                                    0xFF, 0x88, 0x8C, 0x8A, 0x71, 0x00, 0x00, 0x00,
                                    0x61, 0x91, 0x91, 0x91, 0x8E, 0x00, 0x00, 0x00,
                                    0x80, 0x80, 0xFF, 0x80, 0x80, 0x00, 0x00, 0x00,
                                    0xFE, 0x01, 0x01, 0x01, 0xFE, 0x00, 0x00, 0x00,
                                    0xF0, 0x0C, 0x03, 0x0C, 0xF0, 0x00, 0x00, 0x00,
                                    0xFF, 0x02, 0x0C, 0x02, 0xFF, 0x00, 0x00, 0x00,
                                    0xC3, 0x24, 0x18, 0x24, 0xC3, 0x00, 0x00, 0x00,
                                    0xE0, 0x10, 0x0F, 0x10, 0xE0, 0x00, 0x00, 0x00,
                                    0x83, 0x85, 0x99, 0xA1, 0xC1, 0x00, 0x00, 0x00};
                                    
    const char col_arr1[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};  
    //*****************************************************************************
    //
    // Configure the UART and its pins.  This must be called before UARTprintf().
    //
    //*****************************************************************************
    /*void
    ConfigureUART(void)
    {
        //
        // Enable the GPIO Peripheral used by the UART.
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
        //
        // Enable UART0
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
        //
        // Configure GPIO Pins for UART mode.
        //
        GPIOPinConfigure(GPIO_PA0_U0RX);
        GPIOPinConfigure(GPIO_PA1_U0TX);
        GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
        //
        // Use the internal 16MHz oscillator as the UART clock source.
        //
        UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
        //
        // Initialize the UART for console I/O.
        //
        UARTStdioConfig(0, 9600, 16000000);
    }
    */
        
        uint8_t ui32tx_cnt;
        uint8_t nxt_alpha = 0;
        uint32_t ui32tx_data;
        uint32_t alpha_cnt, char_cnt;
        uint8_t column;
        uint8_t bit_cnt = 0;
        uint32_t count = 1;
        uint32_t col_cnt = 0;
        //uint8_t col_inc   =   0;
    int main(void)
    {
        //bool col_inc  =   0;
        
        
        SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
        GPIOPinConfigure(GPIO_PA2_SSI0CLK);
        GPIOPinConfigure(GPIO_PA3_SSI0FSS);
        GPIOPinConfigure(GPIO_PA5_SSI0TX);
        GPIOPinConfigure(GPIO_PB4_SSI2CLK);
        GPIOPinConfigure(GPIO_PB5_SSI2FSS);
        GPIOPinConfigure(GPIO_PB7_SSI2TX);
        
        GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_5|GPIO_PIN_3|GPIO_PIN_2);
        GPIOPinTypeSSI(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7);
       //ConfigureUART();
        //UARTprintf("*********8X8 LED DOT MATRIX*********\n");
        SysCtlDelay(10000);
        
        SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 100000, 8);
        SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 100000, 8);
        SSIEnable(SSI0_BASE);
        SSIEnable(SSI2_BASE);
        //while(1){
    //////////////////////////////////////////////////////////////////////////////////////////
    ////          Just printing some english alphabets as in the ALPHABETS array     ////////
    ////////////////////////////////////////////////////////////////////////////////////////
        
    for(alpha_cnt = 0;alpha_cnt < 156;alpha_cnt++){
    ///////////////////////////////////////////////////////////////////////////////////////
    /////  Char_cnt determines the speed of the scrolling            /////////////////////
    /////////////////////////////////////////////////////////////////////////////////////
     
            for(char_cnt = 0;char_cnt < 14000;char_cnt++){
    ////////////////////////////////////////////////////////////////////////////////////
    ///////  ui32tx_cnt determines the scrolling and displaying ///////////////////////
    //////////////////////////////////////////////////////////////////////////////////
     
                for(ui32tx_cnt = 0;ui32tx_cnt < count;ui32tx_cnt++)
                {
                ALPHABETS[ui32tx_cnt] = ALPHABETS[ui32tx_cnt + nxt_alpha];
                ui32tx_data = ALPHABETS[ui32tx_cnt];
                GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, 0);
                GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0);
                SSIDataPutNonBlocking(SSI2_BASE, (~ui32tx_data));
                column = col_arr1[ui32tx_cnt];
                SSIDataPutNonBlocking(SSI0_BASE, column);
                    
                GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_PIN_3); 
                GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_PIN_5);
                //UARTprintf("%x\t",ui32tx_data);
                //UARTCharPut(UART0_BASE, column); 
                }                                                                              
                //UARTprintf("\n");
        }                                                                              
            //col_cnt++;
        if(count == 8){
            count = 1;}
            else{
            count++;
            }
            bit_cnt++;
            if(bit_cnt > 7){
            nxt_alpha++;
            }
        }                                                                                  
            //column = 0;
            //col_inc = 0;
        //}
    }


    Regards

    Nithin

  • Hi,

    I think is still the old code, no changes. Please check braces matching in main function. I cannot see a while(1) block, so your code will exit to landscape (out of main), suppose it crashes. Am I right?

    Petrei