Skip to content

HardwareTimer Timebase_callback example #58

Answered by fpistm
eagl1 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @eagl1

Hi,

I tested this example on my black pill and it's working perfectly.

My question is that I want to implement the HardwareTimer object in my current project which is using millis.

1. What does this code mean ?
#if defined(TIM1)
  TIM_TypeDef *Instance = TIM1;
#else
  TIM_TypeDef *Instance = TIM2;
#endif

It allows to select a timer instance. TIMx are defined by the CMSIS device header file. Depending of your mcu, timer exists or not so by testing the TIMx we can select correct timer.

2. Which timer is used for millis ?

millis is based on the systick, it is no a timer TIMx

3. If I chose either TIM1 or TIM2, would that conflict with the timer that is used for millis ?

no

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by eagl1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants