LPSPI FRAMESZ and Receive Data Register

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

LPSPI FRAMESZ and Receive Data Register

跳至解决方案
2,167 次查看
vusal
Contributor III

Hello,

I'm interfacing S32K3xx with an external flash memory. This chip requires different size command and data combinations. For example, to read the status register one needs to send 1 byte command and wait for 1 byte of data to appear on the MISO line. Frame size can range from 8 bits to several bytes. Is there a way to interface this chip without needing changing FRAMESZ each time?

In the above example, I couldn't just send 1 byte of command. I had to send an extra dummy byte to allow for the memory chip to respond. So, my frame size had to be 16 bits long. I have other use cases where I am sending 1 byte of command + 3 bytes of address + 10 bytes of data (just an example). It seem like each time my data changes I have to modify the FRAMESZ.

Another question: It seem like to get correct data in the SPI data register I have to read that register each time I send out a frame. Is this how the SPI set up?

LPSPI1_transmit_16bits(tx_16bits); /* Transmit half word (16 bits) on LPSPI1 */
LPSPI1_16bits_read = LPSPI1_receive_16bits(); /* Receive half word on LSPI1 */

Thank you very much for your help!

Vusal

0 项奖励
回复
1 解答
2,148 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Vusal,

I understand you need to keep CS asserted throughout the whole 14-byte transfer (using the example, 1 byte of command + 3 bytes of address + 10 bytes of data).

For that, the LPSPI Continous mode can be used (TCR[CONT = 1]).

FRAMESZ can be set to 8bit frames.

The LPSPI will keep CS asserted until a new command with TCR[CONT = 0].

 

RTD LPSPI_IP driver

danielmartynek_0-1718355095205.png

Call the function below with Length = 14.

danielmartynek_1-1718355278613.png

 

Regards,

Daniel

 

在原帖中查看解决方案

4 回复数
2,149 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Vusal,

I understand you need to keep CS asserted throughout the whole 14-byte transfer (using the example, 1 byte of command + 3 bytes of address + 10 bytes of data).

For that, the LPSPI Continous mode can be used (TCR[CONT = 1]).

FRAMESZ can be set to 8bit frames.

The LPSPI will keep CS asserted until a new command with TCR[CONT = 0].

 

RTD LPSPI_IP driver

danielmartynek_0-1718355095205.png

Call the function below with Length = 14.

danielmartynek_1-1718355278613.png

 

Regards,

Daniel

 

2,124 次查看
vusal
Contributor III

Hi Daniel,

Thank you for your message. This fixed the issue.

One more quick question: It seem like to get correct data in the SPI data register I have to read that register each time I send out a frame. Is this how the SPI set up?

LPSPI1_transmit_16bits(tx_16bits); /* Transmit half word (16 bits) on LPSPI1 */
LPSPI1_16bits_read = LPSPI1_receive_16bits(); /* Receive half word on LSPI1 */


Thank you!

Best,
Vusal

0 项奖励
回复
2,098 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

There is 4x32b RX FIFO disabled by default.

danielmartynek_0-1718707863682.png

danielmartynek_1-1718707956067.png

 

BR, Daniel

 

 

