2019-03-28 12:29 AM
I'm using SPI Communication in STM32L476JGYx.
But the code processing time takes too long.
[Sensor_IO_SPI_Read] function takes 2 micro sec.
After that, I calculated the received raw data.
But, it took more 30 micro sec. (32 micro sec)
Below, the calculating code is here.
ctx->pDataRX->Axis_x = (float)((-1.0f) * raw_data_tmp.i16bit[0] * ctx->sensitivity * M_PI / 180.0f);
ctx->pDataRX->Axis_y = (float) ((-1.0f) * raw_data_tmp.i16bit[1] * ctx->sensitivity * M_PI / 180.0f);
ctx->pDataRX->Axis_z = (float) ((-1.0f) * raw_data_tmp.i16bit[2] * ctx->sensitivity * M_PI / 180.0f);
What happened in my code.....?
Below, I attach my clock configuration.
2019-03-28 11:23 PM
Not really, it more of a compiler problem or how the variable is being declared. Good compilers try to group of calculations which can become a constant like you did. Some other compiler need help (apparently here).
2019-03-29 12:09 AM
> Is it because I use L4???
I think not. The L4 has an FPU too, but lower maximal core clock frequency, because this core is optimized for minimal consumption, not performance.
The rest is probably a project/compiler settings issue.
Decent optimizing compilers would have catched your constant expressions/calculations, and replaced them out in higher optimization levels.
Without optimization, compilers use to do exactly as you say.
2019-03-29 12:40 AM
Which compiler do you use and which compile optimization setting?