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/EK-TM4C1294XL: SSI Data Get

Part Number: EK-TM4C1294XL
Other Parts Discussed in Thread: ADC161S626EVM, STRIKE

Tool/software: Code Composer Studio

I'm using SSI to communicate the EK-TM4C94XL with the ADC161S626EVM booster pack.

Debugging my code, I saw that it was stopping in the part that of the SSIDataGet(...). Stepping into this function the part it was stopping is below:

// Wait until there is data to be read.
//
while(!(HWREG(ui32Base + SSI_O_SR) & SSI_SR_RNE))
{
}

Here's the code:

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

uint32_t ui32SysClkFreq;

void
UARTprompt(uint32_t str[])
{
uint8_t i = 0;

while(str[i] != '\0'){

UARTCharPut(UART0_BASE, str[i]);

i++;

}

}

void
InitPORTE(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE))
{
}

GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_4);

GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, 1);
}

void
InitConsole(void)
{

//
// Enable UART0 so that we can configure the clock.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

//
// Enable GPIO port A which is used for UART0 pins.
// TODO: change this to whichever GPIO port you are using.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

//
// Configure the pin muxing for UART0 functions on port A0 and A1.
// This step is not necessary if your part does not support pin muxing.
// TODO: change this to select the port/pin you are using.
//
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);

//
// Select the alternate (UART) function for these pins.
// TODO: change this to select the port/pin you are using.
//
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.
//
UARTConfigSetExpClk(UART0_BASE, ui32SysClkFreq, 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
}

int
main(void)
{
uint32_t pui32DataRx[3];
uint32_t ADCRx[16];
uint8_t i;

//
// Set the clocking to run directly from the external crystal/oscillator.
// TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
// crystal on your board.
//

ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);

//
// Set up the serial console to use for displaying messages. This is
// just for this example program and is not needed for SSI operation.
//
InitConsole();

InitPORTE();


SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);


SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

GPIOPinConfigure(GPIO_PD3_SSI2CLK);
GPIOPinConfigure(GPIO_PD2_SSI2FSS);
GPIOPinConfigure(GPIO_PD0_SSI2XDAT1);
GPIOPinConfigure(GPIO_PD1_SSI2XDAT0);


GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 |
GPIO_PIN_3);

SSIConfigSetExpClk(SSI2_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_1,
SSI_MODE_MASTER, 1000000, 8);

HWREG(SSI2_BASE + 0x004) = 0x00000001;


SSIEnable(SSI2_BASE);

//
// Read any residual data from the SSI port. This makes sure the receive
// FIFOs are empty, so we don't read any unwanted junk. This is done here
// because the SPI SSI mode is full-duplex, which allows you to send and
// receive at the same time. The SSIDataGetNonBlocking function returns
// "true" when data was returned, and "false" when no data was returned.
// The "non-blocking" function checks if there is any data in the receive
// FIFO and does not "hang" if there isn't.
//
while(SSIDataGetNonBlocking(SSI2_BASE, &pui32DataRx[0]))
{
}

GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, 0);

UARTCharPut(UART0_BASE, 'T');
UARTCharPut(UART0_BASE, '\n');

for(i=0 ; i<16 ; i++){

SSIDataGet(SSI2_BASE, &ADCRx[i]);
}


UARTprompt(ADCRx);

