Hi,
The Spi driver have a selection of frame size up to 16 bits.
SPI_CTAR_FMSZ(0x0F);
1. My question is how to make it 24bits. My application needs SPI to send and receive 24bits a frame without CS and unnecessary Data Input toggling within a frame. Any suggestion or sample code?
2. I think the PE Component Inspector Property Page: using Delay Between Frames is more accurate than using Delay between chars.
Thank you
David Zhou
Solved! Go to Solution.
Hi David,
Could you tell me the partnumber of your chip?
If it is the kinetis K series.
1. From the SPIx_CTARn[FMSZ], you will know, the max data is 16bits, so you can't configure it with 24bits, but you can configure the frame as 8bits, then send 3 frames. If you don't want the CS pull up between the 24bits, you can just control it as active low with the code.Eg, you can configure the CS pin as the GPIO, then the cs pin won't be controlled by the SPI module, it will be controlled by the GPIO, now, you can use the GPIO code to pull down the CS before send 24bits frame, after the SPI data is sent, then you can pull up the CS pin with GPIO code.
For this part, there still no according project, but it is not complicate, you can write the code by yourself, just disable the CS spi function, and configure your CS pin as the GPIO function.
For the SPI sample code, you can refer the KSDK2.0 for K64, just download it from this link:Welcome to Kinetis Expert | Kinetis Expert
After you download it, you can find the SPI sample code in folder:SDK_2.0_FRDM-K64F\boards\frdmk64f\driver_examples\dspi
2. Thank you for your suggestion. Could you tell me which SPI module you are using in the PE now?
Wish it helps you!
If you still have question, please contact with me!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello David
By default, SPI data length is set in SPI Data Size and Control Register. First, I need to check whether the hardware supports 24bits SPI data length. What is the part number of your MCU? And what CodeWarrior version you are using?
Best Regards
Fiona Kuang
Technical Information & Commercial Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Mark Correct button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi JingJing & Fiona,
My MCU is K60 F120M: TWRK60F120MUM (Tower), MK60FN1M0VLQ12 (MCU).
I am using 8Bits frame and works. The only thing is the time delay between frames (bytes, in this case) has minimum one clock cycle delay, and data output (from MCU master) is high. But it works, so it is ok with a clock delay.
You can close this tick.
Thank you for your support.
David Zhou
Hi David,
Could you tell me the partnumber of your chip?
If it is the kinetis K series.
1. From the SPIx_CTARn[FMSZ], you will know, the max data is 16bits, so you can't configure it with 24bits, but you can configure the frame as 8bits, then send 3 frames. If you don't want the CS pull up between the 24bits, you can just control it as active low with the code.Eg, you can configure the CS pin as the GPIO, then the cs pin won't be controlled by the SPI module, it will be controlled by the GPIO, now, you can use the GPIO code to pull down the CS before send 24bits frame, after the SPI data is sent, then you can pull up the CS pin with GPIO code.
For this part, there still no according project, but it is not complicate, you can write the code by yourself, just disable the CS spi function, and configure your CS pin as the GPIO function.
For the SPI sample code, you can refer the KSDK2.0 for K64, just download it from this link:Welcome to Kinetis Expert | Kinetis Expert
After you download it, you can find the SPI sample code in folder:SDK_2.0_FRDM-K64F\boards\frdmk64f\driver_examples\dspi
2. Thank you for your suggestion. Could you tell me which SPI module you are using in the PE now?
Wish it helps you!
If you still have question, please contact with me!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------