LPSPI Send and receive data greater than 32bit

cancel
Showing results for 
Search instead for 
Did you mean: 

LPSPI Send and receive data greater than 32bit

99 Views
Contributor I

 I run into the problem of sending 10 Bytes of data, but TDR size is 32Bit. I tried several possibilities, as found in the NXP community:

// for loop: //for ( index = 0; index < sequence_length; ++index) {
// for loop: //LPSPI1->TDR = &txbuffer[index]; /* Transmit data */

// for loop: //}

// cast to 32Bit words

// LPSPI1->TDR = ((uint32_t)txbuffer[index] << 24)
// |((uint32_t)txbuffer[index+1] << 16)
// |((uint32_t)txbuffer[index+2] << /* Transmit data */
// |((uint32_t)txbuffer[index+3] ) ;
// LPSPI1->TDR = ((uint32_t)txbuffer[index+4] << 24)
// |((uint32_t)txbuffer[index+5] << 16)
// |((uint32_t)txbuffer[index+6] << /* Transmit data */
// |((uint32_t)txbuffer[index+7] ) ;
// LPSPI1->TDR = ((uint32_t)txbuffer[index+8] << 24)
// |((uint32_t)txbuffer[index+9] << 16);

Nothing is working, also receiving more than 32 Bits is not working! 

How should the sending and receiving of data greater than 32Bit word file be implemented?

and How should the framesize be adjusted? (I changed it to 80bits)

0 Kudos
3 Replies

83 Views
NXP TechSupport
NXP TechSupport

Hello Maurice,

Could you please elaborate on what exactly does not work?

Can you scope the bus and share it?

I modified the S32K144_Project_LPSPI example from the S32DS IDE to send 80b frames.

Because it does not read the RX data, CFGR1_NOSTALL = 1.

danielmartynek_0-1600778817869.png

Regards,

Daniel

 

0 Kudos

73 Views
Contributor I

Hi Daniel,

thank you for the example.

But my problem actual is the change of the framsize during runtime. I have SPI messages that are 3 Bytes long. And then I have to write 10 Bytes and read 10 Bytes. My problem is, that when I watch the framsesize in TCR register, it will only change from 23 bit to 79 bit when I step through. In running mode (without breakpoints) the Framsesize changes somehow to 0x05F...but this value is never been written to the TCR.

Do you have an example where the framesize is changed ? Attached I have

Framesize is 0x05FFramesize is 0x05Fspi send  80bit (but it is more)spi send 80bit (but it is more)spi send 24 bitspi send 24 bit

0 Kudos

54 Views
NXP TechSupport
NXP TechSupport

Hi Maurice.

You probably mask the register (read-modify-write operation)

TCR |= new_command;

because

23 = 0x17

79 = 0x4F

0x17 | 0x4F = 0x5F.

 

Please write the PCR register with a 32b word directly.

TCR = command_framesize_80b;

TCR = command_framesize_24b;

 

Thank you,

BR, Daniel

 

 

 

 

0 Kudos