[SOLVED]Interruptions in the timer do not work

STM32F103 Nucleo boards e.g. STM Nucleo F103RB
FRANCISCOGIMENO
Posts: 38
Joined: Wed Nov 08, 2017 12:30 pm

[SOLVED]Interruptions in the timer do not work

Post by FRANCISCOGIMENO » Wed Nov 22, 2017 9:38 am

Hello friends can someone tell me some example of use of the timers with the arduino ide in the core board.
The library of Timer1..Timer3 seems not to work in this board.

I have searched but I do not see any clear example.

Greetings and thank you
Last edited by FRANCISCOGIMENO on Wed Nov 29, 2017 1:50 pm, edited 2 times in total.

stevestrong
Posts: 1813
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Use of the timer?

Post by stevestrong » Wed Nov 22, 2017 10:45 am

Here is the original leaflabs reference documentation: http://docs.leaflabs.com/static.leaflab ... -mini.html
On the right side you have the modules (including Timers).

FRANCISCOGIMENO
Posts: 38
Joined: Wed Nov 08, 2017 12:30 pm

Re: Use of the timer?

Post by FRANCISCOGIMENO » Wed Nov 22, 2017 11:01 am

Thanks for your answer.

In that web the reference of those libraries I do not have them.

my board is an STMF303 - F303K8 And do not use these libraries

fpiSTM
Posts: 247
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: Use of the timer?

Post by fpiSTM » Wed Nov 22, 2017 1:27 pm

Hi,
I've open a discussion around timer management here:
https://github.com/stm32duino/Arduino_C ... issues/146

FRANCISCOGIMENO
Posts: 38
Joined: Wed Nov 08, 2017 12:30 pm

Re: Use of the timer?

Post by FRANCISCOGIMENO » Wed Nov 22, 2017 4:07 pm

I used the <FlexiTimer2.h> and it gives me an error when compiling.

Does not support this micro.

The other two do not compile either.

FRANCISCOGIMENO
Posts: 38
Joined: Wed Nov 08, 2017 12:30 pm

Re: Use of the timer?

Post by FRANCISCOGIMENO » Thu Nov 23, 2017 6:15 pm

Someone knows why libraries do not work
Timer1 ... 2 ...


I have tried this example and it does not work either.


#define ANY_DELAY_RQUIRED 0x0FFF

TIM6->SR = 0
TIM6->ARR = ANY_DELAY_RQUIRED
TIM6->CR1 |= TIM_CR1_CEN
while (!(TIM6->SR & TIM_SR_UIF)); /* Loop until the update event flag is set */
/* The required time delay has been elapsed */
/* User code can be executed */

Compile without errors but it does not work

fpiSTM
Posts: 247
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: Use of the timer?

Post by fpiSTM » Thu Nov 23, 2017 8:22 pm

Maybe clk for this timer is not enable.

__HAL_RCC_TIM6_CLK_ENABLE
https://github.com/stm32duino/Arduino_C ... rcc.h#L797

FRANCISCOGIMENO
Posts: 38
Joined: Wed Nov 08, 2017 12:30 pm

Re: Use of the timer?

Post by FRANCISCOGIMENO » Fri Nov 24, 2017 7:55 am

Hello that example, I have taken it from the sheet of ST AN4776

To use it I include in the project #include <Timer.h>.

I will try your option to see if it works.

FRANCISCOGIMENO
Posts: 38
Joined: Wed Nov 08, 2017 12:30 pm

Re: Use of the timer?

Post by FRANCISCOGIMENO » Fri Nov 24, 2017 1:11 pm

It's still not working .. I'm going crazy with the timer :oops: :oops: :oops:

FRANCISCOGIMENO
Posts: 38
Joined: Wed Nov 08, 2017 12:30 pm

Re: Use of the timer?

Post by FRANCISCOGIMENO » Fri Nov 24, 2017 1:18 pm

if I put this:


TIM6-> SR = 0;
TIM6-> ARR = 250;
TIM6-> CR1 | = TIM_CR1_CEN;
while (! (TIM6-> SR & TIM_SR_UIF));

point A

Never go to point A



RCC->APB1ENR |= RCC_APB1ENR_TIM6EN; <-----------new line
TIM6->SR = 0;
TIM6->ARR = 250;
TIM6->CR1 |= TIM_CR1_CEN;
while (!(TIM6->SR & TIM_SR_UIF));

point A

And with the new line, that tells you that the oscillator is internal,
goes to point A immediately without doing any kind of timing

Post Reply