2023-12-02 12:37 PM
Dear All,
I compile a program with cube ide and would like to know how the float variable is const float.
sample is.
float a
const float b
b = a;
BR,
Methee
Solved! Go to Solution.
2023-12-03 10:45 AM
And I can't edit or pull code from a screen shot/bitmap.
Make a structure you're configuration items live in.
Create routines to read, write and validate this structure you can place in FLASH or EEPROM
FOO foo = { 0 };
void InitFoo(FOO *foo, EEPROM *eeprom)
{
...
foo->donkeys = 12;
foo->freqHz = eeprom->freqHz;
foo->speedRPM = eeprom->speedRPM;
...
}
2023-12-02 01:37 PM
Const (constant) variables cannot be changed after they are initialized. This means you can and must initialize them only once.
It's a compiler flag more than anything that lets the compiler know that variable won't be changing and it can optimize things as if that variable will always be the same value.
2023-12-02 01:45 PM
Dear TDK,
You can help me for this solution?
float a =10;
const float b=a;
BR,
Methee
2023-12-02 01:52 PM
That code is valid and will compile just fine. What help is needed?
2023-12-02 01:55 PM
To what end?
const float b = 10.0f;
Or pass it to a function that has const float x as a parameter?
The optimizer should try to fold constant values, perhaps use define?
2023-12-03 02:15 AM
Dear Tesla DeLorean,
I need to read data from eeprom for change information in parameters of MotorControl Workbench 6.2.0 project.
But function parameters need to be const float or #define only.
Please help advise.
BR,
Methee
2023-12-03 06:47 AM
That is not a function, but a structure initialization. You need to learn the C programming language first before trying to deal with complex software development.
2023-12-03 08:10 AM
The compiler can't initialize the structure with a variable.
You should start with an empty structure, and write a subroutine to do the initial fill from your EEPROM, or whatever.
2023-12-03 09:40 AM
I can use it for Aruino ide but cube ide is very difficult to use. Can you make an inverter to sell if you are good at it? It didn't help me at all. It's better not to answer.
2023-12-03 09:41 AM
I'm just stuck here. Otherwise, I have no problem. Let's try to find another way. It doesn't seem to help me at all.