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.

Setting SPI communication for my custom hardware

Other Parts Discussed in Thread: CC2640, CC2650

Hi everybody,

I have my custom CC2640 board and I am trying to establish an SPI communication with another chip on my board. However, my code does not execute SPI_open() statement.

Here is my main code ;

int main(void)
{
/* Call board init functions */
PIN_init(BoardGpioInitTable);

/* Open LED pins */
pinHandle = PIN_open(&pinState, pinTable);
if(!pinHandle) {
System_abort("Error initializing board pins\n");
}

SPI_init() ;

/* Set up the led task */
Task_Params workTaskParams;
Task_Params_init(&workTaskParams);
workTaskParams.stackSize = 256;
workTaskParams.priority = 2;
workTaskParams.stack = &workTaskStack;

Task_construct(&workTask, workTaskFunc, &workTaskParams, NULL);

/* Start kernel. */
BIOS_start();

return (0);
}

And here is the task and the doSPi function inside the task ;

void doSpi(void)
{
SPI_Params_init(&params);
params.bitRate = 1000000;
spihandle = SPI_open(CC2650_LAUNCHXL_SPI0, &params);
if (!spihandle) {
System_printf("SPI did not open ");
}

spiTransaction.count = sizeof(txBuf);
spiTransaction.txBuf = txBuf;
spiTransaction.rxBuf = rxBuf;

ret = SPI_transfer(spihandle, &spiTransaction);
if (!ret) {
System_printf("Unsuccessful SPI transfer");
}
SPI_close(spihandle) ;

}

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

/* Do work */
doWork();
doSpi();
/* Wait a while, because doWork should be a periodic thing, not continuous.*/
Task_sleep(1000) ;
}
}

This the what  I am having after running the code in debug screen;

 


Thank you for your help, any suggestion is deeply appreciated.

  • could you post your board file? have you checkout your HW according to our HW toubleshooting guide?
    processors.wiki.ti.com/.../CC26xx_HW_Troubleshooting
  • Hi Christin,

    Thank you for your fast response, when I try to blink the LED on my board, I succesfully blink it periodically. I think there is no HW problem. I have checked the HW troubleshooting guide and everything seems correct(all the voltage values etc.). I started with editing TI-RTOS_BasicTask_CC2650LAUNCHXL project which is Lab1 in simplelink academy. 

    Here is my board files ;

    Board.h (Single screenshut);

     

    CC2650_LAUNCHXL.c file (3 screenshuts) ; I have not put some segments of the code as I have commented out them because they are for other drivers like uart and etc.

    1-)

     

    2-)

     

     

     

    3-)


     

     

    CC2650_LAUNCHXL.h file (2 screenshuts); I have not put some segments of the code as I have commented out them because they are for other drivers like uart and etc.

    1-) 

    2-)

     


     

    Thank you a lot for your help.

  • as I can see you don't have any valid DIOs assigned to Board_SPI0_CSN. Can you verify that's the case?
  • Hi,

    As I mentioned I have started with lab1 example under simplelink academy and I am  editing it to work on SPI. I have not assigned any pin because it was unassigned originally.

    I have assigned a DIO, it did not open SPI again(SPI_open()), It crashed at this line in lab1-main.c file ;

    ret = SPI_transfer(spihandle, &spiTransaction);  

    Here is how I assigned a DIO in CC265*_LAUNCHCL.h file ;

    /* SPI Board */
    #define Board_SPI0_MISO IOID_5 /* RF1.20 */
    #define Board_SPI0_MOSI IOID_6 /* RF1.18 */
    #define Board_SPI0_CLK IOID_7 /* RF1.16 */
    //#define Board_SPI0_CSN PIN_UNASSIGNED
    #define Board_SPI0_CSN IOID_8

    /* SPI */
    #define Board_SPI_FLASH_CS IOID_2
    #define Board_FLASH_CS_ON 0
    #define Board_FLASH_CS_OFF 1

    Thank you for your help.

  • What I can recommend is take a look at our software developer's guide page 102 section 9.8 Deciphering CPU Exceptions
  • Well, this does not help I guess, I will work on it and I will send the updates.

    Thank a lot for your help Christin