cancel
Showing results for 
Search instead for 
Did you mean: 

Systick (system clk) and timers with different time base (HAL_TIM).

Posted on April 24, 2017 at 12:23

I was developing a project with one ms system clock. I chose systick as system clk source in the CubeL4 app. This app add this file to my project: stm32l4xx_hal_timebase_tim_template.c and added this piece of code to the clock configuration function:

void SystemClock_Config(void)

{

...

/**Configure the Systick interrupt time **/

HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

/**Configure the Systick **/

HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

/* SysTick_IRQn interrupt configuration */

HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

...

}

I'm working over HAL_xx libraries. I created and added some modules based on HAL drivers with different app funcionalites. After this, I wanted to add the possibility of counting periods of time and do some actions.

The simplest time counter is TIM6 or TIM7 in stm32L476 mcu being configured as time base enabling interruptions. 

As you know with these libs you must implement interruption handlers and callbacks. There is one callback linked with elapsed period interruption for timers. 

The problem I have is that this callback is matched with the callback used by systick interruption implemented in a hal library file. Compiler error msg:

pm03\pm03.axf: Error: L6200E: Symbol HAL_TIM_PeriodElapsedCallback multiply defined (by stm32l4xx_hal_timebase_tim_template.o and drv_timer.o).

You can find the following words in this file related to systick named before:

* This file override the native HAL time base functions (defined as weak)

* the TIM time base:

* + Intializes the TIM peripheral to generate a Period elapsed Event each 1ms

* + HAL_IncTick is called inside HAL_TIM_PeriodElapsedCallback ie each 1ms

==============================================================================

♯♯♯♯♯ How to use this driver ♯♯♯♯♯

==============================================================================

[..]

This file must be copied to the application folder and modified as follows:

(♯) Rename it to 'stm32l4xx_hal_timebase_tim.c'

(♯) Add this file and the TIM HAL driver files to your project and make sure

HAL_TIM_MODULE_ENABLED is defined in stm32l4xx_hal_conf.h

[..]

(@) The application needs to ensure that the time base is always set to 1 millisecond

to have correct HAL operation.

I know systick is generated from another timer: TIM6. But the fact is that I don't want to use TIM7 as a clock system. I only want to have a timer counting periods in order to activate other actions with a timing less than 1ms whereas system is running with its system clk.

Is not possible to use both features? -> a systick and one peripheral counting periods in the same App project.

I would like to attend tim7 ending period interruptions. But now I can't. Does it mean that only the interruptions of only one timer can be attended every time?

Thanks in advance.

#hal_tim_irqhandler #stm32f4-timer-tim7-interrupt #systick-config #hal_tim_periodelapsedcallback
0 REPLIES 0