K70 SPI Framesize

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K70 SPI Framesize

599 Views
MarkyNXP
Contributor I

mcu: K70FX512VMJ12

I'm trying to get a new LCD screen going but i need to send 9 bit spi packets (see image). On the K70, I tried to change the framesize to 9 but the LCD still does not communicate. I don't want to write a bit-bang SPI driver, so can the framesize be set to 9?  I send the data as a uint16, but im not sure if the SPI is sending the extra zeros.  I might need to hook up a scope.  

LCDSPIST7_1.PNG

See code below. I want to make sure this is the proper way to send 9 bit packets.

In my initialize function I change the frame size to 9bits (along with other spi init):

// 9bit frame size
param = 9;
if (SPI_OK != ioctl(spiFileHandle, IO_IOCTL_SPI_SET_FRAMESIZE, &param))
{
    printf ("Error: unable to set LCD SPI interface\n");
}

Here is my spi write function:

static void SPI_Write(uint16_t i)
{
    int_32 result = 0;
    uint_16 retryCount = SPI_RETRY_COUNT;
    uint_32 param = 0;

    // Toggle CS1 Low
    SetOutput(nSPI0_PCS1_OUTPUT, FALSE);

    // Write Command/Data to SPI
    retryCount = SPI_RETRY_COUNT;
    do
    {
        result = fwrite((void *)&i, 2, 1, spiFileHandle);
        retryCount--;
    }
    while ((result < 1) && (retryCount > 0));

    // Toggle CS1 High
    SetOutput(nSPI0_PCS1_OUTPUT, TRUE);
}

 

 

Labels (1)
Tags (3)
0 Kudos
1 Reply

578 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi MarkyNXP,

   About the K70 SPI frame size,  it can support programmable serial frame size: 4 to 16 bits.

  You can configure it in this register:

kerryzhou_0-1615259735738.png

So, please check your code, and debug the code, check the register, whether the above FMSZ is configured to 8? Then the real number of bits per frame should be 9.

You also can test the SPI bus data which is sent out from K70, whether it is really 9 bits.

 

Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

 

0 Kudos