Skip to main content
BTrem.1
Senior
Jan 9, 2021 12:33 AM UTC
Solved

Relation between *.stmx file and drive_parameters.h ?

Often I find that MCSDK does not have the exact MCU I need to use so I need to end up modifying the CubeMx *.ico file generated from MCSDK.

In trying to determine the relationship of these files I took an existing working project and renamed the *.stmx file to *.stmx_____. I then loaded the *.ico file with CubeMx with no complaints. Next I deleted the drive_parameters.h file then had CubeMx generate new code. The result was a new drive_parameters.h file was generated.

Where does the information for this new drive_parameters.h file come from? There was no old drive_parmeters.h file and the *.stmx file was not present.

I ask this because sometimes when rebuilding my project I find all my drive_parameters.h values have changed and I need to copy the file over from an archived project.

Thanks for any insight you can give on this. A secret decoder ring would be appreciated from ST ;)

Brian

This topic has been closed for replies.
Dario CUCCHI
Dario CUCCHIBest answer
ST Employee
Jan 11, 2021 3:53 PM UTC

Hello Brian,

Once the CubeMX file .ioc is generated, it has in the middleware section a part called MotorControl, which contains all the information about the FOC algorithm, among which the "previous" drive_parameters.h file.

Modifying the CubeMX file can lead to some error, so I suggest to always generate the project starting from the Workbench (.stmcx file) .

Further modifications can be added directly to the code in the dedicated parts indicated between comments:

/* USER CODE BEGIN ... */

/* USER CODE END... */

Code inside these comments is kept when the project is generated again and not overwritten by the new code generation.

I hope this can help you in your project.

2 replies

Dario CUCCHI
Dario CUCCHIBest answer
ST Employee
Jan 11, 2021 3:53 PM UTC

Hello Brian,

Once the CubeMX file .ioc is generated, it has in the middleware section a part called MotorControl, which contains all the information about the FOC algorithm, among which the "previous" drive_parameters.h file.

Modifying the CubeMX file can lead to some error, so I suggest to always generate the project starting from the Workbench (.stmcx file) .

Further modifications can be added directly to the code in the dedicated parts indicated between comments:

/* USER CODE BEGIN ... */

/* USER CODE END... */

Code inside these comments is kept when the project is generated again and not overwritten by the new code generation.

I hope this can help you in your project.

Laurent Ca...
Senior III
Jun 1, 2021 8:45 AM UTC

The question has been moved from the "Motor Control Hardware" section to the "STM32 Motor Control" section (the question is about the STM32 SDK). 

Best regards

Laurent Ca...