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.

Configuring GPIO port pin as output(for acting as FSS) for oled SSI Communiation .

Hi

Can any one please cross check the way i am trying to make GPIO port pin as output for making it to act as Chip select in OLED SSI communication.

Connection of "Reset " of oled is given to reset of tm4c123gh6pm.

In the code I am trying to make Port A6 as the FSS pin , by trying to configure the GPIO pin as output.

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_6, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIODirModeSet(GPIO_PORTA_BASE, GPIO_PIN_6 , GPIO_DIR_MODE_OUT);

Can I please get the quick response please.

#define DISPLAY_SSI_PERIPH          SYSCTL_PERIPH_SSI0
#define DISPLAY_SSI_GPIO_PERIPH     SYSCTL_PERIPH_GPIOA

#define DISPLAY_PINCFG_SSICLK       GPIO_PA2_SSI0CLK
#define DISPLAY_PINCFG_SSITX        GPIO_PA5_SSI0TX

#define DISPLAY_SSI_PORT            GPIO_PORTA_BASE
#define DISPLAY_SSI_PINS            (GPIO_PIN_2 | GPIO_PIN_6 | GPIO_PIN_5)

#define DISPLAY_D_C_PORT            GPIO_PORTA_BASE
#define DISPLAY_D_C_PIN             GPIO_PIN_7

#define DISPLAY_ENV_PORT            GPIO_PORTA_BASE
#define DISPLAY_ENV_PIN             GPIO_PIN_4

//*******************************SSD1306_SPI_INIT****************************
void SSD1306_SPI_Init(void)
{
  
     // Enable the peripherals used by this driver
    SysCtlPeripheralEnable(DISPLAY_SSI_PERIPH);
    SysCtlPeripheralEnable(DISPLAY_SSI_GPIO_PERIPH);
    
    // Select the SSI function for the appropriate pins
    GPIOPinConfigure(DISPLAY_PINCFG_SSICLK);

   SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
   GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_6, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
   GPIODirModeSet(GPIO_PORTA_BASE, GPIO_PIN_6 , GPIO_DIR_MODE_OUT); 

    GPIOPinConfigure(DISPLAY_PINCFG_SSITX);

    // Configure the pins for the SSI function
    GPIOPinTypeSSI(DISPLAY_SSI_PORT, DISPLAY_SSI_PINS);

    // Configure display control pins as GPIO output
    GPIOPinTypeGPIOOutput(DISPLAY_D_C_PORT, DISPLAY_D_C_PIN);
		   
    // Configure the SSI port
    SSIDisable(DISPLAY_SSI_BASE);
    SSIConfigSetExpClk( DISPLAY_SSI_BASE, SysCtlClockGet(),
                        SSI_FRF_MOTO_MODE_3, SSI_MODE_MASTER,
                        DISPLAY_SSI_CLOCK, 0x08 );
    SSIEnable(DISPLAY_SSI_BASE);

    // Send the initial configuration command bytes to the display
    SSD1306WriteCommand( g_ucDisplayInitCommands,
                         sizeof(g_ucDisplayInitCommands) );
  			
    //Set_Display_On_Off(0x01);
    gs_ucOled_Temp_Address_Array[0x00] = 0x01;
    SSD1306WriteCommand( gs_ucOled_Temp_Address_Array,
                         sizeof(gs_ucOled_Temp_Address_Array) );
    
	
 
}
//*******************************SSD1306WriteCommand****************************

static void
SSD1306WriteCommand(const unsigned char *pcCmd, unsigned long ulCount)
{
    // Wait for any previous SSI operation to finish.
    while(ROM_SSIBusy(DISPLAY_SSI_BASE))
    {
    }

    //Set the D/C pin low to indicate command
    GPIOPinWrite(DISPLAY_D_C_PORT, DISPLAY_D_C_PIN, 0);
   GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6,0);//cs=0
	
    // Send all the command bytes to the display
    while(ulCount--)
    {
        SSIDataPut(DISPLAY_SSI_BASE, *pcCmd);
        pcCmd++;
    }
	
    GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6, GPIO_PIN_6);//cs=1
}

//*******************************SSD1306WriteData****************************


static void
SSD1306WriteData(const unsigned char *pcData, unsigned long ulCount)
{
    // Wait for any previous SSI operation to finish.
    while(ROM_SSIBusy(DISPLAY_SSI_BASE))
    {
    }

    // Set the D/C pin high to indicate data 
    GPIOPinWrite(DISPLAY_D_C_PORT, DISPLAY_D_C_PIN, DISPLAY_D_C_PIN);
   GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6,0);//cs=0

    // Send all the data bytes to the display
    while(ulCount--)
    {
       SSIDataPut(DISPLAY_SSI_BASE, *pcData);
        pcData++;
    }
		
   GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6,GPIO_PIN_6);//cs=1
}

//*************************************main**********************************
main()
{
     SSD1306_SPI_Init();
    Clr_Screen(0x00); // function for clr_screen
    OLED_String_Display( 1, "Texas", 0x01, 0x25 ); // function to display string on row 0x01 and column 0x25
} 

  • Hello user4295597,

    A few observations on the code (other than the reply on the previous post)

    1. If PA6 is being selected for a CS function then GPIOPinTypeSSI(DISPLAY_SSI_PORT, DISPLAY_SSI_PINS); does not need to have the PA6 as one of the pins
    2. Make sure that after enabling a peripheral you wait for some time before accessing the peripheral or poll for the peripheral ready pin to ensure that the code does not end up in a bus fault.

    Regards
    Amit