Read system clock in LL driver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-17 9:32 AM
Hi Everyone,
I'm working with LL driver and want to read the system clock. There is this function:
LL_RCC_GetSystemClockFreq(PCLK1_Frequency)
to get the frequencies but although I include stm32f1xx_ll_rcc.h, I receive this Error
'PCLK1_Frequency' undeclared (first use in this function) .
Could you please help me. It's making me crazy ;)
- Labels:
-
RCC
-
STM32Cube MCU Packages
-
STM32F1 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-17 10:24 AM
> LL_RCC_GetSystemClockFreq(PCLK1_Frequency)
Where this line come from? Was it generated by the Cube/CubeIDE?
-- pa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-17 10:29 AM
I'm using STM32CubeIDE however this is a standard function on LL driver found in HAL and LL driver description by ST.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-17 10:39 AM
STM32F1 does not have LL_RCC_GetSystemClockFreq. Rather, it has LL_RCC_GetSystemClocksFreq.
Here. It's parameter is a pointer to 4 frequencies.
-- pa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-17 10:43 AM
The RCC has no way to actually determine the frequency of the PCLK bus clocks if you are using the HSE oscillator. CSMIS historically uses a hard-coded HSE frequency to base calculations, with no guarantee it matches the crystal. Internal RC oscillator frequencies can be determined by RCC settings, though I'm not sure how well LL does this. If the base oscillator used for the PLL or HCLK system clock can be determined then all other clocks can be derived through RCC registers.
Check the LL source code to see what it expects for the call parameter. Your error implies the parameter isn't what you think it is. I don;t use LL so I'm not sure how well it parses the RCC setting to derive the clock tree. However, you can fined any bus frequency if you know the actual HSE crystal by directly reading the RCC registers.
Jack Peacock
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-17 9:59 PM
Yes you are right but still same problem with this
a = LL_RCC_GetSystemClocksFreq(PCLK1_Frequency);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-18 8:21 PM
Thank you guys,
Actually there was no success with this function:
LL_RCC_GetSystemClocksFreq(PCLK1_Frequency)
I don't know if it's a bug by LL or I'm using it wrong. Anyway, digging through it directed me to another function (I guess like Jack said it's a CMSIS function) and enabled me to read the clock and it was:
RCC_GetSystemClockFreq()
Which returns me the SYSCLK. Although it asks me to define it as a prototype first by a Warning and I don't know WHY (because it has been defined once in header) but I'm happy now :smiling_face_with_smiling_eyes: .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-19 1:03 PM
> although I include stm32f1xx_ll_rcc.h, I receive this Error
> I don't know if it's a bug by LL or I'm using it wrong.
In both cases you ha NOT included the respective header file.
https://www.tutorialspoint.com/cprogramming/c_header_files.htm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-20 10:41 AM
What do you mean by respective. I included "stm32f1xx_ll_rcc.h" which is the respective header file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-20 12:46 PM
https://dictionary.cambridge.org/dictionary/english/respective
Looked once more at this... OK, let's rewind it back. The compiler already tells you the problem - the PCLK1_Frequency is not defined. The LL_RCC_GetSystemClocksFreq() function takes a single parameter, which must be a pointer to specific structure. You have to provide that structure and pass the pointer to it into that function.
