cancel
Showing results for 
Search instead for 
Did you mean: 

Is there an elegant way of using CubeMX to generate code for two very different configurations in the same program?

Remi Demers
Associate II

The program is alternating between two modes, one is high performance and the second is low power. For perfomance mode the ADC is used with a timer triggering and DMA+interrupt at fast rate. In the low power mode it is intended to make a single conversion triggered by software on a very slow pace. The clocking is also different. Now I am using custom code to switch peripheral configuration between the two modes. I Would like to use CubeMX for both, in the cleanest possible way. Any good experience to share? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
S.Ma
Principal

For dynamic HW peripheral configuration, better code directly in the project source file.

The CubeMX starting point maybe the most perceived complex of the configuration.

View solution in original post

6 REPLIES 6

Seems to exceed the scope of the tool.

Would really need a template, would see if any of the examples demonstrate multi-mode operation, but in most cases are overly simplistic and not real-world applications.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Remi Demers
Associate II

Thank for your answer. I was thinking about methods like having two MX projects, and making a copy-paste operation on one of the two projects to bring the second configuration in the main project and edit the files to change main() for a new function name that can be called. This may be automated with scripting. Just thinking loud.

S.Ma
Principal

For dynamic HW peripheral configuration, better code directly in the project source file.

The CubeMX starting point maybe the most perceived complex of the configuration.

ST: Your competitors' configuration tools explicitly provide for setting up multiple clock and power configurations so you can switch between them. This is important; lots of customers have this requirement (slow-lowpower <-> fast-highpower)!

Piranha
Chief II

"This may be automated with scripting."

Is it worth spending time on writing scripts to automate the automation (code generation)? That time can be spent on writing actual C code, which can also be much more configurable and modular than automatically generated buggy unstable and inflexible bloatware.

Remi Demers
Associate II

Thank you all for your answers! Until ST add this feature to the CubeMX, I will program the configuration changes directly. This is the simplest!