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: SPI manually controlled Fss line going high upon byte transfer

Part Number: TM4C123GH6PM

I am using the TivaWare libraries. I intend to send two bytes of data (0xFF, 0xFF) over SSI2 in the SPI protocol, with the Fss signal to be low for the duration of the two-byte frame. Upon realising that the TM4C123GH6PM does not support SSIAdvFrameHoldEnable(uint32_t ui32Base), I decided to manually take control of the SSI2Fss (PB5) signal as a GPIO output. 

However, the Fss signal is not behaving as I intended. It goes high at the beginning of the first byte, and stays high. I have stepped through my code, and have monitored the GPIO PORTB DATA register throughout. That register behaves as it should but my resultant waveform does not correspond to the register value. 

Please shed some light on this issue. I have attached my code and the captured waveform for your reference. Thank you for your time. 

void SSI2Init(void) {
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    GPIOPinConfigure(GPIO_PB4_SSI2CLK);
    GPIOPinConfigure(GPIO_PB6_SSI2RX);
    GPIOPinConfigure(GPIO_PB7_SSI2TX);

    GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_6 |
                   GPIO_PIN_7);

    SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,
                       SSI_MODE_MASTER, 350000, 8);

    SSIEnable(SSI2_BASE);

    uint32_t RxBuffer;
    // Flush receive FIFO buffer of any residual data and discard it
    while (SSIDataGetNonBlocking(SSI2_BASE, &RxBuffer)) {
    }

    GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_5);
    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_PIN_5);

    return;
}

void SDCardInit(void) {
    uint32_t TxBuffer = 0xFF;

    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0);

    SSIDataPut(SSI2_BASE, TxBuffer);
    SSIDataPut(SSI2_BASE, TxBuffer);

    GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_PIN_5);
}

/**
 * main.c
 */
int main(void)
{
    uint32_t RxBuffer;
    uint32_t TxBuffer;

    InitConsole();

    UARTprintf("SysCtlClockGet(): %u\n", SysCtlClockGet());

    SSI2Init();

    SDCardInit();

    while (1) {

    }

	return 0;
}

  • What is happening is that SSIDataPut() simply puts the data in a FIFO and lets the hardware start the transfer. You need to wait until the transfer is complete before driving SSIFSS back high. The simple way is to add the following line after the second call to SSIDataPut() in the function SDCardInit().

       while(SSIBusy(SSI2_BASE));