What microcontroller has the most timers

Hi Everyone,

I'm looking to find out what microcontrollers have the most amount of timers. I've been working with the ESP32, which has 4 timers. For a program I'm writing, I could use 5 or 6 timers.

Is there any kind of comparison chart of microcontrollers and their features that might include timer information?

Hi, what problem are you trying to solve ?
How do you want to use the timers ? Do you need to measure pulses at a pin or do you want multiple timers in software ? What accuracy do you need ?

If you want to measure phase shifts between high frequency signals, then extra hardware might be needed.
If you want to run multiple timers for different tasks, then the ESP32 can run thousands different millis-timers (example for 27000 timers, yes that is twenty-seven-thousand).

To answer your question: No, there is no comparison chart. There is no need for such a chart if your question is a XY-problem: https://xyproblem.info/

4 Likes

+1 with @Koepel - it would be good to understand why you think you need the 6 of them but in case you do, the Arduino Mega does have 6 timers (one being used by Arduino for micros / millis / delay related functions)

On an ESP32 (4 hardware timers) you can create software timers (see High Resolution Timer (ESP Timer) - ESP32 - — ESP-IDF Programming Guide latest documentation)

2 Likes

Atmega328PB gives you 5 timers. Two 8-bit timers and three 16-bit timers.

I use maybe 10 timers in some of my code using a Nano without a problem. These are software timers that work in 0.001 timebase. None of my timing is that critical so they do well for me.

Hello,

When it comes to microcontrollers with a higher number of timers, the STM32 series is worth considering. Many STM32 microcontrollers offer a rich set of peripherals, including a significant number of timers. For example, the STM32F4 series typically provides up to 14 timers, offering versatility for projects that require multiple timing functions.

For a comprehensive comparison of microcontrollers and their features, including timer information, I recommend checking manufacturer datasheets and reference manuals.

1 Like

nice chatGPT copy and paste... (but correct, the STM32F4 series can have up to 14 timers)

you're under watch as we have seen poster who share such content for their first post are likely to be bots or future spammers...

3 Likes

I'm sure that STM32F4 series can help.

1 Like

Thank you for all the good replies.

Hmmm, I never really thought of doing a software time using millis(). That is an interesting idea to explore. I'm not sure if it will work well with my situation, but definitely worth looking into.

To explain what I'm doing in it's simplest form. I currently have 4 timers that are set to run different functions when they expire, then reset and run it again when it expires. Depending on whether each of the features/functions are enabled or not in the config (can be changed while running) determines if that particular timer is running or not. Also, in the config, each function can be set to run at different intervals.

The timing is not super critical, I think the lowest I would have anything set to at the moment is 125ms. I don't think I would ever go below 100ms for what I'm doing just because of some of the code being run in one of the functions is probably 1/2 to 3/4 that right now and I prefer to have a little bit of a margin to make sure it's not too far off on the timing and trying to run multiples of the function concurrently.

I have not yet played with any STM32 chips, but it could be something new to explore. Any recommendations on something cheap and easy to start playing with?

If you tell what you want to do, then we can help better.

For example controlling a valve to let a drop of water fall and make a photograph of it.
Or feed four different cows at different times.
If you don't want to tell what problem you want to solve, then you are still stuck in that XY-problem.

Whatever it is, in my opinion you are overthinking it.

2 Likes

Are you running the functions in an interrupt context or just setting a flag in the ISR and capture that in the loop to execute the function ?

How long takes the typical function?

Why do some people always want to know specifics. The specifics are unnecessary. It doesn't matter if I'm controlling a valve, feeding cows, blinking lights, or running an engine. I already described what I want to do. More details on what I want to do are not necessary so much as how I am currently going about it.

Kind of both. So, basically, I have a configuration stored with an interval setting and number of steps for each counter. Each time it runs, the step increments. Once it gets to the last step it goes back to the beginning. I run part of the code in an interrupt which loads the specific settings of outputs for that step, then sets a flag that the data is ready. When the main loop sees the flag, it updates the outputs. The outputs are actually on an i2c connected chip, so essentially I send all the register data at once in the loop after the config is set by the ISR and sets the flag saying that it's ready.

