CC1310: CC1310

Part Number: CC1310
Other Parts Discussed in Thread: SEGGER

Tool/software:

Hello,
I have been looking trough the internet for a few days know and I could not find anything that could help me solve my problem.
Currently Iam working with a cc1310 and Iam trying to port functionality from an older PIC18 Microcontroller to it. Wireless Communication is handled by 
Softwarestack which provides some API-Functions to interact with it, besides that this stack is blackbox. All of it runs in a "main Task" in tirtos.
I need to use UART and SPI to communicate with some external Sensors and an EEPROM. UART is working fine and i have the TI-Driver functions located in two separate files (.h and .c).
SPI however does not work. Everytime i try to use it my code Crashes. Often i cant even step through it using the debugger. The times i could it would end up in an endless for-loop inside of "exit.c".

I could only make it work, if all my functions were located in the same file as my main task. Which is weird because UART works fine by just including the .h file of my module. 
My guess is it has something to do with memory allocation. I already tried declaring all the variables I need globally and I also tried using the heap instead (malloc() and free()). I also tried to resize the task stack but that did not help either. Iam using Board_SPI1 instead of 0 because that one never worked regardless of the Implementation.
Maybe someone here has an idea what  I do wrong.

LAUNCHXL.h:

#define CC1310_LAUNCHXL_SPI1_MISO      IOID_2
#define CC1310_LAUNCHXL_SPI1_MOSI      IOID_1
#define CC1310_LAUNCHXL_SPI1_CLK        IOID_6
#define CC1310_LAUNCHXL_SPI1_CSN        IOID_7

LAUNCHXL.c: (#if is not executed, i dont use a launchpad)

const PIN_Config BoardGpioInitTable[] =
{

#if (SF_CC13XX_TARGET == SF_TARGET_CC13X0_LP)
CC1310_LAUNCHXL_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
CC1310_LAUNCHXL_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
CC1310_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
CC1310_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
CC1310_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */
CC1310_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */
CC1310_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */
CC1310_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */
#endif /* SF_CC13XX_TARGET */
CC1310_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */
CC1310_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW| PIN_PUSHPULL, /* UART TX via debugger back channel */
CC1310_LAUNCHXL_SPI1_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */
CC1310_LAUNCHXL_SPI1_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */
CC1310_LAUNCHXL_SPI1_CLK | PIN_INPUT_EN | PIN_PULLDOWN,
PIN_TERMINATE };

My SPI.c:

bool loc_spi_init()
{
bool retVal = false;

// Initilize SPI with default parameters
SPI_Params_init(&spiParams);
spiParams.dataSize = 8;
spiParams.bitRate = 4000000;
spiParams.mode = SPI_MASTER;
spiParams.transferMode = SPI_MODE_BLOCKING;
spiParams.transferTimeout = SPI_WAIT_FOREVER;
spiParams.transferCallbackFxn = NULL;

spiHandle = SPI_open(Board_SPI1, &spiParams);
if (spiHandle == 0)
{
return retVal;
}
else
{
retVal = true;
}

return retVal;

}

bool loc_spi_WriteRead(uint8_t spiSendBuffer[], uint8_t spiRecvBuffer[],
uint8_t size)
{
spiHandle = SPI_open(Board_SPI1, &spiParams);
SPI_Transaction stTransaction;
bool spiTransferOk = false;

// Populating the struct
stTransaction.count = size;
stTransaction.txBuf = (void*) spiSendBuffer;
stTransaction.rxBuf = (void*) spiRecvBuffer;

spiTransferOk = SPI_transfer(spiHandle, &stTransaction);
SPI_close(spiHandle);
return spiTransferOk;
}

Iam Using a segger j-link to programm and debug and CCS version 12.

Simplelink Version is 4.20.02.07.

I also used the runtime object view to see if my task stack was overflowing (it was Not).
Thanks in advance.

  • void loc_read_EEPROM(TUINT16 AdrEEPROM, uint8_t *RecvBuffer, size_t RecvSize)
    {
        uint8_t spiSend_RegAdr[] = { READ, (TUINT16) AdrEEPROM >> 8,
                                    (TUINT16) AdrEEPROM & (TUINT16) 0xFF };
    
        size_t sendSizeSPI = sizeof(spiSend_RegAdr) + RecvSize;
    
        if (!loc_spi_WriteRead(spiSend_RegAdr, RecvBuffer, sendSizeSPI))
        {
           while (1)
                ; // Failed
        }
    //}

    Sorry i forgot this function.

  • Hi Gbu,

    I am looking at your loc_spi_init, and I see that you are calling SPI_open.

    However, in loc_spi_WriteRead, you are also calling SPI_open. I then believe the crash may come from there.

    You should get rid of the SPI_open call in loc_spi_init.

    Regards,

    Arthur

  • Hey Arthur,
    that indeed fixed it, Iguess i just needed a second pair of eyes. Thank you very much.