Page 1 of 1

Question about Timers

Posted: Thu Jun 03, 2021 9:39 pm
by nesergen
Good day!
I want to use timers in my program to periodically execute a part of the code, without referring to any pins.
According to the documentation, to activate the timer, you need to write the following line, which usually includes the identifier (built-in number) of the timer.

Code: Select all

machine.Timer(id, ...)
But I do not specify the identifier and the timer is created and works without problems.

Code: Select all

machine.Timer(mode=machine.Timer.PERIODIC, period = 2000 , callback = lambda x: set_ln2())
And two timers are created this way and work.
So the question I'm interested in is what timers (name, type, or something else) I activate with this code and how many of them can I create?

Re: Question about Timers

Posted: Fri Jun 04, 2021 6:10 am
by davef
What hardware are you running on?

ESP8266 virtual timers
ESP32 hardware timers

Re: Question about Timers

Posted: Fri Jun 04, 2021 10:29 am
by nesergen
davef wrote:
Fri Jun 04, 2021 6:10 am
What hardware are you running on?

ESP8266 virtual timers
ESP32 hardware timers
I'm sorry, I forgot to specify my equipment. I am using stm32f411 board.

Re: Question about Timers

Posted: Fri Jun 04, 2021 3:49 pm
by pythoncoder
If no ID is specified (or id == -1) the timer is virtual. A positive integer specifies a hardware timer.