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: lostwire.wordpress.com/.../
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); }