Other Parts Discussed in Thread: TMDSEVM6657, SYSBIOS, OMAPL138
Hi, I am working with TMDSEVM6657 evaluation board. I am trying to establish simple SPI transmission to CS0 port.
If I set the spiParams.transferTimeout = SPI_WAIT_FOREVER; then it gets stuck in SPI_transfer line (waiting for the semaphore), and if I set the transfer timeout to be a certain number, then it finishes transfer with the message SPI_TRANSFER_TIMEOUT.
I am using the SPI_BasicExample_C6657_c66xExampleProject, where I only changed the main_spi_flash_read_example.c file, nothing else.
This is what I use:
This is how my code looks:
#ifndef BARE_METAL
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>
#include <stdio.h>
#include <xdc/runtime/Error.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#endif
/* SPI Header files */
#include <ti/drv/spi/SPI.h>
#if defined(SOC_K2H) || defined(SOC_K2K) || defined(SOC_K2E) || defined(SOC_K2L) || defined(SOC_K2G) || defined(SOC_C6678) || defined(SOC_C6657) || defined(SOC_OMAPL137) || defined(SOC_OMAPL138)
#include <ti/drv/spi/src/v0/SPI_v0.h>
#endif
#include <ti/drv/spi/soc/SPI_soc.h>
#include <ti/drv/spi/test/src/SPI_log.h>
#include <ti/drv/spi/test/src/SPI_test.h>
/* Board Header files */
#include <ti/board/board.h>
#include <ti/board/src/flash/include/board_flash.h>
//Char myTaskStack[1024];
//Task_Struct myTaskStruct;
bool loop = true;
SPI_Handle spiHandle;
SPI_Params spiParams;
SPI_Transaction spiTransaction;
/*
* ======== Board_initSPI ========
*/
void Board_initSPI(void)
{
Board_initCfg boardCfg;
SPI_v0_HWAttrs spi_cfg;
Board_SoCInfo socInfo;
bool boardStatus;
/* Get the default SPI init configurations */
SPI_socGetInitCfg(0, &spi_cfg);
/* Update the SPI functional clock based on CPU clock*/
Board_getSoCInfo(&socInfo);
if(socInfo.sysClock != BOARD_SYS_CLK_DEFAULT)
{
spi_cfg.inputClkFreq = socInfo.sysClock/SPI_MODULE_CLOCK_DIVIDER;
}
/* Set the default SPI init configurations */
SPI_socSetInitCfg(0, &spi_cfg);
boardCfg = BOARD_INIT_PINMUX_CONFIG |
BOARD_INIT_MODULE_CLOCK |
BOARD_INIT_UART_STDIO;
boardStatus = Board_init(boardCfg);
if (boardStatus != BOARD_SOK)
{
printf("Board not OK!");
}
else{
printf("Board OK!");
}
}
/*
* ======== test function ========
*/
#ifdef BARE_METAL
void main()
#else
void spi_test(UArg arg0, UArg arg1)
#endif
{
bool transferOK;
SPI_v0_HWAttrs const *hwAttrs = NULL;
SPI_v0_Object *object = NULL;
#ifdef BARE_METAL
/* Call board init functions */
Board_initSPI();
#endif
System_printf("Start SPI task\n");
SPI_Params_init(&spiParams);
spiParams.transferMode = SPI_MODE_BLOCKING;
//spiParams.transferTimeout = SPI_WAIT_FOREVER;
spiParams.transferTimeout = 1000;
spiParams.transferCallbackFxn = NULL;
spiParams.mode = SPI_MASTER;
//spiParams.bitRate = 1000000;
//spiParams.dataSize = 8;
spiHandle = SPI_open(0, &spiParams);
if (!spiHandle)
{
printf("\n SPI_open failed. \n");
}
hwAttrs = (const SPI_v0_HWAttrs *)spiHandle->hwAttrs;
object = (SPI_v0_Object*)spiHandle->object;
while (loop) {
uint8_t transmitBuffer[1];
//uint8_t receiveBuffer[1];
transmitBuffer[0] = 0x01;
spiTransaction.count = 2;
spiTransaction.txBuf = transmitBuffer;
spiTransaction.rxBuf = NULL;
transferOK = SPI_transfer(spiHandle, &spiTransaction);
//printf("loop");
if (!transferOK){
printf("\nSPI transfer failed!\n");}
//printf("%x",receiveBuffer[0]);
}
}
/*
* ======== main ========
*/
#ifndef BARE_METAL
int main(void)
{
System_printf("Start Setup\n");
/* Call board init functions */
Board_initSPI();
/* Configure task. */
//Task_Params taskParams;
//Task_Params_init(&taskParams);
//taskParams.stack = myTaskStack;
//taskParams.stackSize = sizeof(myTaskStack);
//Task_construct(&myTaskStruct, spi_test, &taskParams, NULL);
System_printf("End Setup\n");
/* Start BIOS */
BIOS_start();
return (0);
}
#endif
Here is how the hwAttrs and object variables look like after opening the SPI_open:
And here is the outline of Variables before returning from SPI_transfer function in case when spi timeout is 1000:
What could be the reason for this?
If I can provide more information, please let me know.
Kind regards,
Dejana