AnsweredAssumed Answered

Using the KSDK SPI transfer function, how do I continuity send data?

Question asked by Thanh Duong on Apr 12, 2016
Latest reply on Apr 13, 2016 by Thanh Duong



I apologize in advance as I am new to KDS and Freescale devices. I want to know how I would go about sending multiple bytes of data WITH the chip select saying low, when using the KSDK SPI library. I am using KSDK v1.3 and the frdm-kl25z board.


The device I am communicating to has commands larger than a byte. The chip select signifies whether it is a different command. From the KSDK library, there is a blocking transfer fuction called SPI_DRV_MasterTransferBlocking(). I know it takes a couple of parameters, i.e what instance of spi you are using, config setting, sending data, receiving data, number of bytes, and timeout.


The problem I am having with this function is when I want to send multiple bytes, I would increase the amount of data I will send and the number of bytes it is, but it would toggle each time it sends data. For an example:


SPI_DRV_MasterTransferBlocking(spi0_idx, &spio_masterconfig, {0x4A}, NULL, 1, 1000)

This function selects spi0 module, sets configuration to master (this could be NULL if configured already), sends data 0x4A, expects no data to be received, and the number of bytes it will send is 1. If sending takes longer than 1000 ms, it will timeout. The chip select is put low then data is clocked out. This occurs once because I am only sending 1 byte.


sendbuffer[0] = {0x4A}

sendbuffer[1] = {0x46}


SPI_DRV_MasterTransferBlocking(spi0_idx, &spio_masterconfig, sendbuffer, NULL, 2, 1000)

Similar to above, except I am sending 2 bytes, 0x4A and 0x46. What I want to happen is that, when sending 2 bytes of data, the chip select stays low until all bytes have completed. But what I see is that chip select is toggled for each send.


How would I gain control of the chip select to keep it low for the duration of the send command? Is it possible? Would I be better of not using the library and doing it myself?


Thank you in advance!