Max SPI Transfer Length on K64

cancel
Showing results for 
Search instead for 
Did you mean: 

Max SPI Transfer Length on K64

985 Views
jerrygardner
Contributor III

What is the maximum number of bits that can be transferred in a single SPI operation on a K64? The reference manual says: "The module is in SPI configuration when the DCONF

field in the MCR is 0b00. The SPI frames can be 32 bits long." However, the FMSZ (frame size) field in the SPIx_CTARn register is only four bits wide, which would imply a maximum frame size of 16 bits.

4 Replies

619 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jerry Gardner,

    From the K64 reference manual,  register SPIx_PUSHR description, you will get that:

In Master mode, the register transfers 16 bits of data and 16 bits of command information.In Slave mode, all 32 bits can be used as data, supporting up to 32-bit frame operation.

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!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

619 Views
muriukidavid
Contributor II

I think the question was about the frame size (<=16) as can be set in the register SPIx_CTARn in the FMSZ bit-field . Can you, for example set 4-bit,5-bit,6-bit,7bit, 8bit... 16bit mode and be sending those many bits per frame? while still under 16 bits in length?

0 Kudos

619 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi David,

Please check the reference manual description:

pastedImage_1.png

 Each frame bit size is determined by SPIx_CTARn in the FMSZ bit-field. it can send 4-bit,5-bit,6-bit,7bit, 8bit... 16bit per frame.

But, if you need the frame size is larger than 16bits, you need to use the continuous format.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

619 Views
muriukidavid
Contributor II

Yes Zhou, I wanted to communicate with a slave [a nokia 1616 LCD] which has a serial interface with 9-bit mode where the 9th bit is the C/D indicator bit. If it's set, the other 8-bits represent data and if its cleared, they represent one of the many commands for setting up the device. I have tested it with bit-banging and it works. I tried using Processor Expert generated code, it didn't work. First of all, even after setting the data width to 9-bit in settings, the type used for the output buffer variable and the argument to the sendchar function in the generated code is byte, which is defined as unsigned char. This means the 9th bit gets truncated anyway if you do type casting of your uint16_t to byte. I modified the generated code and changed all those variables to uint16_t and debugged up to the point the data is being written into the output register, the lower 16-bits of data had valid command/data values. Still it didn't work. I checked that the SPI master conforms to the minimum timing requirements of the serial transmission timings of the slave, it still didn't work.

According to my understanding, the SPI0_PUSHR should contain lower 16 bits of data to be sent and upper 16bits of command information which determines how the data is sent. What I want to know is, if you set 9-bit mode, does it mean that the first 9 bits of this data are sent serially one by one and after that, no more of the rest of the bits are shifted until the next frame? If this is the case, then hardware SPI should work just as the bit-banging worked. Here is the repo with the code I was testing: GitHub - Muriukidavid/K64_LCD: A repository for testing the K64 hardware SPI for 9-bit LCDs 

I had to configure the SPI pins as GPIO ATL1 to initialize the LCD because it requires a very specific routine of the signals. Then I use the connectPin function to reconnect the pins to SPI0.