SPI TRANSFER S32K

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI TRANSFER S32K

2,478 Views
hajianik
Senior Contributor I

Hi,

I took the example project "lpspi_transfer_s32k148" and made some modification to it:

What remain is clock and the pin and spi0 initialization.

Also I changed the size input of the  MasterTransferBlocking from 1 to 5 and the PE is configured for 40bits  for transfer size.

what happen is only the 1 byte of the 5 byte transmit buffer is transferred and the bus after transmitting this byte is pulled high for remaining of the cycle. 

in contrast to this I tried transmitting 5 bytes by using the function 5 times and passing 1 for the size and it works OK.

Could someone explain this contrast between transferring 5 bytes (40 bits clock cycle) and one byte at a time using 5 (8bits clock)?

LPSPI_DRV_MasterTransferBlocking(SEND, &masterDataSend, &masterDataReceive,5, 0);
// LPSPI_DRV_MasterTransferBlocking(SEND, &masterDataSend[1], &masterDataReceive,1, TIMEOUT);
//LPSPI_DRV_MasterTransferBlocking(SEND, &masterDataSend[2], &masterDataReceive,1, TIMEOUT);
//LPSPI_DRV_MasterTransferBlocking(SEND, &masterDataSend[3], &masterDataReceive,1, TIMEOUT);
//LPSPI_DRV_MasterTransferBlocking(SEND, &masterDataSend[4], &masterDataReceive,1, TIMEOUT);
//FTM_DRV_UpdatePwmChannel(INST_FLEXTIMER_PWM1, 1U, FTM_PWM_UPDATE_IN_DUTY_CYCLE, masterDataReceive<<8, 0U, true);

Thanks,

Koorosh

0 Kudos
Reply
4 Replies

2,466 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

using 40 bit/frame setting with below code

uint8_t masterDataSend[8]={1,2,3,4,5,6,7,8};
uint8_t masterDataReceive[8];

while(1)
{
     LPSPI_DRV_MasterTransferBlocking(SEND, &masterDataSend, &masterDataReceive, 8, TIMEOUT);
}

I got 

PetrS_0-1631261993049.png

Please refer to suggestion for transferByteCount and buffer in driver description 
C:/NXP/S32DS_ARM_v2.2/S32DS/software/S32SDK_S32K1xx_RTM_3.0.0/doc/html_S32K148/group__lpspi.html

Or with 8 bit/frame setting and PCS continuous you can have 

while(1)
{
     LPSPI_DRV_MasterTransferBlocking(SEND, &masterDataSend, &masterDataReceive, 5, TIMEOUT);
}

PetrS_1-1631263358190.png

 

BR, Petr

0 Kudos
Reply

2,460 Views
hajianik
Senior Contributor I

Hi Petr,

Thanks for your response.

Either of two solution does not work on my board(S32K148 EVAL).

I tried many mutations , It does not work, only one byte gets transferred.

It is a simple project which is attached.

Please see if you could run it correctly on your set up.

BR,

Koorosh

 

0 Kudos
Reply

2,443 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

seems your project uses some early SDK version (EAR_0.8.6). Please update to the latest one, RTM4.0.x in S32DS 3.4, or RTM 3.0.3 in S32DS 2.2.
I used demo example from S32DS 2.2 RTM 3.0.3 and see no issue there.

BR, Petr

0 Kudos
Reply

2,429 Views
hajianik
Senior Contributor I

Hi Petr,

Thanks for your response,

The version I was working on, had a few issues like:

I need to change the local definition of the RX/TX buffers to global.

It seems to transmit array in reverse order like Byte 5 goes out 1st and byte 4 goes out next and .... .

Other than those, it seems to be working fine.

 

BR,

kOOROSH 

0 Kudos
Reply