I want to use lpspi1 as master to transmit 3 * 16 bit as a frame to slave MC33664.
But tx clk is not correct. when i send 48 bit as a frame ,the clk and data cs all waveform is correct and MC33664 return data can be received by lpspi2 as slave. when slave set LPSPI_TCR_FRAMESZ as 16 bit ,the receive data order is not correct. but set LPSPI_TCR_FRAMESZ as 48 bit is correct. I think it might be used not correctly of LPSPI_TCR_CONT and LPSPI_TCR_CONTC register .But I tried different combinations of these,none of them succeeded.
Please tell me how to configure a continuous frame. my code refer to attachment. Thank you.
解決済! 解決策の投稿を見る。
Hi @Xjh193,
This is you code:
MC33664_MASTER_SPI_HANDLE->TCR = LPSPI_TCR_CPOL(0) | LPSPI_TCR_CPHA(1) | LPSPI_TCR_PCS(0) | LPSPI_TCR_PRESCALE(MC33664_CLK_FRE)
| LPSPI_TCR_CONT(1) | LPSPI_TCR_CONTC(1) | LPSPI_TCR_FRAMESZ(16 - 1) | LPSPI_TCR_TXMSK(1);
MC33664_MASTER_SPI_HANDLE->TDR = tx[0];
MC33664_MASTER_SPI_HANDLE->TDR = tx[1];
MC33664_MASTER_SPI_HANDLE->TCR = LPSPI_TCR_CPOL(0) | LPSPI_TCR_CPHA(1) | LPSPI_TCR_PCS(MC33664_PCS_MAP[id]) | LPSPI_TCR_PRESCALE(MC33664_CLK_FRE)
| LPSPI_TCR_CONT(0) | LPSPI_TCR_CONTC(0) | LPSPI_TCR_FRAMESZ(16 - 1) | LPSPI_TCR_TXMSK(1);
MC33664_MASTER_SPI_HANDLE->TDR = tx[2];
In the first command, you have both CONT can CONTC set.
But only CONT should be set, becasuse it starts a new continuous transfer (CONT = 1) but it does not change an ongoing continuous transfer (CONTC = 0).
Then, you can write all the three 16bit words (please check if there is a place in the FIFO left).
And terminate the continuous transfer with a new command where (CONT = 0, CONTC = 0).
There is actualy no need for CONTC = 1, becasue you don't change any parameters of the continous transfer specified in the first command, you just start it and terminate it.
Regards,
Daniel
Hi @Xjh193,
This is you code:
MC33664_MASTER_SPI_HANDLE->TCR = LPSPI_TCR_CPOL(0) | LPSPI_TCR_CPHA(1) | LPSPI_TCR_PCS(0) | LPSPI_TCR_PRESCALE(MC33664_CLK_FRE)
| LPSPI_TCR_CONT(1) | LPSPI_TCR_CONTC(1) | LPSPI_TCR_FRAMESZ(16 - 1) | LPSPI_TCR_TXMSK(1);
MC33664_MASTER_SPI_HANDLE->TDR = tx[0];
MC33664_MASTER_SPI_HANDLE->TDR = tx[1];
MC33664_MASTER_SPI_HANDLE->TCR = LPSPI_TCR_CPOL(0) | LPSPI_TCR_CPHA(1) | LPSPI_TCR_PCS(MC33664_PCS_MAP[id]) | LPSPI_TCR_PRESCALE(MC33664_CLK_FRE)
| LPSPI_TCR_CONT(0) | LPSPI_TCR_CONTC(0) | LPSPI_TCR_FRAMESZ(16 - 1) | LPSPI_TCR_TXMSK(1);
MC33664_MASTER_SPI_HANDLE->TDR = tx[2];
In the first command, you have both CONT can CONTC set.
But only CONT should be set, becasuse it starts a new continuous transfer (CONT = 1) but it does not change an ongoing continuous transfer (CONTC = 0).
Then, you can write all the three 16bit words (please check if there is a place in the FIFO left).
And terminate the continuous transfer with a new command where (CONT = 0, CONTC = 0).
There is actualy no need for CONTC = 1, becasue you don't change any parameters of the continous transfer specified in the first command, you just start it and terminate it.
Regards,
Daniel
hi@Daniel, accoding to your guidance ,I sent 0x1122 0x3344 0x5566 data and get them. Thank you!
Now I want to use DMA channel to receive spi data,but failed. I check the related register , found that the TCD0_DADDR are not added. I enable DMAMUX_0, DMA_TCD0 clock. source 48(lspi2 rx request) ,DMA channel 0. See the attachment for the more configuration. I'm looking forward to you reply.