Page 1 of 1

How to get rid of error: selected ST frequency is not obtainable because integer rounding

Posted: Sun Sep 18, 2022 7:39 pm
by robert_o
I have a STM32F411CE (blackpill Board) with HSE=25MHz.
I selected M=15, N=144, P=4, Q=5, AHBP=1, APB1=2, APB2=1 which gives 60MHz System Clock and 48MHz USB Clock.
I've got the Error:

Code: Select all

chibios_trunk/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.c:322:2: error: #error "the selected ST frequency is not obtainable because integer rounding"

which comes from:

Code: Select all

#if ST_CLOCK_SRC % OSAL_ST_FREQUENCY != 0
#error "the selected ST frequency is not obtainable because integer rounding"
#endif

Chibios uses Timer 2 (32bit).
How can i fix this?

Thanks.
Robert

Re: How to get rid of error: selected ST frequency is not obtainable because integer rounding  Topic is solved

Posted: Sun Sep 18, 2022 7:53 pm
by robert_o
Never mind.
I found a solution with:
M=25, N=192, P=2, Q=4 which gives 96MHz System Clock and no error.
cheers.

Re: How to get rid of error: selected ST frequency is not obtainable because integer rounding

Posted: Sun Sep 18, 2022 7:56 pm
by Giovanni
Hi,

That assertion is about the system tick frequency defined in chconf.h, the frequency must be obtainable from the selected timer. Consider that the timer prescaler is 16 bits even on 32 bits timers.

Giovanni

Re: How to get rid of error: selected ST frequency is not obtainable because integer rounding

Posted: Sun Sep 18, 2022 8:09 pm
by robert_o
Thanks for the reply. I don't understand.
With 60Mhz Timer freq and 10kHz Systick the prescaler could be 6000?
Why is this not obtainable?

Re: How to get rid of error: selected ST frequency is not obtainable because integer rounding

Posted: Sun Sep 18, 2022 8:23 pm
by Giovanni
25MHz / 15 is not an integer value, the preprocessor uses integer math and gives 1666666, after multiplying by 144 the result is 239999904.

Giovanni

Re: How to get rid of error: selected ST frequency is not obtainable because integer rounding

Posted: Sun Sep 18, 2022 8:28 pm
by robert_o
Thank you for the explanation.
-robert