I don't recall the exact timing, but altogether, everything takes I believe 80-90 ms. Most of that is because of the library I'm using to store and read configuration, not the actual update process. So, I figured a good minimum timer interval (which seems to work for what I need) is about 125ms, an eighth of a second.

EDIT: I would probably write it all in the ISR, but I found that serial functions (serial.print, i2c communications) don't work well in an ISR.

Well, because frequently people ask for a thing when it isn't needed for what they want to do.

Back when there were less capable "servo" libraries, people would ask for a chip with more timers so that they could run more than two servos on a board. But that's not the way to run a lot of servos - they can simply be run serially off of a single timer.
And while an RP2040 only has a single hardware timer, their SDK includes "alarm pool" functions that can schedule large numbers of callback events, at microsecond resolution.

Finding a chip with lots of timers ends up restricting you to that particular processor, while finding a more general software solution (if it's possible) leaves you in a better place.

Again, I ask, why do some people always want to know specifics?

I didn't ask, "how do I better feed cows at different times. It's not up to you or anyone else to decide if I need timers or not. I asked about more timers. I didn't even say that I specifically needed hardware timers, and I was very open to the software timer idea.

Now, if anyone has any useful information to post or questions to ask, like @J-M-L, then I am perfectly willing to answer questions and appreciate any help. But if you're going to ask stupid questions about specifics, like if I'm feeding cows or controlling valves, or anything else, just don't even post.

I said I was using the timers to run some functions. @J-M-L asked valid questions ask to how I was going about that and what my timing was like. I appreciate that and I answered with what I think is a pretty descriptive reply that will hopefully help them advise me better.

My question was about timers and replies should be limited to this subject. This is how how things usually work.

I am sorry if anyone feels offended by this, but, again, I did not ask how to better feed cows.

Because we want the OP's project to work, and have no idea (in the absense of any details) whether they've asked a stupid question or not. A LOT of arduino users are programming beginners, and frequently ask the "wrong" questions.

Now, it may be that YOU in particular have experience and knowledge that means your question is exactly what you need/want the answer to, but WE have no way of knowing that. Or this thread could have stopped with "some STM32 chips have many timers."

(Also, beware of different types of timers. The new AVRs have "type A" through "type F" timers these days, plus an RTC. Some chips have a separate PWM peripheral that can drive "many" PWM pins off of a single "timer." ARMs will usually have an additional sysTick timer, and maybe a DWT Cycle timer...)

1 Like

We often see here people asking question X because they believe it’s the solution to their real problem Y. The intent is to assess if X is the real fundamental question to help the poster.

That’s what I was coming to. ISRs should be kept super short and you are limited in what you do there and depending on the platform it can create time challenges if multiple triggers at similar time but the code is already busy in an ISR which can’t be interrupted (your I2C issue).

if the execution depends on the loop picking up a flag, then you don’t really need the interruption to be managed in hardware.

Taking an approach just with a software timer could simplify your code (get rid of the volatile variables and critical sections of the loop).

That could be something to explore if it has an impact on your ability to get better timing. (RAM cache ?)

Others have answered this already. We dont know what the demands of the OP are - will they then say I need an accurate time in picoseconds? Or referenced to NTP?
I'll throw another spanner in the works.
Has the OP considered distributed processing - then you have access to as many timers as you could ever need, without imposing ridiculous demands on processing power.

.

Because these people try to get a better understanding of the underlying problem of YOUR QUESTION.
In the end it will help YOU to get better answers.

2 Likes

Because there is a vast difference in the answer given depending on whether you need a timer to measure nanoseconds or a timer to measure hours.

What I would like to know is why people think that specifics are unnecessary? Actually I already know, people ask for help in the first place because they lack knowledge. Questions like "which MCU has the most timers" is a flag to indicate that their approach to the problem is probably wrong.

There are people here with decades of experience in MCUs and coding, which is why you asked here in the first place. If you don't like the answers... well you asked for experienced advice.

1 Like