AnsweredAssumed Answered

There is a question about the dual motor S32 project form NXP

Question asked by Eden Li on Jul 2, 2017
Latest reply on Jul 3, 2017 by dumitru-daniel.popa

Hi Guys,

I read the C-code about the dual motor demo board ,there is a question shown as below:

The C-code from the Project as below:

/*
* Declaration macro keeps all necessary settings for single/dual
* motor control application under one command.
*/
#define DECLARATION(param, uni3_param, pospe_param, cb_param, enc_avaliable, res_avaliable)  static pmsmDrive_t  param = { CFOC_DEFAULT,\
uni3_param##_CFG_DEFAULT,\
pospe_param##_CFG_DEFAULT,\
enc_avaliable,\
res_avaliable,\
MPC5643L_BGA257_##cb_param##_DEFAULT,\
CNTR_STATE_DEFAULT,\
SCALAR_CNTR_STATE_DEFAULT};

 

My analysis and question:

AS i use the 'define' before,

#define A  5  --- equal to A=5; According to the similar to analyze it that DECLARATION = param,but it  seems not right,The reason is that the parameters order of DECLARATION is (1)param, (2)uni3_param, (3)pospe_param, (4)cb_param, (5)enc_avaliable, (6)res_avaliable ,but the assignment is (1)CFOC_DEFAULT (2)uni3_param##_CFG_DEFAULT (3)pospe_param##_CFG_DEFAULT,\(4) enc_avaliable,\(5) res_avaliable,\ (6)MPC5643L_BGA257_##cb_param##_DEFAULT,\(7)CNTR_STATE_DEFAULT,\

(8)SCALAR_CNTR_STATE_DEFAULT};

 

1# The order and the numbers is the same, Why adding the CNTR_STATE_DEFAULT and SCALAR_CNTR_STATE_DEFAULT?

 

2# How to comprehend the uni3_param##_CFG_DEFAULT?

 

3#Assign the order of the Value is rignt?

 

Outcomes