Hi!
I'm working with the Kinetis KL27Z connected with a SPI Flash Memory through SPI module.
Everything is working fine controlling the Chip Select or "Chip Enable" externally of the SPI functions using the "fsl_gpio", but I would like to control using the proper control of “Slave Select Pin” provided by “fsl_spi”. I had some tests and the device doesn’t answer when I’m sending or receiving more than one byte…
Here is the logic diagram provided by the memory manufacturer (Reading Chip ID, for example):
I'm using this component and their function:
The "fsl_gpio" configuration:
I needed to add a little delay to correct the toggle time of the “chip select “logic level. The code is shown below:
The device is working fine, like the proposal of the manufacturer:
Until here is ok, the device is working… But I would like to don’t use “delays” or “blocking” functions. I just need to use the interface with interrupts and live my main function free!
When I put the configuration of the “Slave Select Pin”, like below some problems occur...
The code...
...and device toggle the "Chip Enable" between each byte sent or received. The logic diagram is shown below:
My doubts are: It's a bug from the KSDK 1.3 or isn't possible to transfer multiple data bytes using just "fsl_spi" configurations?
Sorry my english... Thank's!
Solved! Go to Solution.
Hello Andre,
In fact, SPI module's functionality allows user to control SS automatically or manual, if you select automatic control on Slave Select, SS output feature automatically drives the SS pin low during transmission to select external devices and drives the SS pin high during idle to deselect external devices, it is to say, that if you are sending 8 (or 16) bits, once they have transfered, SS will go to idle state. (This is practical by a single communication scheme). On the other hand, if you want to send more than 8 bits (or 16 bits if you are using 16 bit extension) in the same transaction, you will need to use manual control, otherwise, SPI module will act as if these bits are different transactions. So it is not a Driver issue, it is SPI's module functionality.
So for your current transaction scheme, you can use manual control and also, replace the delay for next instructions:
error = SPI_DRV_MasterTransfer(SPI_MASTER_INSTANCE, NULL, spi_buffer, NULL, sizeof(spi_buffer)/sizeof(spi_buffer[0]));
if (kStatus_SPI_Success != error) {
#ifdef DEBUG
PRINTF("Error on SPI_DRV_MasterTransfer\r\n");
#endif
}
while(kStatus_SPI_Success != SPI_DRV_MasterGetTransferStatus(SPI_MASTER_INSTANCE, NULL));
The SPI_DRV_MasterGetTransferStatus function returns kstatus_SPI_Success when all data have been transfered, this way, you won't need delay function in order to finish the transaction.
I hope this can help you!
Best Regards,
Isaac Avila
----------------------------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
----------------------------------------------------------------------------------------------------------------------------------------
Hello Andre,
In fact, SPI module's functionality allows user to control SS automatically or manual, if you select automatic control on Slave Select, SS output feature automatically drives the SS pin low during transmission to select external devices and drives the SS pin high during idle to deselect external devices, it is to say, that if you are sending 8 (or 16) bits, once they have transfered, SS will go to idle state. (This is practical by a single communication scheme). On the other hand, if you want to send more than 8 bits (or 16 bits if you are using 16 bit extension) in the same transaction, you will need to use manual control, otherwise, SPI module will act as if these bits are different transactions. So it is not a Driver issue, it is SPI's module functionality.
So for your current transaction scheme, you can use manual control and also, replace the delay for next instructions:
error = SPI_DRV_MasterTransfer(SPI_MASTER_INSTANCE, NULL, spi_buffer, NULL, sizeof(spi_buffer)/sizeof(spi_buffer[0]));
if (kStatus_SPI_Success != error) {
#ifdef DEBUG
PRINTF("Error on SPI_DRV_MasterTransfer\r\n");
#endif
}
while(kStatus_SPI_Success != SPI_DRV_MasterGetTransferStatus(SPI_MASTER_INSTANCE, NULL));
The SPI_DRV_MasterGetTransferStatus function returns kstatus_SPI_Success when all data have been transfered, this way, you won't need delay function in order to finish the transaction.
I hope this can help you!
Best Regards,
Isaac Avila
----------------------------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
----------------------------------------------------------------------------------------------------------------------------------------