problem with lpspi_transfer_s32k148

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

problem with lpspi_transfer_s32k148

522 Views
RishikeshB
Contributor II

Hello NXP 

I am trying  the demo lpspi_transfer_s32k148 example in this can you tell me what data are we sending exactly and how can i change the  data that is being getting transferred it would be great if you show me in the snippet where and how we can modify the data

awaiting for your reply?  

0 Kudos
3 Replies

503 Views
RishikeshB
Contributor II

The screenshot you sent is of different example

I am using this 

 

 

/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "clockMan1.h"
#include "pin_mux.h"
#include "Send.h"
#include "Receive.h"
#include "adConv1.h"
#include "dmaController1.h"
#include "flexTimer_pwm1.h"
#if CPU_INIT_CONFIG
#include "Init_Config.h"
#endif
#define BUFFER_SIZE 1U
#define TIMEOUT 10U
volatile int exit_code = 0;
/* User includes (#include below this line is not maintained by Processor Expert) */

#include <stdint.h>
#include <stdbool.h>

/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - __start (startup asm routine)
* - __init_hardware()
* - main()
* - PE_low_level_init()
* - Common_Init()
* - Peripherals_Init()
*/
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
/*** End of Processor Expert internal initialization. ***/

ftm_state_t ftmStateStruct;
uint8_t masterDataSend;
uint8_t masterDataReceive;
lpspi_state_t masterState;
// uint8_t slaveDataReceive;
uint16_t adcRead;
uint8_t slaveDataSend;
// lpspi_state_t slaveState;
/* Initialize and configure clocks
* - see clock manager component for details
*/
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

/* Initialize pins
* - See PinSettings component for more info
*/

/* Example Description
* Potentiometer voltage is read using ADC0- channel 0. The value is send to
* LPSPI1 from LPSPI0. The read value represent duty for PWM (FTM0-channel 0).
* SPI wiring:
* B0-D3
* B2-D0
* E1-D2
* B4-D1
*/
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
/* Initialize LPSPI0 (Send)*/
LPSPI_DRV_MasterInit(SEND, &masterState, &Send_MasterConfig0);
/* Initialize LPSPI1 (Receive)*/
// LPSPI_DRV_SlaveInit(RECEIVE, &slaveState, &Receive_SlaveConfig0);
/* Initialize ADC */
ADC_DRV_ConfigConverter(INST_ADCONV1, &adConv1_ConvConfig0);
/* Initialize FTM */
FTM_DRV_Init(INST_FLEXTIMER_PWM1, &flexTimer_pwm1_InitConfig, &ftmStateStruct);
FTM_DRV_InitPwm(INST_FLEXTIMER_PWM1, &flexTimer_pwm1_PwmConfig);

while(1)
{
ADC_DRV_ConfigChan(INST_ADCONV1, 0U, &adConv1_ChnConfig0);
ADC_DRV_WaitConvDone(INST_ADCONV1);
/* Store the channel result into a local variable slaveDataSend*/
ADC_DRV_GetChanResult(INST_ADCONV1, 0U, &adcRead);

LPSPI_DRV_MasterTransferBlocking(SEND, &masterDataSend, &masterDataReceive, BUFFER_SIZE, TIMEOUT);


}
/* Write your code here */
/* 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!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

 

0 Kudos

489 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Oh Sorry. You submitted several similar questions and I confused the project.

Please read the Application description of LPSPI Transfer RTM3.0.3 lpspi_transfer_s32k148:
The application uses two on board instances of LPSPI, one in master configuration and the other one is slave to communicate data via the SPI bus. Data will be gathered periodically from the ADC input and will be sent to the master device which transforms it into a PWM signal.

LPSPI Transfer RTM3.0.3 lpspi_transfer_s32k148.png

LPSPI_DRV_SlaveTransfer LPSPI_DRV_MasterTransferBlocking.png

Best Regards,
Robin

0 Kudos

511 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi RishikeshB,
Please read the chapter "2.8 SPI" of AN5413:

AN5413.png


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.
-------------------------------------------------------------------------------

0 Kudos