2,086 次查看
vusal
Contributor III
Thank you!
0 项奖励
回复
%3CLINGO-SUB%20id%3D%22lingo-sub-1887242%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ELPSPI%20FRAMESZ%20%E5%92%8C%E6%8E%A5%E6%94%B6%E6%95%B0%E6%8D%AE%E5%AF%84%E5%AD%98%E5%99%A8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1887242%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%EF%BC%8C%3CBR%20%2F%3E%3CBR%20%2F%3E%E6%88%91%E6%AD%A3%E5%9C%A8%E5%B0%86%20S32K3xx%20%E4%B8%8E%E5%A4%96%E9%83%A8%E9%97%AA%E5%AD%98%E8%BF%9E%E6%8E%A5%E8%B5%B7%E6%9D%A5%E3%80%82%E8%AF%A5%E8%8A%AF%E7%89%87%E9%9C%80%E8%A6%81%E4%B8%8D%E5%90%8C%E5%A4%A7%E5%B0%8F%E7%9A%84%E5%91%BD%E4%BB%A4%E5%92%8C%E6%95%B0%E6%8D%AE%E7%BB%84%E5%90%88%E3%80%82%E4%BE%8B%E5%A6%82%EF%BC%8C%E8%A6%81%E8%AF%BB%E5%8F%96%E7%8A%B6%E6%80%81%E5%AF%84%E5%AD%98%E5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%E4%BD%8D%E9%95%BF%E3%80%82%E6%88%91%E8%BF%98%E6%9C%89%E5%85%B6%E4%BB%96%E7%94%A8%E4%BE%8B%EF%BC%8C%E5%85%B6%E4%B8%AD%E6%88%91%E5%8F%91%E9%80%81%201%20%E5%AD%97%E8%8A%82%E7%9A%84%E5%91%BD%E4%BB%A4%20%2B%203%20%E5%AD%97%E8%8A%82%E7%9A%84%E5%9C%B0%E5%9D%80%20%2B%2010%20%E5%AD%97%E8%8A%82%E7%9A%84%E6%95%B0%E6%8D%AE%EF%BC%88%E4%BB%85%E4%BD%9C%E4%B8%BA%E7%A4%BA%E4%BE%8B%EF%BC%89%E3%80%82%E4%BC%BC%E4%B9%8E%E6%AF%8F%E6%AC%A1%E6%88%91%E7%9A%84%E6%95%B0%E6%8D%AE%E5%8F%91%E7%94%9F%E5%8F%98%E5%8C%96%E6%97%B6%E6%88%91%E9%83%BD%E5%BF%85%E9%A1%BB%E4%BF%AE%E6%94%B9%20FRAMESZ%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E5%8F%A6%E4%B8%80%E4%B8%AA%E9%97%AE%E9%A2%98%EF%BC%9A%E4%BC%BC%E4%B9%8E%E4%B8%BA%E4%BA%86%E5%9C%A8%20SPI%20%E6%95%B0%E6%8D%AE%E5%AF%84%E5%AD%98%E5%99%A8%E4%B8%AD%E8%8E%B7%E5%8F%96%E6%AD%A3%E7%A1%AE%E7%9A%84%E6%95%B0%E6%8D%AE%EF%BC%8C%E6%88%91%E5%BF%85%E9%A1%BB%E5%9C%A8%E6%AF%8F%E6%AC%A1%E5%8F%91%E9%80%81%E4%B8%80%E5%B8%A7%E6%97%B6%E8%AF%BB%E5%8F%96%E8%AF%A5%E5%AF%84%E5%AD%98%E5%99%A8%E3%80%82SPI%20%E6%98%AF%E8%BF%99%E6%A0%B7%E8%AE%BE%E7%BD%AE%E7%9A%84%E5%90%97%EF%BC%9F%3CBR%20%2F%3E%3CBR%20%2F%3E%20LPSPI1_transmit_16bits(tx_16bits)%3B%20%2F*%20%E5%9C%A8%20LPSPI1%20%E4%B8%8A%E4%BC%A0%E8%BE%93%E5%8D%8A%E5%AD%97%EF%BC%8816%20%E4%BD%8D%EF%BC%89*%2F%3CBR%20%2F%3E%20LPSPI1_16bits_read%20%3D%20LPSPI1_receive_16bits()%3B%20%2F*%20%E5%9C%A8%20LSPI1%20%E4%B8%8A%E6%8E%A5%E6%94%B6%E5%8D%8A%E5%AD%97%20*%2F%3CBR%20%2F%3E%3CBR%20%2F%3E%E9%9D%9E%E5%B8%B8%E6%84%9F%E8%B0%A2%E6%82%A8%E7%9A%84%E5%B8%AE%E5%8A%A9%EF%BC%81%3CBR%20%2F%3E%3CBR%20%2F%3E%E6%AD%A6%E8%90%A8%E5%B0%94%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1889503%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9ALPSPI%20FRAMESZ%20%E5%92%8C%E6%8E%A5%E6%94%B6%E6%95%B0%E6%8D%AE%E5%AF%84%E5%AD%98%E5%99%A8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1889503%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E9%9D%9E%E5%B8%B8%E6%84%9F%E8%B0%A2%EF%BC%81%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1888870%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9ALPSPI%20FRAMESZ%20%E5%92%8C%E6%8E%A5%E6%94%B6%E6%95%B0%E6%8D%AE%E5%AF%84%E5%AD%98%E5%99%A8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1888870%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E5%97%A8%EF%BC%8C%E4%B8%B9%E5%B0%BC%E5%B0%94%EF%BC%8C%3CBR%20%2F%3E%3CBR%20%2F%3E%E6%84%9F%E8%B0%A2%E6%82%A8%E7%9A%84%E7%95%99%E8%A8%80%E3%80%82%E8%BF%99%E8%A7%A3%E5%86%B3%E4%BA%86%E8%AF%A5%E9%97%AE%E9%A2%98%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E8%BF%98%E6%9C%89%E4%B8%80%E4%B8%AA%E5%BF%AB%E9%80%9F%E9%97%AE%E9%A2%98%EF%BC%9A%3CSPAN%3E%E4%B8%BA%E4%BA%86%E5%9C%A8SPI%E6%95%B0%E6%8D%AE%E5%AF%84%E5%AD%98%E5%99%A8%E4%B8%AD%E8%8E%B7%E5%8F%96%E6%AD%A3%E7%A1%AE%E7%9A%84%E6%95%B0%E6%8D%AE%EF%BC%8C%E6%88%91%E6%AF%8F%E6%AC%A1%E5%8F%91%E9%80%81%E4%B8%80%E5%B8%A7%E6%97%B6%E9%83%BD%E5%BF%85%E9%A1%BB%E8%AF%BB%E5%8F%96%E8%AF%A5%E5%AF%84%E5%AD%98%E5%99%A8%E3%80%82SPI%E6%98%AF%E8%BF%99%E6%A0%B7%E8%AE%BE%E7%BD%AE%E7%9A%84%E5%90%97%EF%BC%9F%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%20%3CSPAN%3ELPSPI1_transmit_16bits(tx_16bits)%3B%20%2F*%20%E5%9C%A8%20LPSPI1%20%E4%B8%8A%E4%BC%A0%E8%BE%93%E5%8D%8A%E5%AD%97%EF%BC%8816%20%E4%BD%8D%EF%BC%89*%2F%3C%2FSPAN%3E%3CBR%20%2F%3E%20%3CSPAN%3ELPSPI1_16bits_read%20%3D%20LPSPI1_receive_16bits()%3B%20%2F*%20%E5%9C%A8%20LSPI1%20%E4%B8%8A%E6%8E%A5%E6%94%B6%E5%8D%8A%E5%AD%97%20*%2F%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%E8%B0%A2%E8%B0%A2%E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