Hi,
I'm Using LPSPI_s32k144 Example SPI Code, For Sending Data over the SPI the Below API is used in the code at-->LPSPI1_transmit_16bits(tx_16bits);/* Transmit half word (16 bits) on LPSPI1 */
Issue: What ever the Data/Value sending over the Above API or above Code(Ex Tx Data 0x08), Half of the Data only received on the Slave End(Ex Rx Data 0x04).
Ex:
tx_16bits = 0x08;
LPSPI1_transmit_16bits(tx_16bits);
Received value at the Slave side: 0x04
Similarly Tx Data-FFD0
Rx Data-7E80
Please give the Clarification on this issue, Why i'm getting this half of the Data/Value?
Hi Dilip1441,
How did you configure the CPHA and CPOL of slave device? Here you can refer to the signal captured by external logic analyze.
Best Regards,
Robin
-------------------------------------------------------------------------------
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.
-------------------------------------------------------------------------------
Oh. Sorry. I don't know how the use Arduino uno. Would you please check the setting of Clock polarity and phase of your slave are same as S32K144?
May I ask if you have other slaves, such as a logic analyzer, to check the data sent by the S32K and upload pictures.
In addition, please try to use a logic analyzer to communicate with your slave Arduino uno to see if the data is sent and received normally.
Hi, Now i'm using lspi_transfer_s32k144(SDK) Example Code, Using that code i'm trying to communicate LTC6813(ADC Board), Before Data Writing to the ADC Over the SPI, I need to Wakeup the ADC by CS Pin after that need to Write the Data.
But Unable to control the CS Pin Separately, Please check the below code, and PFA For the Required Wakeup Signal From Master-S32K144(Attached Screen shot signals are generated from Arduino Uno)
PINS_DRV_SetPinsDirection(PTB,(1 << 5));
PINS_DRV_SetPins(PTB,(1 << 5));
OSIF_TimeDelay(500);
PINS_DRV_ClearPins(PTB,(1 << 5));
OSIF_TimeDelay(500);
while(1)
{
LPSPI_DRV_MasterTransferBlocking(LPSPICOM1, tx, rx, 2, SPI_TIMEOUT);
OSIF_TimeDelay(5000);
}
Question:
How to control the CS Pin Manually/General Purpose Output as well as CS Pin in SPI
Please guide me and do the Needful.
Thanks in Advance.
I'm Attaching the Screenshot
When you configure PTB5 as LPSPI0_PCS0, ALT4 is selected for the MUX. If you want to use it as GPIO output, you may need to change the MUX to ALT1(PTB5). When you want to use it as CS pin, then you need to change MUX back to ALT4 again.
Please have a try. Hope it helps.
One more Query,
After Sending the Complete data over the SPI Only the CS Pin State need to change like below attached Format.
but in our example code if i'm sending 2 bytes of data using below code
uint8_t tx[2] = {0x25, 0x30};
LPSPI_DRV_MasterTransferBlocking(LPSPICOM1, tx, rx, 2, SPI_TIMEOUT);
The CS Pin state is changing(one time low to high) after sending every 1 byte
but i want after completion of complete data sending only the CS Pin State need to change
Did you enabled PCS continuous?
According to your previous description, you should choose Continuous mode:
Have you tried the PINS_DRV_SetMuxModeSel mentioned in my last reply?
PINS_DRV_SetMuxModeSel(PTB,5U,PORT_MUX_AS_GPIO);
PINS_DRV_SetPinsDirection(PTB,(1 << 5));
PINS_DRV_SetPins(PTB,(1 << 5));
OSIF_TimeDelay(500);
PINS_DRV_ClearPins(PTB,(1 << 5));
OSIF_TimeDelay(500);
PINS_DRV_SetMuxModeSel(PTB,5U,PORT_MUX_ALT4);
Hi,
Thanks for the Reply.
Added below code in my project and enabled PCS Continuous.
PINS_DRV_SetMuxModeSel(PTB,5U,PORT_MUX_AS_GPIO);
PINS_DRV_SetPinsDirection(PTB,(1 << 5));
PINS_DRV_SetPins(PTB,(1 << 5));
OSIF_TimeDelay(500);
PINS_DRV_ClearPins(PTB,(1 << 5));
OSIF_TimeDelay(500);
PINS_DRV_SetMuxModeSel(PTB,5U,PORT_MUX_ALT4);
while(1)
{
LPSPI_DRV_MasterTransferBlocking(LPSPICOM1, tx, rx, 2, SPI_TIMEOUT);
OSIF_TimeDelay(5000);
}
PFA For the Captured Wave Forms.
1.PCS Continuous is Working fine.
2.PTB-5 is not Working as we expected as per above code
Can you please guide me the Required Steps for this Requirement.
Thanks in Advance.
Sorry. PINS_DRV_SetMuxModeSel should use PORT_Type
Please have a try:
PINS_DRV_SetMuxModeSel(PORTB,5U,PORT_MUX_AS_GPIO);
PINS_DRV_SetPinsDirection(PTB,(1 << 5));
PINS_DRV_SetPins(PTB,(1 << 5));
OSIF_TimeDelay(500);
PINS_DRV_ClearPins(PTB,(1 << 5));
OSIF_TimeDelay(500);
PINS_DRV_SetMuxModeSel(PORTB,5U,PORT_MUX_ALT4);
I did not debug it, so not sure whether your code works.
About the PINS_DRV_SetMuxModeSel, please check if the MUX value of PORTB_PCR[5] is change during debug.
Hi Ronin,
I am facing the same issues now.
could you please let me know if you have solution for it.
my problem is that the CS seems not working at all with the lpspi_drv_mastertransferblocking function.
Kind regards
saman.poushpas@gmail.com
Hi,
Thanks for the Reply.
Modified the Code as per your Guidance thanks for your support.
PTB-5 is working fine as we expected(GPIO and CS).
But one unknown observation is there before expected Result may be that is due to Pin Mode Changings.
Can you please check the attached Screenshots once and please guide me to overcome that unknown state changes.
Before attaching our code also(Using Direct Example code without any changes) also i observed that state change in SCK pin.