s32k146 spi receive data

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

s32k146 spi receive data

1,981 Views
alisasong
Contributor I

Hi,

I'm using S32K SDK Lpspi drivers.

 and I use LPSPI_DRV_MasterTransferBlocking(LPSPICOM1,sendBuffer,receiveBuffer,5,1); to send buffer data from master, and how can I receive a  read buffer data  form the matser? any function? Is it still LPSPI_DRV_MasterTransferBlocking(LPSPICOM1,sendBuffer,receiveBuffer,5,1)?

look forward for replyiing.Thank you

Best regards

Labels (1)
Tags (1)
0 Kudos
6 Replies

1,205 Views
veerajuvh619
Contributor III

#include "Cpu.h"
#include <stdio.h>
#include "pin_mux.h"
#include "clockMan1.h"
#include "lpspiCom1.h"
#include "dmaController1.h"
void chipselect();
void chipdeselect();
volatile int exit_code = 0;
uint8_t rx_buffer[10];
uint8_t tx_buffer[10]={1,2,3};
void chipselect()
{
PINS_DRV_ClearPins(PTC_BASE, 14);
}
void chipdeselect()
{
PINS_DRV_SetPins(PTC_BASE, 14);
}

int main(void)
{
/* Write your local variable definition here */

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif

while(1)
{

CLOCK_SYS_Init(g_clockManConfigsArr,NUM_OF_PERIPHERAL_CLOCKS_0,g_clockManCallbacksArr,CLOCK_MANAGER_CALLBACK_CNT);

CLOCK_SYS_UpdateConfiguration(0,CLOCK_MANAGER_POLICY_AGREEMENT);

PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

LPSPI_DRV_MasterInit(LPSPICOM1, &lpspiCom1State, &lpspiCom1_MasterConfig0);

LPSPI_DRV_SlaveInit(LPSPICOM1, &lpspiCom1State, &lpspiCom1_SlaveConfig0);
chipselect();


// LPSPI_DRV_MasterTransfer(LPSPICOM1, tx_buffer, rx_buffer, 100U);
LPSPI_DRV_MasterTransferBlocking(LPSPICOM1, tx_buffer, rx_buffer, 100U, NULL);
// LPSPI_DRV_ReadRXBuffer(LPSPICOM1);
LPSPI_DRV_SlaveTransfer(LPSPICOM1, tx_buffer, rx_buffer, 100U);

// LPSPI_DRV_ReadRXBuffer(LPSPICOM1);
chipdeselect();

}


/* For example: for(;;) { } */

/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
}

I am not getting output for this program. suggest me the solution.

Regards,

veeraju

0 Kudos

1,205 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi veerajuvh619@gmail.com

This is not the code from our example. The main issue in your code is that you are trying to use the same instance for master and slave in the same time. This is impossible and the driver returns some error code, but the application doesn't check them.

Best regards,

Razvan

1,205 Views
veerajuvh619
Contributor III

HI Razvan-nicolae Tilimpea 

That is not working working in my system, I am using s32ds ARM 2018.R1.  

0 Kudos

1,205 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi,

After that call the data received by master from slave will be moved in receiveBuffer.

Best regards,

Razvan

1,205 Views
veerajuvh619
Contributor III

Sir please send code for this i am also facing same problem.

0 Kudos

1,205 Views
razva_tilimpea
NXP Employee
NXP Employee

Hi Veeraju Hallikeri,

Please check the example code delivered in SDK. For thi go to File->Project from example and select the LPSPI project for your CPU.

Best regards,

Razvan

0 Kudos