cancel
Showing results for 
Search instead for 
Did you mean: 

Code processing time takes too long. I'm using STM32L476JGYx.

Min-Kyoung Kim
Associate III

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.

0690X00000896WIQAY.jpg

12 REPLIES 12
S.Ma
Principal

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).

> 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.

S.Ma
Principal

Which compiler do you use and which compile optimization setting?