DSPI interface issu while sending union buffer

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

DSPI interface issu while sending union buffer

858 Views
InHome
Contributor III

Hi All,

I am using a code example from the Power PC library to develop my DSPI application.

I have an issue with the data transferred on the SPI bus.

I ma using a SPI inspector to visualize the the data sent on the SPI bus. I remark that I am only sending the first value of the buffer (master_send[0]) even if I loop trough the whole buffer?

for (count1 = 0; count1 < 2; count1++)
{
Pointer = (uint16_t *)&master_send[count1].XS_Spd_In_Data[0];
Dspi_status = DSPI_MasterTransfer(INST_DSPI1, Pointer, &master_receive[0], NUMBER_OF_FRAMES);

}

Do you have any idea about the source of this problem? Thank you in advance.

Capture d’écran 2021-07-05 222610.png 

 

/*
* Copyright 2017 NXP
* All rights reserved.
*
* THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/* ###################################################################
** Filename : main.c
** Project : pit_periodic_interrupt_mpc5748g
** Processor : MPC5748G_324
** Version : Driver 01.00
** Compiler : GNU C Compiler
** Date/Time : 2017-03-15, 12:21, # CodeGen: 6
** Abstract :
** Main module.
** This module contains user's application code.
** Settings :
** Contents :
** No public methods
**
** ###################################################################*/
/*!
** @file main.c
** @version 01.00
** @brief
** Main module.
** This module contains user's application code.
*/
/*!
** @addtogroup main_module main module documentation
** @{
*/
/* MODULE main */
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "pit1.h"
#include "clockMan1.h"
#include "pin_mux.h"
#include "dspi1.h"
#include "MC20XS4200_Drv.h"
volatile int exit_code = 0;

typedef union
{
uint16_t XS_Spd_In_Data[7];
struct
{
TstIO_eSPD_STATR_In_Bits XS_StartIn; //Start register
TstIO_eSPD_PWMR_In_Bits XS_PwmIn; //pwm register
TstIO_eSPD_CONFR_In_Bits XS_ConfIn; //configuration register
TstIO_eSPD_OCR_In_Bits XS_OcrIn; //ocr register
TstIO_eSPD_RETRYR_In_Bits XS_RetrayIn;//Retry register
TstIO_eSPD_GCR_In_Bits XS_GcrIn; //GCR register
uint16_t XS_CalbIn; //Calibration register
};
} XS_SpdInRegsData;

 

#define BUFFER_SIZE 7U
#define NUMBER_OF_FRAMES 7U
#define TIMEOUT 1000U
/* User includes (#include below this line is not maintained by Processor Expert) */
/* This example is setup to work by default with DEVKIT. To use it with other boards
please comment the following line
*/

/* Write your local variable definition here */

XS_SpdInRegsData master_send[2]={0};
uint16_t master_send_cache[7 * 2];
status_t Dspi_status;
dspi_transfer_status_t DSp_Busy;
//uint8_t master_receive[BUFFER_SIZE];
uint16_t count;
uint8_t master_receive[BUFFER_SIZE];
uint8_t slave_send[] = { 1, 2, 3, 4, 5, 6, 7 };
uint8_t slave_receive[BUFFER_SIZE];
uint16_t count1 = 0;
uint16_t count2;
static uint16_t DutyCycle = 0;
uint16_t *Pointer = NULL;
#define DEVKIT
#ifdef DEVKIT
#define PORT PTA
#define LED 10 /* pin PA[10] - LED3 (DS4) on DEV-KIT */
#else
#define PORT PTG
#define LED 2 /* pin PG[2] - LED1 (DS2) on Motherboard */
#endif
void PIT_Ch0_IRQHandler(void)
{
PINS_DRV_TogglePins(PORT, (1 << LED));
PIT_DRV_ClearStatusFlags(INST_PIT1, pit1_ChnConfig0.hwChannel); /* Clear channel 0 interrupt flag */

/* update the the period */
(void) des_MC20XS4200_PwmUpdate(&master_send[0], DutyCycle);

for (count1 = 0; count1 < 2; count1++)
{
Pointer = (uint16_t *)&master_send[count1].XS_Spd_In_Data[0];
Dspi_status = DSPI_MasterTransfer(INST_DSPI1, Pointer, &master_receive[0], NUMBER_OF_FRAMES);

}

}
/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - startup asm routine
* - main()
*/
int main(void)
{
/*** 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. ***/
/* Initialize clock gate*/
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

/* Initialize and configure pins */
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

/*
*
* Init the DSPI peripheral*/
/* SPI master configuration: clock speed: 500 kHz, 8 bits/frame, MSB first */
DSPI_MasterInit(DSPI0_INSTANCE, &dspi1State, &dspi1_MasterInitConfig0);

/* Configure delay between transfer, delay between SCK and PCS and delay between PCS and SCK */
DSPI_MasterSetDelay(DSPI0_INSTANCE, 1, 1, 1);

/*
*
* Init the PIT peripheral*/
/* Initialize PIT */
PIT_DRV_Init(INST_PIT1, &pit1_InitConfig);

/* Initialize channel 0 */
PIT_DRV_InitChannel(INST_PIT1, &pit1_ChnConfig0);

/* Start channel 0 counting */
PIT_DRV_StartChannel(INST_PIT1, pit1_ChnConfig0.hwChannel);

/* Init */
DutyCycle = 0;
/*
*
* Init the uart peripheral*/

/* Initialize the master send buffer */
(void) des_MC20XS4200_Config(&master_send[0]);

/* Send CAFE to test SPI communication */
for (count1 = 0; count1 < 2; count1++)
{
Pointer = (uint16_t *)&master_send[count1].XS_Spd_In_Data[0];
Dspi_status = DSPI_MasterTransfer(INST_DSPI1,Pointer, &master_receive[0],NUMBER_OF_FRAMES);


}

/*** 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!!! ***/
/* END main */
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.1 [05.21]
** for the NXP C55 series of microcontrollers.
**
** ###################################################################
*/

 

0 Kudos
Reply
0 Replies