2021-04-16 02:38 AM
Hi.
Faced the problem of prinyf () function execution speed.
Wrote a simple speed test
HAL_GPIO_TogglePin (GPIOE, GPIO_PIN_8);
uint8_t text [256] = {0};
for (uint32_t i = 0; i <256; i ++)
{
sprintf (text, "% - 5.2f", (i + 10.0 / 2.0));
}
HAL_GPIO_TogglePin (GPIOE, GPIO_PIN_8);
I measure with an oscilloscope the time between setting the 8th leg of port E to a logical unit and reset.
Time is obtained with 1.1 ms cache enabled and 4.4 ms with cache disabled.
I am using the stm32h743 microcontroller. Programming environment stm32cubeide.
Included printf in stm32cubeide as follows settings ---> MCU ---> Miscellaneous ---> -u_printf_float.
2021-04-16 11:13 AM
So your test shows that it runs faster with cache enabled. Anything new here?
--pa
2021-04-16 07:02 PM
I need a runtime to do 256 μS to execute the cache enabled code.
HAL_GPIO_TogglePin (GPIOE, GPIO_PIN_8);
uint8_t text [256] = {0};
for (uint32_t i = 0; i <256; i ++)
{
sprintf (text, "% - 5.2f", (i + 10.0 / 2.0));
}
HAL_GPIO_TogglePin (GPIOE, GPIO_PIN_8);
2021-04-17 01:47 AM
> I need
Then don't use the library printf(), write your own
JW
2021-04-17 04:45 AM
The printf() functions are for... guess it - printing! Printing means converting data to a human readable format. This rises a question of why do you need a 4+ kHz capable printf() at all. If that is for sending data, then drop that ineffective idea and send a binary data with some same format/protocol.
2021-04-17 02:16 PM
Fixed format, typically convert it to a scaled integer, and use a fast assembler routine to do the string conversion.