return(0);
}

  • Geovani Alves said:
    GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, 1);

    While not the cause of your issue - your 3rd parameter will NOT cause Port "E_4" to output high.    You must change the final parameter to the, "Bit Positional Value" reflected by the 2nd parameter.   (that would be "16" in your case.)   You may also use a repetition of the 2nd parameter, "GPIO_PIN_4".    Your use of "1" WILL enable PORTx, Pin_0 (only) to produce a high.

    Personally - I find there to be "so much" extraneous code as to obscure the code you wish reviewed.    A simple "highlighting" would better guide your helpers - reducing their, "wear/tear."   Classically - the minimal code which illustrates your issue - proves optimal...

  • On top of cb1's comments, I see below line which enables bit0 for loopback and disable SSI in bit2.

    HWREG(SSI2_BASE + 0x004) = 0x00000001;


    I also don't see you calling SSIDataPut(). SSI is full-duplex. Even if you are only reading data from the slave you still need to transmit dummy data and that is how the SSI starts the clock. Without the clock, the slave cannot respond.
  • Greetings Charles - I wondered about that "mix" of DRM among the predominantly API code - its beyond my interest/patience to "make that (needless) extra, DRM look-up effort!"

    And surely the "miss" of "SSIDataPut()" calms the SPI clock.    (and yet another "Like" bubbles up - your behalf)

    Should not posters make (some) effort to "ease the efforts of their helpers?" (if not done here - and now - such will NOT be appreciated if/when they enter industry - and request such (effort-lite) "aid.")

  • Hi cb1,
    Thanks for spending your weekend to help out the forum. Perhaps the poster at one point in time was trying to enable the loopback mode for a simple test for which there is not an available SSI API.

    Hi Geovani,
    You can use SSIEnable() to enable the SSI module in case you missed it in the API.
  • By "bit positional value" you mean like 0x08 for bit 4?

    And I'm sorry about the post. I'm new in the forum. I'll try to do better next time.
  • Thanks Charles.. I did not know about having to transmit dummy data in order to start the SSI clock.

    But when I ran the code and opened the PuTTY console it gives me the following screen:

    It gives me exactly what I transmitted in the through the SSI, but I'm trying to get the output values of the ADC.

    Here's part of the code I inserted in order to get SSI clock (the highlighted one):

    while(SSIDataGetNonBlocking(SSI2_BASE, &pui32DataRx[0]))

    {
    }

    pui32DataTx[0] = 's';
    pui32DataTx[1] = 'p';
    pui32DataTx[2] = 'i';

    for(ui32Index = 0; ui32Index < 3; ui32Index++)

    {

    // Display the data that SSI is transferring.

    UARTprompt(pui32DataTx[ui32Index]);


    // Send the data using the "blocking" put function. This function
    // will wait until there is room in the send FIFO before returning.
    // This allows you to assure that all the data you send makes it into
    // the send FIFO.

    SSIDataPut(SSI2_BASE, pui32DataTx[ui32Index]);


    }

    GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, 0x00);

    UARTCharPut(UART0_BASE, 'T');
    UARTCharPut(UART0_BASE, '\n');

    for(i=0 ; i<16 ; i++){

    SSIDataGet(SSI2_BASE, &ADCRx[i]);

    UARTprompt(ADCRx);

    }

    Thanks. And Sorry for the first post.

  • Hi Geovani,
    Small correction. bit4 would have been 0x10, not 0x08. As suggested by cb1, you can instead use:
    GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, GPIO_PIN_4) rather than GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, 0x10).
  • No one requests your "sorrow" - yet it will prove ALWAYS helpful for you to, "Think of - and try to EASE the efforts of others - especially when you are requesting their aid!" Pity that forum Mgmt. does not properly promote nor guide posters in this matter. (I've written several manifestos - buried far back - this & earlier forums...

    Providing code covering "every nook & cranny" is easy for you (simple cut/paste of everything) - while making our review harder/longer.    The shortest code block which presents/proves you issue - presented instead - is ideal!   (and - the thought required to "shorten the code listing" MOST ALWAYS will prove helpful to you - will raise your confidence & understanding!)

    And too the DRM code format forces "Finding, Opening and intense review of the MCU manual & Register Review/Re-Read - by ALL of your helpers!"    (even vendor agents - cannot instantly recall the mass of Registers and key Register bit values.)     And that "extra, unwanted effort" - is so often, "done for you" (and us) via the API.    And has been PROVEN - time & again. DRM - in stark contrast - proves ALWAYS an (unwanted) adventure!

    To your "bit 4" question: GPIO_Pin_7 has the value "128", Pin_6 "64", Pin_5 "32" and Pin_4 "16" - which is the value I listed. The total of all bits & resulting values - when ALL bits are "high/ON" equals 255. (0xFF) Note too that you can control, "ALL Port Bits" via a single GPIO_Write!

  • Hello Charles,

    Charles Tsai said:
    you can instead use:
    GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, GPIO_PIN_4) rather than GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, 0x10)

    Kindly note - my inspiration for suggesting (instead) the "bit-positional value method" was to save this poster (and all others) from dreaded, "Carpal-Tunnel Syndrome" - known to strike those who must "Set" MULTIPLE Port Bits - across Many Ports.    BTW: does vendor staff (still) receive "referral fees" from "hand MD. specialists?"   (ask - as my right hand has almost healed - left one still trembles - I can "repeat key-strokes" - really - without trying...without trying...without trying...)  

    Long live "Bit-Positional Value" and "Tunnel/Pain-Free/Rock Stable" hands...   (unfortunately - neither of my hands "meet" any part of that specification...)

  • cb1_mobile said:
     BTW: does vendor staff (still) receive "referral fees" from "hand MD. specialists?"

    $0. :-)

  • Good to know! I'll "nego" a "bill reduction" - by (just) that amount....