[SOLVED] error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
lucky62
Posts: 5
Joined: Sun Mar 15, 2020 5:06 pm

[SOLVED] error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Post by lucky62 »

Hello i am trying to set the bluepill clock and then check.
Here is the whole program (it is a skeleton for I2C-DMA transfer):

Code: Select all

#include "stm32f1xx.h"
#include "stm32f1xx_ll_bus.h"
#include "stm32f1xx_ll_gpio.h"
#include "stm32f1xx_ll_utils.h"
#include "stm32f1xx_ll_rcc.h"
#include "stm32f1xx_ll_system.h"

void setupClock(void) {
  // 72MHz from 8MHz HSE
  LL_UTILS_PLLInitTypeDef pll;
  pll.Prediv = LL_RCC_PREDIV_DIV_1; // 8MHz / 1 = 8MHz
  pll.PLLMul = LL_RCC_PLL_MUL_9;    // 8MHz * 9 = 72MHz
  LL_UTILS_ClkInitTypeDef clk;
  clk.AHBCLKDivider = LL_RCC_SYSCLK_DIV_1;
  clk.APB1CLKDivider = LL_RCC_APB1_DIV_2;
  clk.APB2CLKDivider = LL_RCC_APB2_DIV_1;
  // configure clock
  LL_PLL_ConfigSystemClock_HSE(8000000,LL_UTILS_HSEBYPASS_OFF,&pll,&clk);
  SystemCoreClockUpdate();
  Serial.print("SystemCoreClock: ");
  Serial.println(SystemCoreClock);
}

void setupDMA(void) {}
void setupI2C(void) {}

void setup() {
  Serial.begin(115200);
  setupClock();
  // spočítej a uož frekvence SYSCLK,AHB a APB do struktury "clocks"
  LL_RCC_ClocksTypeDef clocks; // <-- !!! this line is causing error
  LL_RCC_GetSystemClocksFreq(&clocks); // <-- !!! this line too
  setupI2C();
  setupDMA();
}

void loop() {
  Serial.print(".");
  delay( 1000 );
}
When I am trying to compile it then I got the error - 'LL_RCC_ClocksTypeDef' was not declared in this scope at this line:
LL_RCC_ClocksTypeDef clocks;
When this line (and next one) is commented out then program is compiled successfully.

Most of LL_RCC_* functions/constants are defined in file stm32f1xx_ll_rcc.h - including others, which are used without problems.

Just I observed that LL_RCC_ClocksTypeDef is compiled conditionally by:
#if defined(USE_FULL_LL_DRIVER)
What is purpose of variable USE_FULL_LL_DRIVER and where/when it should be defined?
Last edited by lucky62 on Tue Mar 17, 2020 7:01 am, edited 1 time in total.
User avatar
fpiSTM
Posts: 1770
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 92
Location: Le Mans
Contact:

Re: error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Post by fpiSTM »

Define it before the include
lucky62
Posts: 5
Joined: Sun Mar 15, 2020 5:06 pm

Re: error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Post by lucky62 »

I tried this already, but problem was not solved.
Compilator was ok, but linker failed with error:
undefined reference to `LL_RCC_GetSystemClocksFreq'
BTW - what is the meanings of USE_FULL_LL_DRIVER config?
User avatar
fpiSTM
Posts: 1770
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 92
Location: Le Mans
Contact:

Re: error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Post by fpiSTM »

Add a file named hal_conf_extra.h with the #define USE_FULL_LL_DRIVER
Or a build_opt.h file with -DUSE_FULL_LL_DRIVER
About the switch:
https://www.google.com/url?sa=t&source= ... 9L88TasRoS
The definition of these LL initialization functions and associated resources (structure, literals and prototypes) is
conditioned by a compilation switch: USE_FULL_LL_DRIVER. To use these functions, this switch must be added
in the toolchain compiler preprocessor or to any generic header file which is processed before the LL drivers
lucky62
Posts: 5
Joined: Sun Mar 15, 2020 5:06 pm

Re: error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Post by lucky62 »

I added the half_conf_extra.h file with the #define USE_FULL_LL_DRIVER to the project, but result is the same as with this define in main sketch.

compilation is fine but linker failed:
SineWaveGenerator2.ino.cpp:(.text.setup+0x12): undefined reference to `LL_RCC_GetSystemClocksFreq'
collect2: error: ld returned 1 exit status
Using library SrcWrapper at version 1.0.1 in folder: /arduino/portable/packages/STM32/hardware/stm32/1.8.0/libraries/SrcWrapper
exit status 1
Error compiling for board Generic STM32F1 series.
Verbose build.log attached.
Attachments
build.zip
build.log
(15.63 KiB) Downloaded 254 times
lucky62
Posts: 5
Joined: Sun Mar 15, 2020 5:06 pm

Re: error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Post by lucky62 »

Solution was found here.
Thank! Indeed the file "build_opt.h" in the sketch directory with a string "-DUSE_FULL_LL_DRIVER" completely solved the problem.
User avatar
fpiSTM
Posts: 1770
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 92
Location: Le Mans
Contact:

Re: [SOLVED] error: 'LL_RCC_ClocksTypeDef' was not declared in this scope

Post by fpiSTM »

I've also added this solution in my previous post 🙄
Post Reply

Return to “General discussion”