Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: CC1310
Tool/software: TI-RTOS
Hello!
I am quite new to TI-RTOS ecosystem, and I am trying to make configure a CC1310 board to act as SPI master. I have written following code. While debugging, I realized that the code freezes as soon as I call the SPI_open() function. I would really appreciate if someone could indicate what's I am doing wrong. Thanks in advance!
/*
* main.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>
#include <ti/sysbios/knl/Clock.h>
/* TI-RTOS Header files */
#include <ti/drivers/PIN.h>
#include <ti/drivers/SPI.h>
#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTCC26XX.h>
#include <ti/drivers/Watchdog.h>
/* Board Header files */
#include "Board.h"
/* Driver files */
#include <driverlib/aon_batmon.h>
#include <driverlib/aux_timer.h>
#include <driverlib/aux_tdc.h>
#include <driverlib/aux_adc.h>
#include <driverlib/gpio.h>
#include <ti/drivers/spi/SPICC26XXDMA.h>
#define SPI_TRANSFER_SLAVE_STRING "hello, SPI Slave..."
#define TASKSTACKSIZE 512
Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];
void TaskFxn(UArg arg0, UArg arg1){
//char input;
//UART_Handle uart;
//UART_Params uartParams;
SPI_Handle spi;
SPI_Params spiParams;
SPI_Transaction spiTrans;
char buffer[128] = "\fSPI Sample:\r\n";
SPI_Params_init(&spiParams);
spiParams.bitRate = 1000000;
spiParams.frameFormat = SPI_POL1_PHA1;
//memset(&spiTrans, 0, sizeof(SPI_Transaction));
spiParams.mode = SPI_MASTER;
spiParams.transferMode = SPI_MODE_BLOCKING;
spiParams.transferCallbackFxn = NULL;
spiParams.transferTimeout = 1000;
spi = SPI_open(Board_SPI0, &spiParams);
if (!spi) {
System_printf("SPI did not open");
System_flush();
}
strcpy(buffer, "SPI open with Master mode");
System_printf(buffer);
System_flush();
while (1){
spiTrans.count = strlen (SPI_TRANSFER_SLAVE_STRING);
spiTrans.txBuf = SPI_TRANSFER_SLAVE_STRING;
spiTrans.rxBuf = NULL;
int ret = SPI_transfer(spi, &spiTrans);
if (!ret) {
System_printf("Unsuccessful SPI transfer");
System_flush();
}
}
}
int main(void) {
Task_Params taskParams;
Board_initSPI();
/* Construct BIOS objects */
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)TaskFxn, &taskParams, NULL);
/* Start BIOS */
BIOS_start();
return 0;
}
EDIT: I did some debugging for the code using step over, and it looks like it freezes while executing following line in the SPICC26XXDMA.c file-
object->csnPin = hwAttrs->csnPin;
; I hope this information helps to find the problem.