What does the LPSPI transmit data zero-extend feature do for MSB first?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

What does the LPSPI transmit data zero-extend feature do for MSB first?

ソリューションへジャンプ
1,455件の閲覧回数
imxrtuser
Senior Contributor I

Hello,

the LPSPI Transmit Data Register TDR is built so that it zero-extends 8 and 16 bit writes

pastedImage_1.png

We want to fill the FIFO with DMA transfers. In case I have 5 bytes of data and a Framesize of 5 * 8 = 40 to send I will have one 4 byte DMA transfer and one 1 byte DMA transfer.

The last DMA transfer will only write 8 bit to the register therefore the bits 8 to 31 will be zero.

  1. If the LPSPI module is set to MSB first will it send the zero data bits 24 to 31 instead of my expecet data?
  2. If yes is it possible to write to bits 24 to 31 in TDR with DMA and will the lower bits automatically be 0 too?
  3. Because of the limitation of DMA to 1,2 and 4 byte transfers it is not possible to send e.g. 3 bytes because I would have to write first 2 bytes to TDR (which will result in 2 zero bytes and 2 data bytes in TX FIFO) and then 1 byte (3 zero bytes in FIFO) which will result in at least 2 unwanted zero-bytes sent out through SPI right?

Kind regards,

Stefan

0 件の賞賛
返信
1 解決策
1,380件の閲覧回数
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I did a test based on MCUXpresso SDK interrupt_b2b_master demo.

I make below change with the code:

uint32_t masterRxData[TRANSFER_SIZE] = {0U};

/*Master config*/
masterConfig.baudRate = TRANSFER_BAUDRATE;
masterConfig.bitsPerFrame = 40; //8;
masterConfig.cpol = kLPSPI_ClockPolarityActiveHigh;
masterConfig.cpha = kLPSPI_ClockPhaseFirstEdge;
masterConfig.direction = kLPSPI_MsbFirst;

masterTxData[0] = 0x11223344;
masterTxData[1] = 0x55;

I could get below transfer siganl from captured scope:

pastedImage_1.png

So, the LPSPI module is set to MSB first it will send your expecet data.


Have a great day,
Mike

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

元の投稿で解決策を見る

2 返答(返信)
1,381件の閲覧回数
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I did a test based on MCUXpresso SDK interrupt_b2b_master demo.

I make below change with the code:

uint32_t masterRxData[TRANSFER_SIZE] = {0U};

/*Master config*/
masterConfig.baudRate = TRANSFER_BAUDRATE;
masterConfig.bitsPerFrame = 40; //8;
masterConfig.cpol = kLPSPI_ClockPolarityActiveHigh;
masterConfig.cpha = kLPSPI_ClockPhaseFirstEdge;
masterConfig.direction = kLPSPI_MsbFirst;

masterTxData[0] = 0x11223344;
masterTxData[1] = 0x55;

I could get below transfer siganl from captured scope:

pastedImage_1.png

So, the LPSPI module is set to MSB first it will send your expecet data.


Have a great day,
Mike

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,380件の閲覧回数
imxrtuser
Senior Contributor I

Thank you for testing it Mike!

0 件の賞賛
返信