Skip to main content
Associate III
February 27, 2024
Solved

SPI frame size more than 4 bytes

  • February 27, 2024
  • 2 replies
  • 1652 views

Hello

I working with spc560p and I send or receive with SPI very good and had no problem, but if I want to send or receive more than 4 bytes (32bits) in one message (one chip select), what should I do? 

I used this format for send and receive:

 

spi_lld_start(&SPID2, &spi_config_Achip);

spi_lld_exchange(&SPID2, 4, txbuf, rxbuf);

spi_lld_stop(&SPID2);

 

Is there any sample in spc5studio wizard?

Best answer by Giuseppe DI-GIORE

Hello,

the second parameter of the spi_lld_exchange() defines the number bytes to be transferred in a single exchange operation.

In your example is the to 4 (that i: 4 bytes =  32 bits), just increase it to the number of bytes to be transferred in a single exchange.

For example, to transfer 64 bytes:

spi_lld_start(&SPID2, &spi_config_Achip);

spi_lld_exchange(&SPID2, 64, txbuf, rxbuf);

spi_lld_stop(&SPID2);

 

Best Regards

2 replies

Giuseppe DI-GIORE
ST Employee
April 16, 2024

Hello,

the second parameter of the spi_lld_exchange() defines the number bytes to be transferred in a single exchange operation.

In your example is the to 4 (that i: 4 bytes =  32 bits), just increase it to the number of bytes to be transferred in a single exchange.

For example, to transfer 64 bytes:

spi_lld_start(&SPID2, &spi_config_Achip);

spi_lld_exchange(&SPID2, 64, txbuf, rxbuf);

spi_lld_stop(&SPID2);

 

Best Regards

DNewm.1Author
Associate III
June 17, 2024

Thanks my friend.