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: EK-TM4C1294XL & SPILoopBack

Part Number: EK-TM4C1294XL
Other Parts Discussed in Thread: ADS127L01

Tool/software: Code Composer Studio

 
Hello,
I'm a little new around here. I looked at old posts, but I couldn't find an answer for my issue.
I'm using EK-TM4C1294XL via Code Composer Studio Version: 8.3.1.00004 and spiloopback. Also I have ADS127L01EVM.
With these parts, I'm making ADC and I want to read with EK-TM4C1294XL (SPI) than I want to send It to the CAN line.
spiloopback.h is working on the EK-TM4C1294XL but I can not read any data from ADS127L01EVM. 
I build like the jumper wire connections are needed for the external SPI loopback example.  | PD3->PQ0, PD2->PQ1, PD0->PQ2, PD1->PQ3  and the spiloopback works.

Now,
TM4C PQ1 to GND
ADS SCLK ->TM4C PQ0 - SLAVE
ADS DIN -> TM4C PQ2 - SLAVE
ADS DOUT -> TM4C PQ3 - SLAVE

ADS input frequency is 16MHz and output (DOUT) frequency is about 130kHz. It works and i add my oscilloscope-screenshots





so I made some additions to the program.

slaveSpiParams.transferMode = SPI_MODE_BLOCKING; //added
slaveSpiParams.bitRate = 130000; //added

This is my Console on Code Composer
SPI initialized
SPI initialized
Master:
Done

Q: Why can't I get data?
Q: Is there a simpler example you can recommend?
Q: This program is running once. if i add a "while loop" , can it work continuously?

Thank You

 /*  ======== spiloopback.c ========
 */
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>

/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/SPI.h>

/* Example/Board Header files */
#include "Board.h"

#define SPI_MSG_LENGTH    30

#define TASKSTACKSIZE     768


Task_Struct task0Struct, task1Struct;
Char task0Stack[TASKSTACKSIZE], task1Stack[TASKSTACKSIZE];

unsigned char masterRxBuffer[SPI_MSG_LENGTH];
unsigned char masterTxBuffer[SPI_MSG_LENGTH] = "Hello, this is master SPI1234";

unsigned char slaveRxBuffer[SPI_MSG_LENGTH];
unsigned char slaveTxBuffer[SPI_MSG_LENGTH] =  "Hello, this is slave SPI1234";
/* *  ======== slaveTaskFxn ========
 *  Task function for slave task.
 *
 *  This task runs on a higher priority, since slave
 *  has to be ready for master. Slave SPI sends a
 *  message to master and also receives message from
 *  master. Task for this function is created
 *  statically. See the project's .cfg file.
 */
Void slaveTaskFxn (UArg arg0, UArg arg1)
{
    SPI_Handle slaveSpi;
    SPI_Params slaveSpiParams;
    SPI_Transaction slaveTransaction;

    bool transferOK;

    /* Initialize SPI handle with slave mode */
    SPI_Params_init(&slaveSpiParams);
    slaveSpiParams.transferMode = SPI_MODE_BLOCKING;  //eklendi
    slaveSpiParams.mode = SPI_SLAVE;
    slaveSpiParams.bitRate = 130000;
    slaveSpi = SPI_open(Board_SPI1, &slaveSpiParams);
    if (slaveSpi == NULL) {
        System_abort("Error initializing SPI\n");
    }
    else {
        System_printf("SPI initialized\n");
    }

    /* Initialize slave SPI transaction structure */
    slaveTransaction.count = SPI_MSG_LENGTH;
    slaveTransaction.txBuf = (Ptr)slaveTxBuffer;
    slaveTransaction.rxBuf = (Ptr)slaveRxBuffer;

    /* Initiate SPI transfer */
    transferOK = SPI_transfer(slaveSpi, &slaveTransaction);

    if(transferOK) {
        /* Print contents of slave receive buffer */
        System_printf("Slave: %s\n", slaveRxBuffer);
    }
    else {
        System_printf("Unsuccessful slave SPI transfer");
    }

    /* Deinitialize SPI */
    SPI_close(slaveSpi);
}
/*
 *  ======== masterTaskFxn ========
 *  Task function for master task.
 *
 *  This task runs at a lower priority after the slave
 *  task to ensure it is ready for a transaction.
 *  Master SPI sends a message to slave and also
 *  receives message from slave. Task for this function
 *  is created statically. See the project's .cfg
 *  file.
 */
