Gokulnath Kasinathan

K82 SPI chip select not going high at end of frame transfer

Discussion created by Gokulnath Kasinathan on Sep 27, 2018
Latest reply on Oct 23, 2018 by Kerry Zhou


My Project requirement is to use K82 SPI transfer to communicate a  slave device.

The requirements for Slave side is the following,

Frame transfer is 16 bits,

CPOL = 0;

CPHA =0; So its mode 0 SPI communication for SCK 

Active Low chip select for 16 bits (also know as slave select)

I need to send some 64 bytes, means 32 frames in total.

So at the end of each frame transfer is completed, I should see Chip Select(slave select) getting low to high.

I used the code given from demo project SDK examples, dspi_half_duplex_polling_master for FRDM k82, which suited my requirements and made the following changes in initial configuration,



int main(void)


/* Transfer structure for half-duplex. */
dspi_half_duplex_transfer_t xfer = {0};
dspi_master_config_t masterConfig;



masterConfig.whichCtar = kDSPI_Ctar0;
masterConfig.ctarConfig.baudRate = TRANSFER_BAUDRATE;
masterConfig.ctarConfig.bitsPerFrame = 16;
masterConfig.ctarConfig.cpol = kDSPI_ClockPolarityActiveHigh;
masterConfig.ctarConfig.cpha = kDSPI_ClockPhaseFirstEdge;
masterConfig.ctarConfig.direction = kDSPI_MsbFirst;
masterConfig.ctarConfig.pcsToSckDelayInNanoSec = 1000000000U / TRANSFER_BAUDRATE;
masterConfig.ctarConfig.lastSckToPcsDelayInNanoSec = 1000000000U / TRANSFER_BAUDRATE;
masterConfig.ctarConfig.betweenTransferDelayInNanoSec = 500000000000U / TRANSFER_BAUDRATE;

masterConfig.pcsActiveHighOrLow = kDSPI_PcsActiveLow;

masterConfig.enableContinuousSCK = false;
masterConfig.enableRxFifoOverWrite = false;
masterConfig.enableModifiedTimingFormat = false;
masterConfig.samplePoint = kDSPI_SckToSin0Clock;
DSPI_MasterInit(EXAMPLE_DSPI_MASTER_BASEADDR, &masterConfig, srcFreq);


// filled the data I need to configure my slave device

for (i = 0; i < BUFFER_SIZE; i++)
txData[i] = 1U;


/*Start Transfer by polling mode. */
xfer.txData = txData;
xfer.rxData = NULL;
xfer.txDataSize = sizeof(txData);
xfer.rxDataSize = 0; 
xfer.isTransmitFirst = true;
xfer.isPcsAssertInTransfer = true;
xfer.configFlags = kDSPI_MasterCtar0 | EXAMPLE_DSPI_MASTER_PCS_FOR_TRANSFER | kDSPI_PcsActiveLow;


 DSPI_MasterHalfDuplexTransferBlocking(EXAMPLE_DSPI_MASTER_BASEADDR, &xfer);


/* Stop the transfer. */

while (1)
      { }


I am unable to see chip select getting active low for every 32 frame, and 16 clock pulse per frame and data in MOSI.

But Iam able to see proper data in another K82 as half duplex slave, and receives correct data when the only change in line, 

xfer.configFlags = kDSPI_MasterCtar0 | EXAMPLE_DSPI_MASTER_PCS_FOR_TRANSFER | kDSPI_MasterPcsContinuous ;


with MasterPcsContinuous instead of PcsActiveLow. I also kept delay between transfer of frames as 

masterConfig.ctarConfig.betweenTransferDelayInNanoSec = 500000000000U / TRANSFER_BAUDRATE;.

Yet I am unable to see my 32 frames with chip select going high to low  and low to high 32 times and 16 clock pulses per frame in scope.

Please help me if Iam making any mistakes.