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.

RTOS/LAUNCHXL-CC1310: SPI Not Working

Part Number: LAUNCHXL-CC1310

Tool/software: TI-RTOS

I have code for SPI based off off the examples in SPI.h.

I'm not getting any errors, but when I check to see if SPI is working on the oscilloscope, there is nothing coming out of the clock, or mosi pins when transmit is called.

This is my code:

/* 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/PIN.h>
#include <ti/drivers/UART.h>

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

#include <stdint.h>

/* SPI Header files */
#include <ti/drivers/SPI.h>
#include <ti/drivers/spi/SPICC26XXDMA.h>
#include <ti/drivers/dma/UDMACC26XX.h>

#define TASKSTACKSIZE   768

Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];

/* Pin driver handle */
static PIN_Handle ledPinHandle;
static PIN_State ledPinState;

PIN_Config ledPinTable[] = {
    Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
};

SPI_Handle handle;
SPI_Params params;
SPI_Transaction	transaction;
uint8_t txBuf[]	= "Hello World";		// Transmit buffer
uint8_t rxBuf[11];						// Receive buffer

Void taskFxn(UArg arg0, UArg arg1)
{
    while (1) {

        /* Toggle LED */
        PIN_setOutputValue(ledPinHandle, Board_LED0, 0);

		Task_sleep((UInt)arg0);
		
        PIN_setOutputValue(ledPinHandle, Board_LED0, 1);

		if (! SPI_transfer(handle, &transaction)){	
        	PIN_setOutputValue(ledPinHandle, Board_LED1, 0);
		}
        
		Task_sleep((UInt)arg0);
    }
}

int main(){

    Task_Params taskParams;

    /* Call board init functions */
    Board_initGeneral();
	SPI_init();

    /* Construct heartBeat Task  thread */
    Task_Params_init(&taskParams);
    taskParams.arg0 = 1000000 / Clock_tickPeriod;
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)taskFxn, &taskParams, NULL);

	// Init SPI and specify non-default params
	SPI_Params_init (&params);
	params.bitRate 			= 1000000;
	params.frameFormat 		= SPI_POL1_PHA1;
	params.mode				= SPI_MASTER;

	// Configure the transaction
	transaction.count		= sizeof(txBuf);
	transaction.txBuf		= txBuf;
	transaction.rxBuf		= rxBuf;

    /* Open LED pins */
    ledPinHandle = PIN_open(&ledPinState, ledPinTable);
    if(!ledPinHandle) {
        System_abort("Error initializing board LED pins\n");
    }

    PIN_setOutputValue(ledPinHandle, Board_LED0, 1);
	PIN_setOutputValue(ledPinHandle, Board_LED1, 1);
    
	System_printf("Starting the 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();

	// Open the SPI and perform the transfer
	handle = SPI_open(Board_SPI0, &params);
    
	/* Start BIOS */
    BIOS_start();

    return (0);
}
  • Hi

    I used the uartecho example from simplelink_cc13x0_sdk_1_00_00_13 and modified the uartecho.c file as shown below:

    #include <stdint.h>
    #include <stddef.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/SPI.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    #define BUFSIZE 10
    
    SPI_Transaction spiTransaction;
    uint8_t transmitBuffer[BUFSIZE] = {0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59};
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        SPI_Handle  spi;
        SPI_Params  spiParams;
    
    
        /* Call driver init functions */
        GPIO_init();
        SPI_init();
        
        SPI_Params_init(&spiParams);
        
        /* Configure the SPI if not using default config */
        // spiParamstransferMode        = SPI_MODE_BLOCKING;
        // spiParamstransferTimeout     = SPI_WAIT_FOREVER;
        // spiParamstransferCallbackFxn = NULL;
        // spiParamsmode                = SPI_MASTER;
        // spiParamsbitRate             = 1000000;
        // spiParamsdataSize            = 8;
        // spiParamsframeFormat         = SPI_POL0_PHA0;
    
        spi = SPI_open(Board_SPI0, &spiParams);
    
        if (spi == NULL)
        {
            /* Error opening SPI */
            while(true);
        }
    
        spiTransaction.count = sizeof(transmitBuffer);
        spiTransaction.txBuf = transmitBuffer;
                
        while(true)
        {
            SPI_transfer(spi, &spiTransaction);
        }   
    }
    

    I monitored SCLK and MOSI using a logic analyzer and everything worked OK.

    BR

    Siri