Void masterTaskFxn (UArg arg0, UArg arg1)
{
    SPI_Handle masterSpi;
    SPI_Transaction masterTransaction;
    SPI_Params masterSpiParams;

    bool transferOK;

    masterSpiParams.bitRate = 130000;

    /* Initialize SPI handle as default master */
    masterSpi = SPI_open(Board_SPI0, NULL);
    if (masterSpi == NULL) {
        System_abort("Error initializing SPI\n");
    }
    else {
        System_printf("SPI initialized\n");
    }

    /* Initialize master SPI transaction structure */
    masterTransaction.count = SPI_MSG_LENGTH;
    masterTransaction.txBuf = (Ptr)masterTxBuffer;
    masterTransaction.rxBuf = (Ptr)masterRxBuffer;

    /* Initiate SPI transfer */
    transferOK = SPI_transfer(masterSpi, &masterTransaction);

    if(transferOK) {
        /* Print contents of master receive buffer */
        System_printf("Master: %s\n", masterRxBuffer);
    }
    else {
        System_printf("Unsuccessful master SPI transfer");
    }

    /* Deinitialize SPI */
    SPI_close(masterSpi);

    System_printf("Done\n");

    System_flush();
}
/*
 *  ======== main ========
 */
int main(void)
{
    /* Construct BIOS objects */
    Task_Params taskParams;

    /* Call board init functions. */
    Board_initGeneral();
    Board_initGPIO();
    Board_initSPI();

    /* Construct master/slave Task threads */
    Task_Params_init(&taskParams);
    taskParams.priority = 1;
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)masterTaskFxn, &taskParams, NULL);

    taskParams.stack = &task1Stack;
    taskParams.priority = 2;
    Task_construct(&task1Struct, (Task_FuncPtr)slaveTaskFxn, &taskParams, NULL);

    /* Turn on user LED */
    GPIO_write(Board_LED0, Board_LED_ON);

    System_printf("Starting the SPI loop-back example\nSystem provider is set to"
                  " SysMin. Halt the target to view any SysMin contents in ROV.\n");
    /* SysMin will only print to the console when you call flush or exit */
    System_flush();

    System_printf("This example requires external wires to be connected to the "
                  "header pins. Please see the Getting Started Guide for "
                  "details.\n");
    /* SysMin will only print to the console when you call flush or exit */
    System_flush();

    /* Start BIOS */
    BIOS_start();

    return (0);
}


  • Hello Riza,

    The loopback example is a basic example to show how to send and receive data to SPI channels on the TM4C LaunchPad. To adapt this to your EVM, you'd take out the slave code and ensure the Master code is sending the correct data packets to the ADS127L01.

    If you need TI-RTOS, that seems to be the simplest example in that it shows how to consider the SPI master properly. From there you'd need to ensure you are sending the correct packets and processing the received data.

    If you don't need TI-RTOS you can look at the spi_master.c example in TivaWare under the peripherals example folder.

  • Thank you for the quick reply,

    I created a CCS project but I can not import "ssi" to project as seen at the picture_1. But the otther projects can be added automatically.?(Picture_2)

    -

  • Hello Riza,

    The SSI peripheral examples are not full projects. You need to import Project0 for your LaunchPad and then copy/paste the entire contents of the .c file for the SSI peripheral example you want to import and replace the contents of the project0.c file with those contents.

    By the way, please try and save clicking a post as Resolved until the issue is fully closed.

  • Hello Ralph Jacobi,

    Thank you for your recomended example, I'm working on it.But again, I have a problem.I've been dealing with this problem for about 3 days.I changed pin outs for my MCU; 

    I changed the following fixes with the first error I received.

    GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    GPIOPinConfigure(GPIO_PA4_SSIORX);
    GPIOPinConfigure(GPIO_PA5_SSI0TX);

    to;

    GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    GPIOPinConfigure(GPIO_PA4_SSI0XDAT0); //here
    GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);   //here

    I think the other settings are the same. I wonder if the errors bacause of codes?

  • Hello Riza,

    The CCS errors are for the functions in uartstdio.c. It looks like you didn't add those files properly.

    See this post for how to resolve that issue: http://e2e.ti.com/support/microcontrollers/other/f/908/p/753675/2787705#2787705

  • Thank you,

    Best,

    Rıza