Other Parts Discussed in Thread: CC3235SF
Hello,
I am trying to get correct data on SPI port. But I am facing a strange behavior.
I am using cc3235 as a SPI master and trying to perform an SPI transaction.
The data sent is always as expected. But, sometimes the data is received over SPI is as expected
and sometimes the data received is incorrect.
I checked the data on Logic analyzer it is correct and as expected. Please check attached screenshot.
Below are the settings i am using:
{
.baseAddr = GSPI_BASE,
.intNum = INT_GSPI,
.intPriority = (~0),
.spiPRCM = PRCM_GSPI,
.csControl = SPI_SW_CTRL_CS,
.csPolarity = SPI_CS_ACTIVELOW,
.pinMode = SPI_3PIN_MODE,
.turboMode = SPI_TURBO_OFF,
.scratchBufPtr = &spiCC3235SDMAscratchBuf[CC3235SF_LAUNCHXL_SPI1],
.defaultTxBufValue = 0,
.rxChannelIndex = UDMA_CH6_GSPI_RX,
.txChannelIndex = UDMA_CH7_GSPI_TX,
.minDmaTransferSize = 100,
.mosiPin = SPICC32XXDMA_PIN_07_MOSI,
.misoPin = SPICC32XXDMA_PIN_06_MISO,
.clkPin = SPICC32XXDMA_PIN_05_CLK,
.csPin = SPICC32XXDMA_PIN_NO_CONFIG
}
SPI_Params_init(&spiParams);
// spiParams.frameFormat = SPI_POL0_PHA0;
spiParams.mode = SPI_MASTER;
spiParams.bitRate = 2000000;
spiParams.dataSize = 8;
masterSpi = SPI_open(Board_SPI0, &spiParams);
if (masterSpi == NULL) {
UART_PRINT("Error initializing master SPI\n");
while (1);
}
else {
UART_PRINT("Master SPI initialized\n");
}
int32_t cc_spi_read(uint8_t *buff, uint32_t len)
{
/* Assert CS */
GPIO_write(CC3235SF_GPIO_OV_SPI_CS,0);
transaction.count = len;
transaction.txBuf = NULL;
transaction.rxBuf = (void *) buff;
SPI_transfer(masterSpi, &transaction);
/* Deassert CS */
GPIO_write(CC3235SF_GPIO_OV_SPI_CS,1);
return len;
}