cancel
Showing results for 
Search instead for 
Did you mean: 

RCC_GetClocksFreq incorrect values with 14.7456MHz HSE?

error401
Associate II
Posted on April 01, 2011 at 03:04

RCC_GetClocksFreq incorrect values with 14.7456MHz HSE?

6 REPLIES 6
Posted on May 17, 2011 at 14:30

Which part, and settings are you using the would provide for a 71.8848MHz clock from a 14.7456MHz input clock?

I could see 73.2380 or 66.3552 MHz
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
error401
Associate II
Posted on May 17, 2011 at 14:30

Oops I should have mentioned the part. It is an STM32F105R8.

The settings are (I think...) straight from the datasheet (table 61, pg 90).

PREDIV2 = 4

PLL2MUL = 12

PREDIV4

PLLMUL = 6.5

So if my math is right:

  (14.7456 / 4) * 12 = 44.2368

  (44.2368 / 4) * 6.5 = 71.8848

Posted on May 17, 2011 at 14:30

Ok, it looks to be using more conventional PLL settings, rather than CL series ones.

I'll assume you have STM32F10X_CL defined in your project.

May be this thread is related, I might take a look at generating a shell project with the parameters you describe and see what it creates with the library. There are bugs/quirks in a lot of this stuff, and sometimes you have to dig around a bit in the code/documentation to get it right.

https://my.st.com/public/STe2ecommunities/mcu/Lists/ARM%20CortexM3%20STM32/Flat.aspx?RootFolder=https%3a%2f%2fmy.st.com%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fARM%20CortexM3%20STM32%2fClock%20setup%20problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000626BE2B829C32145B9EB5739142DC17E...

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
error401
Associate II
Posted on May 17, 2011 at 14:30

Yes, I do have STM32F10X_CL defined.

I took a look at the sourcecode for the function yesterday and noticed a bunch of #ifdefs and special treatment for CL devices, even specific things about the 6.5x multiplier, so I just assumed it was properly supported, but this looks to be the problem:

stm32f10x_rcc.c:970

pllmull = 13 / 2;

pllmull is an integer type, so this is truncating to 6.0, resulting in the low return values.

As a fix, I left-shifted all pllmull sets by 1 and removed the /2, then right shifted all the results. I get the correct results at my clock settings now (and the serial port works), though obviously not tested with any other settings. If you're using the 6.5x multiplier available on a CL device you'll need this (a) fix, but for all other settings and devices I think the default code should work fine.

A bug.
elgerta
Associate II
Posted on June 17, 2011 at 18:25

Hi,

it seems I have the problem like you, because today I've tried with clock settings for a 14,7456MHz crystal but USART and timers are not correct.

I'm working with STM32F105, and settings of /4 x12 and /4 x6.5.

Can you post your correction of the stm32f10x_rcc.c?

By the way for me it's not possible to read some older threads.

Regards

Achim

Posted on June 17, 2011 at 21:00

By the way for me it's not possible to read some older threads.

Here's a cite from the ''new'' Fantastic Forum

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Clock setup problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=364

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..