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.
Please let me know why this issue seems to be.
Best Regards,
Abhishek
Solved! Go to Solution.
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.
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.
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?
Hello lijiantaowy@163.com,
I have already sent you a response here https://community.nxp.com/thread/513041 .
Hope this helps,
Marius
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.