Error During Build (SPI Block) MBD for MPC5744P

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

Error During Build (SPI Block) MBD for MPC5744P

Jump to solution
1,771 Views
abhishek_kumar1
Contributor IV

Dear All

I experienced an error while building a model to Initialize FET Prediver (33937A). 

The build error seems to originate while using SPI Block. 

I have attached the error (MATLAB Diagnostic) in txt file as well as the model. 

pastedImage_1.png

Please let me know why this issue seems to be. 

Best Regards,

Abhishek

Tags (1)
1 Solution
1,535 Views
constantinrazva
NXP Employee
NXP Employee

Hello abhishek.kumar@chassisbrakes.com‌,

I've found the problem:

In MPC5744.h, at line 17064, there is the following define

#define SPI_0                                    ((SPI_Type *)SPI_0_BASE)

At the same time, in the model you've sent me, the name of the SPI Master transfer block is SPI_0. A variable generated to be used as input/output for that block is named SPI_0, as MATLAB codegen has no idea that it should not use that exact name; it just puts the name of the block there. So this is what is actually going on.

typedef struct {
   uint8_T SPI_0; /* '<S2>/SPI_0' */
} B_FET_predriver_MC34GD3000;

void FET_predriver_MC34GD3000(uint8_T rtu_MPC_SPI_Data,
B_FET_predriver_MC34GD3000 *localB)
{
   /* S-Function (spi_mpc574x_master_transfer): '<S2>/SPI_0' */
   {
      DSPI_UpdateCS(0, 0);
      DSPI_MasterTransfer(0, &rtu_MPC_SPI_Data,
      &localB->SPI_0, 1U);
   }
}

Took a while to find the culprit, but the fix is simple - just rename the SPI Master transfer block from SPI_0 to something else (e.g: SPI_zero or SPI_00).

Please let me know if you have further issues with it.

Kind regards,

Razvan.

View solution in original post

5 Replies
1,536 Views
constantinrazva
NXP Employee
NXP Employee

Hello abhishek.kumar@chassisbrakes.com‌,

I've found the problem:

In MPC5744.h, at line 17064, there is the following define

#define SPI_0                                    ((SPI_Type *)SPI_0_BASE)

At the same time, in the model you've sent me, the name of the SPI Master transfer block is SPI_0. A variable generated to be used as input/output for that block is named SPI_0, as MATLAB codegen has no idea that it should not use that exact name; it just puts the name of the block there. So this is what is actually going on.

typedef struct {
   uint8_T SPI_0; /* '<S2>/SPI_0' */
} B_FET_predriver_MC34GD3000;

void FET_predriver_MC34GD3000(uint8_T rtu_MPC_SPI_Data,
B_FET_predriver_MC34GD3000 *localB)
{
   /* S-Function (spi_mpc574x_master_transfer): '<S2>/SPI_0' */
   {
      DSPI_UpdateCS(0, 0);
      DSPI_MasterTransfer(0, &rtu_MPC_SPI_Data,
      &localB->SPI_0, 1U);
   }
}

Took a while to find the culprit, but the fix is simple - just rename the SPI Master transfer block from SPI_0 to something else (e.g: SPI_zero or SPI_00).

Please let me know if you have further issues with it.

Kind regards,

Razvan.

1,535 Views
abhishek_kumar1
Contributor IV

Dear constantinrazvan.chivu

Works like a charm.

Abhishek

0 Kudos
Reply
1,535 Views
lijiantaowy
Contributor III

Hello Abhishek Kumar,

When I use the MPC57XX MBD toolbox to configure SPI and communicate with power chip, the data structure required by the power chip is 16-bit, as shown in the figure below, but only the 8-bit data transmission can be configured in the toolbox. Is there any way to solve it?

pastedImage_2.png

pastedImage_3.png

0 Kudos
Reply
1,535 Views
mariuslucianand
NXP Employee
NXP Employee

Hello lijiantaowy@163.com‌,

I have already sent you a response here https://community.nxp.com/thread/513041 . 

Hope this helps,

Marius

0 Kudos
Reply
1,535 Views
constantinrazva
NXP Employee
NXP Employee

Hello abhishek.kumar@chassisbrakes.com‌,

There seems to be a problem with a define in the makefile. All problems begin here:

MPC5744P.h:17064:61: error: expected ')' before '*' token
#define SPI_0 ((SPI_Type *)SPI_0_BASE)

I will take a look and come back with a fix.

Kind regards,

Razvan.