Hi @VaneB
As you mentioned before I try to RTD for half duplex SPI. When I send to data with using Lpspi_Ip_SyncTransmitHalfDuplex function how could I get data from slave.
Lpspi_Ip_AsyncTransmitHalfDuplex(&SLAVE_EXTERNAL_DEVICE, RxSlaveBuffer, NUMBER_OF_BYTES, LPSPI_IP_HALF_DUPLEX_RECEIVE, NULL_PTR);
/* Master transmits data in half-duplex mode by sync method */
Lpspi_Ip_SyncTransmitHalfDuplex(&MASTER_EXTERNAL_DEVICE, TxMasterBuffer, NUMBER_OF_BYTES, LPSPI_IP_HALF_DUPLEX_TRANSMIT, TIMEOUT);
after that should I write this function
Lpspi_Ip_AsyncTransmitHalfDuplex(&SLAVE_EXTERNAL_DEVICE, RxSlaveBuffer, NUMBER_OF_BYTES, LPSPI_IP_HALF_DUPLEX_TRANSMIT, NULL_PTR);
/* Master transmits data in half-duplex mode by sync method */
Lpspi_Ip_SyncTransmitHalfDuplex(&MASTER_EXTERNAL_DEVICE, TxMasterBuffer, NUMBER_OF_BYTES, LPSPI_IP_HALF_DUPLEX_RECEIVE, TIMEOUT);
Hi @maximillion,
A simple test project is in this thread:
https://community.nxp.com/t5/S32K/S32K314-SPI-flash-implementation/m-p/1617504#M21457
It sends one 8bit frame to the Slave device and reads 3 frames from the Slave device.
Regards,
Daniel
I only have 3 Wire Clock, Chip Select, Data.
Your project is not 3-wire. I've written so much that your community always suggests another answer.
I have attached the project.
I only have to use 3 wires. I need to send and receive at MOSI pin. In the example project, I sent and received data between two SPI modules, but in my own project I cannot read data from the slave because the master does not keep the chip select pin continuous while receiving data. Why chip select did not keep continuos?
Below picture master send data (LPSPI0) and slave receive data (LPSPI1) after that receive send data and master receive. Why doesn't the pcs pin keep the pin continuous while the master is receiving data? Please review the project.
Hello @danielmartynek
In the project I uploaded, LPSPI1 was used as master and LPSPI0 as slave.
In my project, S32K148 will be master and it will communicate with TFT display, so you can think of LPSPI0 module as TFT display. I need to configure the display with 3 wire spi. Below I have attached a photo of the SPI communication specified in the datashette. Also I attached my logic analyzer screnshoot. Could you please tell me how to read data from slave correctly from master?
Hello @maximillion,
I'm sorry for the delay, I couldn't get to the testing.
You example had a few issues, like both modules have to have one pin selected for both MOSI/MISO and the pin must be set as Input/Output.
Anyway, I think there is a bug in the RTD driver.
It has been reported to the RTD development team.
Once I have sone new information, I will update the thread.
Best regards,
Daniel
Hi @maximillion,
I don't see any issue with the 3wire mode, but with the Continues mode.
I have created the attached simple test project (Master only).
1. CONT = 0
2. CONT = 1
The issue is clearly in the Continuous mode.
Regards,
Daniel
How should I handle this issue?
Is this issue related to RTD driver isn't it?
Hi @maximillion,
Yes, it looks like it is a bug in RTD.
Have you consider using one 80bit frame instead?
BR, Daniel
Hi @maximillion,
The RTD team has found some limitations that do not allow the TXMSK CONT function in the LPSPI driver. They will update the UM with a note mentioning that.
Regards,
Daniel
Hi @maximillion,
Unfortunately, I have been informed that there is not going to be any patch.
It will be just listed as a limitation in the User Manual.
I'm not sure what the reasons are.
Regards,
Daniel
"Functions implemented in SDK for LPSPI (RTM 3.0.0 S32 Design Studio 2.2) do not have "native support" for 3-wire. So can we implement 3-wire SPI in continuous mode by making necessary changes at the driver level for RTM3.0.0?
Hi @maximillion,
I don't think the SDK can be easily modified.
These are SW limitations, it should work in HW, there are these errata though:
ERR011097
ERR011089
https://www.nxp.com/docs/en/errata/S32K148_0N20V.pdf
To receive 4 8byte frames in half-duplex continous mode, you need these commands:
while(LPSPI1->FSR & LPSPI_FSR_TXCOUNT_MASK){}
LPSPI1->TCR = LPSPI_TCR_CPHA_MASK
|LPSPI_TCR_TXMSK_MASK
|LPSPI_TCR_CONT_MASK
|LPSPI_TCR_PRESCALE(2)
|LPSPI_TCR_PCS(0)
|LPSPI_TCR_FRAMESZ(7);
while(LPSPI1->FSR & LPSPI_FSR_TXCOUNT_MASK){}
LPSPI1->TCR = LPSPI_TCR_CPHA_MASK
|LPSPI_TCR_TXMSK_MASK
|LPSPI_TCR_CONT_MASK
|LPSPI_TCR_CONTC_MASK
|LPSPI_TCR_PRESCALE(2)
|LPSPI_TCR_PCS(0)
|LPSPI_TCR_FRAMESZ(7);
while(LPSPI1->FSR & LPSPI_FSR_TXCOUNT_MASK){}
LPSPI1->TCR = LPSPI_TCR_CPHA_MASK
|LPSPI_TCR_TXMSK_MASK
|LPSPI_TCR_CONT_MASK
|LPSPI_TCR_CONTC_MASK
|LPSPI_TCR_PRESCALE(2)
|LPSPI_TCR_PCS(0)
|LPSPI_TCR_FRAMESZ(7);
while(LPSPI1->FSR & LPSPI_FSR_TXCOUNT_MASK){}
LPSPI1->TCR = LPSPI_TCR_CPHA_MASK
|LPSPI_TCR_TXMSK_MASK
|LPSPI_TCR_CONT_MASK
|LPSPI_TCR_CONTC_MASK
|LPSPI_TCR_PRESCALE(2)
|LPSPI_TCR_PCS(0)
|LPSPI_TCR_FRAMESZ(7);
/* terminate the transfer */
while(LPSPI1->FSR & LPSPI_FSR_TXCOUNT_MASK){}
LPSPI1->TCR = LPSPI_TCR_CPHA_MASK
|LPSPI_TCR_PRESCALE(2)
|LPSPI_TCR_PCS(0)
|LPSPI_TCR_FRAMESZ(7);
And you have to read the RX data in the meantime.
To transmit data, change TXMSK for RXMASK.
Regards,
Daniel
I opened a case because community support do not provide us the RTD update that supports the 3wire spi communication at continuous mode. You provided us some details how to the update the SDK to support that feature. But it will be a hard task to accomplish that since sdk is provided by RTD team. Even you think that updating the sdk based on that information will not be an easy task. That's why I opened this case. Can you please get in touch with RTD team once again if they can fix this issue in scheduled plan?
https://support.nxp.com/s/case/5002p00002vTPqsAAG/3-wire-spi-driver-with-continuous-mode
Hi @JosephJ,
I see the ticket, a colleague of mine is working on this.
As I already mentioned in this thread, there is an option to send one frame of 80bits, instead of 10 8bit frames. That means that you can use the RTD without the continous mode.
Or you could send 10 8bit frames and use GPIO as the CS, again with the continuous mode disabled.
Regards,
Daniel
I will keep the discussion on the opened case for not duplicating the thread. I guess you can also see the ticket.
Actually my question is, how can I read the register from the slave.
I am sending data as master and how can I receive data from slave. What function should I use to get the data as master from slave