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/CC2640: SPI not working

Part Number: CC2640

Tool/software: TI-RTOS

I am using the code bellow and the SPI not working there is no clock and no and response and the function SPI_Transfere stop the program

/*
 *  ======== echoFxn ========
 *  Task for this function is created statically. See the project's .cfg file.
 */
void echoFxn(UArg arg0, UArg arg1)
{
    //char input;
    char echoPrompt[8]="ABCDE\r\n";

    /* Create a UART with data processing off. */

    Task_sleep(100);
    PIN_setOutputValue(ledPinHandle, Board_SPI_FLASH_CS, 1);
    Task_sleep(100);
    PIN_setOutputValue(ledPinHandle, Board_SPI_FLASH_CS, 0);
    Task_sleep(100);
    PIN_setOutputValue(ledPinHandle, Board_SPI_FLASH_CS, 1);

    UART_write(uart, echoPrompt, sizeof(echoPrompt));
    clk2Handle = Clock_handle(&clk0Struct);

    Clock_start(clk2Handle);


    /* Loop forever echoing */
    while (1) {
//        SPI_transfer(ADChandle, &spiTransaction);
//      System_sprintf(echoPrompt,"%d \r\n",receiveBuffer[0]*0x100+receiveBuffer[1]*0x10+receiveBuffer[2]);
//        UART_write(uart, echoPrompt, sizeof(echoPrompt));
        //CPUdelay(8000*50);
    }
}
/*
 *  ======== buttonCallbackFxn ========
 *  Pin interrupt Callback function board buttons configured in the pinTable.
 *  If Board_LED3 and Board_LED4 are defined, then we'll add them to the PIN
 *  callback function.
 */
/*
 *  ======== clk0Fxn =======
 */
Void clk0Fxn(UArg arg0)
{
//    static UInt32 time;
    static char echoPrompt[20]="TIMER";

//    time = Clock_getTicks();
    SPI_transfer(ADChandle, &spiTransaction);
    System_sprintf(echoPrompt,"%d, %d \r",count++,receiveBuffer[0]*0x100+receiveBuffer[1]*0x10+receiveBuffer[2]);
    UART_write(uart, echoPrompt, sizeof(echoPrompt));
//    PIN_setOutputValue(ledPinHandle, Board_SPI_FLASH_CS,!PIN_getInputValue(Board_SPI_FLASH_CS));

}


/*
 *  ======== main ========
 */
int main(void)
{
    Task_Params taskParams;

    /* Call board init functions */
    Board_initGeneral();
    Board_initUART();
    Board_initPWM();
    Board_initSPI();

    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 115200;
    uart = UART_open(Board_UART0, &uartParams);

    if (uart == NULL) {
        System_abort("Error opening the UART");
    }


    PWM_Params_init(&params);
    params.dutyUnits = PWM_DUTY_FRACTION;
    params.dutyValue =PWM_DUTY_FRACTION_MAX/2;
    params.periodUnits = PWM_PERIOD_HZ;
    params.periodValue = pwmPeriod;
    pwm1 = PWM_open(Board_PWM3, &params);

    if (pwm1 == NULL) {
        System_abort("Board_PWM0 did not open");
    }
    PWM_start(pwm1);

    SPI_Params_init(&ADCparams);
    ADCparams.bitRate=10000;
    ADCparams.dataSize=8;
    //SPI_init();
    ADCparams.transferCallbackFxn=SPIFxn;
//    ADCparams.mode=SPI_MODE_CALLBACK;
    ADChandle = SPI_open(Board_SPI_MASTER, &ADCparams);
    if (!ADChandle) {
        Task_exit();
    }
    spiTransaction.rxBuf=(void *)receiveBuffer;
    spiTransaction.txBuf=(void *)transmitBuffer;
    spiTransaction.count=3;

    //intiating the clock function

    Clock_Params_init(&clkParams);
    clkParams.period = 9766/Clock_tickPeriod;
    clkParams.startFlag = TRUE;

    /* Construct a periodic Clock Instance */
    Clock_construct(&clk0Struct, (Clock_FuncPtr)clk0Fxn,
                   0, &clkParams);


    /* Open LED pins */
    ledPinHandle = PIN_open(&ledPinState, PinTable);
    if(!ledPinHandle) {
        System_abort("Error initializing board LED pins\n");
    }
    GSRPinHandle = PIN_open(&GSRPinState, GSRPinTable);
        if(!GSRPinHandle) {
            System_abort("Error initializing GSR pins\n");
        }
/*        if (PIN_registerIntCb(GSRPinHandle, &GSRCallbackFxn) != 0) {
            System_abort("Error registering button callback function");
        }
*/
        /* Construct BIOS objects */
        Task_Params_init(&taskParams);
        taskParams.stackSize = TASKSTACKSIZE;
        taskParams.stack = &task0Stack;
        Task_construct(&task0Struct, (Task_FuncPtr)echoFxn, &taskParams, NULL);

    /* Start BIOS */
    BIOS_start();

    return (0);
}