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.

TM4C123GH6PM: Problem with SSI

Part Number: TM4C123GH6PM


I have a library for 5110 lcd but it is written by using registers, and sometimes it blocks some of other peripherals. Now I want to drive 5110 lcd by using driverlib and I found library in forum. But the thing is on my custom pcb lcd is connected to ssi0 base and PA4 is used for backlight. I see that PA4 is rx pin of SSI and it is not needed to drive lcd. Without a modification library works properly, but when I add lines below, it goes fault_isr.

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_4); // goes Fault_isr at exactly that line

I tried to place these 2 lines to different locations but result is either it goes fault_isr or it has no effect.

By the way, I use the line below in main.c after lcd_init called,

GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_4, 16);

The rest of the init code:

void all_tasks_manager(void) 
{     
    uint32_t ready_count;
    
    
/* cs high initially */    
    SysCtlGPIOAHBEnable(CE_PERIPH);
    SysCtlPeripheralEnable(CE_PERIPH);
    
    ready_count = 2000U;
    while( (!(SysCtlPeripheralReady(CE_PERIPH)))  &&  (--ready_count));
    if(0U == ready_count)   /* if periph not ready take action */
    {
    }    
    GPIOPinTypeGPIOOutput(CE_BASE, CE_PIN);
    CE_HIGH();      
    
/* reset low initially */    
    SysCtlGPIOAHBEnable(RESET_PERIPH);
    SysCtlPeripheralEnable(RESET_PERIPH);
    
    ready_count = 2000U;
    while( (!(SysCtlPeripheralReady(RESET_PERIPH)))  &&  (--ready_count));
    if(0U == ready_count)   /* if periph not ready take action */
    {
    }    
    
    GPIOPinTypeGPIOOutput(RESET_BASE, RESET_PIN);
    RESET_LOW();    
      
/* dc low initially */    
    SysCtlGPIOAHBEnable(DC_PERIPH);
    SysCtlPeripheralEnable(DC_PERIPH);
    
    ready_count = 2000U;
    while( (!(SysCtlPeripheralReady(DC_PERIPH)))  &&  (--ready_count));
    if(0U == ready_count)   /* if periph not ready take action */
    {
    }    
    
    GPIOPinTypeGPIOOutput(DC_BASE, DC_PIN);
    DC_LOW();        
    
    
    
/* enable SSI0 module */    
    SysCtlPeripheralDisable(SYSCTL_PERIPH_SSI0);
    SysCtlPeripheralReset(SYSCTL_PERIPH_SSI0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    while( (!(SysCtlPeripheralReady(SYSCTL_PERIPH_SSI0)))  &&  (--ready_count));
    if(0U == ready_count)   /* if periph not ready take action */
    {
    }        
    
/* enable clk */
    SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    while( (!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA)))  &&  (--ready_count));
    if(0U == ready_count)   /* if periph not ready take action */
    {
    }      
    GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    GPIOPinTypeSSI(GPIO_PORTA_AHB_BASE , GPIO_PIN_2);
    
/* enable rx */
//    SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOA);    
//    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//    while( (!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA)))  &&  (--ready_count));
//    if(0U == ready_count)   /* if periph not ready take action */
//    {
//    }
//    GPIOPinConfigure(GPIO_PA4_SSI0RX);
//    GPIOPinTypeSSI(GPIO_PORTA_AHB_BASE , GPIO_PIN_4);    
    
/* enable tx */
    SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOA);    
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    while( (!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA)))  &&  (--ready_count));
    if(0U == ready_count)   /* if periph not ready take action */
    {
    }      
    GPIOPinConfigure(GPIO_PA5_SSI0TX);
    GPIOPinTypeSSI(GPIO_PORTA_AHB_BASE , GPIO_PIN_5);       
    
/* disable SPi first */ 
    SSIDisable(SSI0_BASE);
    SSIDMADisable(SSI0_BASE , SSI_DMA_RX | SSI_DMA_TX);
    SSIIntDisable(SSI0_BASE , SSI_TXFF | SSI_RXFF | SSI_RXTO | SSI_RXOR);
    SSIIntClear(SSI0_BASE , SSI_RXTO | SSI_RXOR);
    
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_4);
    
/* SPI clock & congig */    
    SSIClockSourceSet(SSI0_BASE , SSI_CLOCK_SYSTEM);
    SSIConfigSetExpClk(SSI0_BASE , SysCtlClockGet() , SSI_FRF_MOTO_MODE_0 , SSI_MODE_MASTER , 3000000U , 8U);
    SSIEnable(SSI0_BASE);

  • Hello Furkan,

    I believe Issue #2 from our Common Development Problems post is relevant for your application, please review the info there and try to follow the suggestion and see if your issue resolves: e2e.ti.com/.../374640
  • Hi Ralph,

    I checked the the library line by line and I noticed "SysCtlGPIOAHBEnable(CE_PERIPH);" enables to make changes on PORTA by using macros(I am not sure that calls as macro). So I added these changes;

    GPIOPinTypeGPIOOutput(GPIO_PORTA_AHB_BASE, GPIO_PIN_4);
    do{ \
    HWREG(GPIO_PORTA_AHB_BASE + (GPIO_O_DATA + (GPIO_PIN_4 << 2))) = GPIO_PIN_4; \
    }while(0);

    later I called this function,

    GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_4, 16);

    And it worked, now I have working backlight.
  • Do note that you've (earlier) selected the "AHB" Port Bus - yet "write" to the "Non AHB" Port. That's an inconsistency - and I'm unsure if that will (always) work - and is doubtful to align w/"best practice."

    Should not that "GPIOPinWrite()" have targeted that (same) "GPIO_PORTA_AHB_BASE" rather than "GPIO_PORTA_BASE"?     (as your present code reveals)