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

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

robert_o
Posts: 48
Joined: Fri Feb 17, 2017 11:25 pm
Has thanked: 1 time
Been thanked: 5 times

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

Postby robert_o » Sun Sep 18, 2022 7:39 pm

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
Attachments
Clock.png

robert_o
Posts: 48
Joined: Fri Feb 17, 2017 11:25 pm
Has thanked: 1 time
Been thanked: 5 times

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

Postby robert_o » Sun Sep 18, 2022 7:53 pm

Never mind.
I found a solution with:
M=25, N=192, P=2, Q=4 which gives 96MHz System Clock and no error.
cheers.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

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

Postby Giovanni » Sun Sep 18, 2022 7:56 pm

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

robert_o
Posts: 48
Joined: Fri Feb 17, 2017 11:25 pm
Has thanked: 1 time
Been thanked: 5 times

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

Postby robert_o » Sun Sep 18, 2022 8:09 pm

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?

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

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

Postby Giovanni » Sun Sep 18, 2022 8:23 pm

25MHz / 15 is not an integer value, the preprocessor uses integer math and gives 1666666, after multiplying by 144 the result is 239999904.

Giovanni

robert_o
Posts: 48
Joined: Fri Feb 17, 2017 11:25 pm
Has thanked: 1 time
Been thanked: 5 times

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

Postby robert_o » Sun Sep 18, 2022 8:28 pm

Thank you for the explanation.
-robert


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 17 guests