Keil Logo Arm Logo

STM32 undefined HAL symbol

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Mel W
Posted
19-Aug-2015 15:31 GMT
Toolset
None
New! STM32 undefined HAL symbol

Hi All,

I just started learning ARM and I got a STM32L0 Nucleo board with Keils uVision5 as the environment. I used STM32Cube to generate the start-up code and got a blinky example and a button external interrupt example working.

I'm trying to get a Timer Interrupt example working by following this tutorial:
https://lostwire.wordpress.com/2015/01/12/timer-interrupt-on-stm32f4-using-hal/

But I run into some definition problem, error as:

CubeProjectOne Configuration\CubeProjectOne Configuration.axf: Error: L6218E: Undefined symbol HAL_TIM_Base_Init (referred from main.o).
CubeProjectOne Configuration\CubeProjectOne Configuration.axf: Error: L6218E: Undefined symbol HAL_TIM_Base_Start_IT (referred from main.o).

I checked that HAL_TIM_Base_Init and HAL_TIM_Base_Start_IT are located in stm32l0xx_hal_tim.h line 1152, 1153 as:

HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim);
HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim);

But in stm32l0xx_hal_tim.h line 47 (47 #include "stm32l0xx_hal_def.h") there's a red cross and when I hover over it, it says "error in include chain stm32l0xx_hal_rcc_ex.h: unknown type name 'HAL_StatusTypeDef." that repeated for a whole bunch of different header files.

Then in file "stm32l0xx_hal_def.h", which is where HAL_StatusTypeDef is located, it has the same error "error in include chain stm32l0xx_hal_rcc_ex.h: unknown type name 'HAL_StatusTypeDef." at line 48 (48 #include "stm32l0xx.h").

I'm not sure if it's a linker problem, multiple definition or what, but I really can't figure out why.

Please see my main code as attached.

Thanks!


/* Includes ------------------------------------------------------------------*/
#include "stm32l0xx.h"
#include "stm32l0xx_hal.h"
#include "stm32l0xx_hal_tim.h"                // For TIM_HandleTypeDef


/* USER CODE BEGIN PV */
volatile uint32_t blink_period = 500;
TIM_HandleTypeDef TIM_Handle;

/* Set Up Timer --------------------------------------------------------------*/
void Timer_SetUp (void)
{
        // 1. Enable Timer
        __TIM2_CLK_ENABLE();

        // 2. set up to toggle at 500 ms
        TIM_Handle.Init.Prescaler = 15;
        TIM_Handle.Init.CounterMode = TIM_COUNTERMODE_UP;
        TIM_Handle.Init.Period = 62499;

        // 3. Specify HW timer to be used
        TIM_Handle.Instance = TIM2;

        // 4. Initialise and start interrupt
        HAL_TIM_Base_Init(&TIM_Handle);     // Init timer
        HAL_TIM_Base_Start_IT(&TIM_Handle); // start timer interrupts

        // 5. Unmask timer
        HAL_NVIC_SetPriority(TIM2_IRQn, 0, 1);
        HAL_NVIC_EnableIRQ(TIM2_IRQn);

}


/* Timer handler -------------------------------------------------------------*/
void TIM4_IRQHandler(void)
{
    __HAL_TIM_CLEAR_FLAG(&T2_Handle, TIM_FLAG_UPDATE);
    /*Some code here */

}

/** System Clock Configuration
*/
void SystemClock_Config(void)
{

  RCC_OscInitTypeDef RCC_OscInitStruct;
  RCC_ClkInitTypeDef RCC_ClkInitStruct;

  __PWR_CLK_ENABLE();

  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
  RCC_OscInitStruct.MSIState = RCC_MSI_ON;
  RCC_OscInitStruct.MSICalibrationValue = 0;
  RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_5;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  HAL_RCC_OscConfig(&RCC_OscInitStruct);

  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);

  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

}

Read-Only
Author
Westonsupermare Pier
Posted
19-Aug-2015 17:35 GMT
Toolset
None
New! RE: STM32 undefined HAL symbol

Probably want to look more closely at how ST creates projects and uses stm32l0xx_hal_conf.h to manage the files being included, instead of the manual method you're using.

That you have USE_HAL_DRIVER define in the compiler's command line, and
#define HAL_TIM_MODULE_ENABLED in your stm32l0xx_hal_conf.h file

Read-Only
Author
Mel W
Posted
21-Aug-2015 08:02 GMT
Toolset
None
New! RE: STM32 undefined HAL symbol

Thanks for the reply, but I somehow managed to overwrite my entire project when I re-generated code from STM32Cube and everything got lost. The error was gone though, thanks.

Read-Only
Author
Mel W
Posted
25-Aug-2015 07:33 GMT
Toolset
None
New! RE: STM32 undefined HAL symbol

I run into the same problem when I'm trying to include the RTC module.
After fiddling around forever, this is what I did to solve the issue:

1. Add #define HAL_RTC_MODULE_ENABLED stm32l0xx_hal_conf.h
2. Add #define USE_HAL_DRIVER to stm32l0xx.h
3. Project -> Manage -> Project Items -> Application/User add my own rtc.c
4. Project -> Manage -> Project Items -> Drivers/STM32L0xx_HAL_Driver add stm32l0xx_hal_rtc.c and stm32l0xx_hal_rtc_ex.c

I didn't know you have to do step 3 and 4 manually, I thought the linker will automatically add it but guess I was wrong. Anyway, it finally works now. And it seems like Step 2 is just a precaution if you haven't included the _hal.h, not sure which is the better way though...

In the end, this is my include chain:
main.c includes main.h and rtc.h
main.h includes stm32l0xx.h (OR stm32l0xx_hal.h)
rtc.h includes stm32l0xx.h (OR stm32l0xx_hal.h)
stm32l0xx_hal.h includes stm32l0xx_hal_conf.h
stm32l0xx_hal_conf.h includes stm32l0xx_hal_rtc.h

And have the code to prevent recursive inclusion everywhere...

Thanks! :)

Read-Only
Author
Adrian Kurylak
Posted
8-Nov-2015 14:43 GMT
Toolset
None
New! RE: STM32 undefined HAL symbol

Hi,
I think that more proper way to do it is by adding to Your Run-Time environment HAL driver for TIM, rather than manually adding source files. In that case proper source files will be automatically added to Your project, and I recommend to do it with all of Yours components. You can do it by entering: Project -> Manage -> Run-Time Environment.

Read-Only
Author
Gabriel Galvao
Posted
13-Jul-2017 06:13 GMT
Toolset
ARM
New! RE: STM32 undefined HAL symbol

Probably want to look more closely at how ST creates projects and uses stm32l0xx_hal_conf.h to manage the files being included, instead of the manual method you're using.

That you have USE_HAL_DRIVER define in the compiler's command line, and
#define HAL_TIM_MODULE_ENABLED in your stm32l0xx_hal_conf.h file

Thank you very much for this answer! I had the same problem with a STM32F4, and could solve it by following these steps.

The command line "#define HAL_TIM_MODULE_ENABLED" of the stm32f4xx_hal_conf.h file was commented on my project. It was sufficient to decomment it, and the linking worked.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

ARM’s Privacy Policy has been updated. By continuing to use our site, you consent to ARM’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.