Part Number: SW-EK-TM4C129EXL
Other Parts Discussed in Thread: EK-TM4C129EXL
Tool/software: TI-RTOS
I am working with EK-TM4C129EXL Eval kit. I am trying to send the data from one array to another array through SPI protocol. The data from transmitBuffer(array1) is not sent to receiveBuffer(array2). I had also created a boolean variable to check if the SPI transactions complete. The transaction is complete but the data is not transferred to the second array. I hereby attach the code file.
/* 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/GPIO.h> #include <ti/drivers/SPI.h> #include <ti/sysbios/BIOS.h> #include <ti/sysbios/knl/Semaphore.h> #include <ti/sysbios/family/arm/m3/Hwi.h>
/* Board Header file */ #include "Board.h" #include <inc/hw_memmap.h> #include <inc/hw_types.h> #include <inc/hw_ssi.h> #include <driverlib/ssi.h> #include <driverlib/udma.h> #include <driverlib/sysctl.h>
#define TASKSTACKSIZE 1024 UChar transmitBuffer[8] = {0,1,2,3,4,5,6,7}; UChar receiveBuffer[8]; Task_Struct task0Struct; Char task0Stack[TASKSTACKSIZE]; Bool transferOK; Void spiDataSend() { SPI_Handle spi; SPI_Params spiParams; SPI_Params_init(&spiParams); spiParams.transferMode = SPI_MODE_BLOCKING; spiParams.transferCallbackFxn = NULL; spi = SPI_open(Board_SPI0, &spiParams); if (spi == NULL) { /* Error opening SPI */ } SPI_Transaction spiTransaction; spiParams.dataSize = 8; /* dataSize can range from 4 to 8 bits */ spiTransaction.count = 8; spiTransaction.txBuf = transmitBuffer; spiTransaction.rxBuf = receiveBuffer; transferOK = SPI_transfer(spi, &spiTransaction); if (transferOK) { /* Error in SPI transfer or transfer is already in progress */ System_printf("SPI Transfer successful \n"); // This message gets printed on console but the receiveBuffer is empty with values 0. System_flush(); } SPI_close(spi); } int main(void) { Task_Params taskParams;
/* Call board init functions */ Board_initGeneral(); Board_initGPIO(); Board_initSPI(); /* Construct spiDataSend Task thread */ Task_Params_init(&taskParams); taskParams.stackSize = TASKSTACKSIZE; taskParams.stack = &task0Stack; Task_construct(&task0Struct, (Task_FuncPtr)spiDataSend, &taskParams, NULL); BIOS_start(); return (0); }