Author Topic: Looking for MCU with many timers  (Read 2782 times)

0 Members and 1 Guest are viewing this topic.

Offline ubbutTopic starter

  • Regular Contributor
  • *
  • Posts: 100
  • Country: de
Looking for MCU with many timers
« on: August 17, 2019, 10:56:26 am »
Hi,

in a design I need a small (20-32) pin QFN µC with:

- at least 6x  16bit timers that can be used for frequency generation (50% duty cycle is sufficient, no pwm)
- 5V compatible   (removed this requirement, because I released I can get away with 3.3V)
- 4x ADC
- Internal RC oscillator, at least 16Mhz
- cheap:  < $1
- bonus points: programmable logic

I looked at the usual suspects: STM, Microchip (booth PIC and AVR), NXP ... however was not able to find anything suitable.
The search is more complicated by the fact, that a parametric search might show 9x 16 bit timers, but according to the datasheet, only 3 can be used for frequency generation.
In one case (ATTINY417), the parametric search returns 6 x 16bit timers, but according to the datasheet, this is just incorrect.

So If any of you know a suitable part, please let me know!
very much appreciated

thanks!
« Last Edit: August 17, 2019, 01:08:27 pm by ubbut »
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: Looking for MCU with many timers
« Reply #1 on: August 17, 2019, 11:41:59 am »
That is difficult because you want QFN32 and 6 independent 16-bit pwm frequencies. So you need at least 6 timers, 16-bit each and such timers typically have 2-4 outputs, out of which you are going to use one.

« Last Edit: August 17, 2019, 12:13:50 pm by Brutte »
 

Offline Whales

  • Super Contributor
  • ***
  • Posts: 1899
  • Country: au
    • Halestrom
Re: Looking for MCU with many timers
« Reply #2 on: August 17, 2019, 11:47:30 am »
Any reason you can't go for an array of (eg 8-pin) cheap micros?  Even if you need a single master controlling several slaves.

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26907
  • Country: nl
    • NCT Developments
Re: Looking for MCU with many timers
« Reply #3 on: August 17, 2019, 11:50:54 am »
What kind of frequency range do you need to generate?
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline digsys

  • Supporter
  • ****
  • Posts: 2209
  • Country: au
    • DIGSYS
Re: Looking for MCU with many timers
« Reply #4 on: August 17, 2019, 12:08:57 pm »
I've been using Silicon labs stuff for many years - packed with I/O function blocks - https://www.silabs.com/products/mcu
Might be worth a look
Hello <tap> <tap> .. is this thing on?
 

Offline wraper

  • Supporter
  • ****
  • Posts: 16867
  • Country: lv
Re: Looking for MCU with many timers
« Reply #5 on: August 17, 2019, 12:19:22 pm »
EFM8LB10F16 has six 16 bit timers/ six PWM outputs and cost less than $1. Most of pins are 5V tolerant.
« Last Edit: August 17, 2019, 12:20:54 pm by wraper »
 

Offline rhodges

  • Frequent Contributor
  • **
  • Posts: 306
  • Country: us
  • Available for embedded projects.
    • My public libraries, code samples, and projects for STM8.
Re: Looking for MCU with many timers
« Reply #6 on: August 17, 2019, 12:31:47 pm »
STM8 (eg, stm8s003, stm8s103) has TIM1 with 4 output channels and TIM2 with 3. You would have to catch the interrupts and reload the 16-bit capture value for each one, though.
example: CAPTURE  = CAPTURE + INTERVAL
Currently developing STM8 and STM32. Past includes 6809, Z80, 8086, PIC, MIPS, PNX1302, and some 8748 and 6805. Check out my public code on github. https://github.com/unfrozen
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Looking for MCU with many timers
« Reply #7 on: August 17, 2019, 12:49:32 pm »
I can get 16 output compares over 6 timers with 4 ADC channels in STM32G431K6Ux UFQFPN32.
One of the channels is inverted though. And not all channels are independent, but you didn't specify anything about that.
It's not <$1, but it does have an cortex m4 at 170mhz!

Quote
5V compatible
Outputs are never 5V tolerant, so you will need to find level converters, luckily Nexpera makes a lot of those for in smartphones in an incredibly tiny footprint. So that isn't a problem.
 

Offline wraper

  • Supporter
  • ****
  • Posts: 16867
  • Country: lv
Re: Looking for MCU with many timers
« Reply #8 on: August 17, 2019, 01:12:17 pm »
Outputs are never 5V tolerant
They are in a sense that you can use external pull up and setting output to Hi-Z state.
 

Offline ubbutTopic starter

  • Regular Contributor
  • *
  • Posts: 100
  • Country: de
Re: Looking for MCU with many timers
« Reply #9 on: August 17, 2019, 01:20:58 pm »
Thanks for all your suggestions.
Just realized I can get away with using a 3.3V part, this should simplify things :)
(i did not mean 5V tolerant inputs, I meant 5V supply voltage compatible)
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Looking for MCU with many timers
« Reply #10 on: August 17, 2019, 01:37:21 pm »
Outputs are never 5V tolerant
They are in a sense that you can use external pull up and setting output to Hi-Z state.
When you tie an output to a timer, you can't have the hardware put it in a high-z automatically. So you'd need the interrupt which might jitter.
Some chips offer open-drain mode, that might work, if available together with timer output.

(i did not mean 5V tolerant inputs, I meant 5V supply voltage compatible)
That significantly reduces available candidates today.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26907
  • Country: nl
    • NCT Developments
Re: Looking for MCU with many timers
« Reply #11 on: August 17, 2019, 01:56:25 pm »
It depends greatly on what kind of logic is at the output. If it is standard TTL compliant then Vih is 1.4V which is well below 3.3V.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14488
  • Country: fr
Re: Looking for MCU with many timers
« Reply #12 on: August 17, 2019, 02:21:14 pm »
Just a thought, but you may not need as many timers as you think either.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26907
  • Country: nl
    • NCT Developments
Re: Looking for MCU with many timers
« Reply #13 on: August 17, 2019, 03:15:49 pm »
And depending on the frequency requirement you might be able to do it in software too on a fast ARM controller.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3147
  • Country: ca
Re: Looking for MCU with many timers
« Reply #14 on: August 17, 2019, 03:25:56 pm »
And depending on the frequency requirement you might be able to do it in software too on a fast ARM controller.

or in slow PIC alike.
 

Offline errorprone

  • Contributor
  • Posts: 39
Re: Looking for MCU with many timers
« Reply #15 on: August 18, 2019, 01:15:22 am »
The pic32mm gpm series might be is interest. They have 6 single channel pwms, 3 multi channel pwms and is about $2

Sent from my LG-H810 using Tapatalk

 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21695
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Looking for MCU with many timers
« Reply #16 on: August 18, 2019, 01:35:22 am »
Also consider tone generator ICs, which it sounds very much like what you may be doing?

A far out possibility is emulating timers partly in software; you can calculate the time until the next transition, set a timer for that (one-shot, interrupt), and toggle the respective pin.  The jitter will probably be pretty awful, but the spectral purity may still be good enough for some RF or control applications, and most likely is for audio purposes.  (I've done the simplest version of this before, a timed interrupt on a Z80 platform; it generated a single tone at a time and didn't sound any different depending on what the main loop was up to.)

Taking this even further, CPUs in the ~100MHz range (most second-lowest tier ARMs, say) have more than enough power to simply emulate a synth directly.  That is, generating audio a sample at a time, stepping an array of DDSs and, say, running them through wavetables and envelope generators before driving a DAC (or a PWM channel to the same end).  If you still need independent square wave channels, you could still do this but output packed binary to a GPIO port, instead of proportional (digitally coded analog) to a DAC; the sample rate does put a hard limit on how well timed the channels are, of course.  Again, spectrum may be okay, but getting finer timing is less practical.

Fast CPUs aren't really so much necessary, actually; a multi-channel synth has been demonstrated on an XT PC (8088 CPU), using the timer as a 1-bit DAC.  Poor quality of course (~30kHx sample rate at 1 bit gives quite a lot of quantization noise!), but the sounds themselves are unlike almost anything else anyone's ever generated from a PC speaker before.  Needless to say, this required heroic effort to pull off (the "8088 MPH" demo, the end of it namely), and I wouldn't expect anyone else to go to such lengths; rather, just to know that it's possible at all!

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Looking for MCU with many timers
« Reply #17 on: August 18, 2019, 01:48:11 am »
Can you use a UART for some of the frequency generation?  They usually have about a 16bit bitrate generator, and could generate a variety of 50% square waves at each bitrate (more if it doesn't need to be exactly 50%)
At the expense of needing to reload the "output character"
 

Offline ubbutTopic starter

  • Regular Contributor
  • *
  • Posts: 100
  • Country: de
Re: Looking for MCU with many timers
« Reply #18 on: August 18, 2019, 06:54:51 am »
Yes,
I need that many timers, because doing it in software would have introduced too much jitter.
Had considered a tone generator IC, but that would have meant I need a separate µC for ADC and control.

Now found the STM32F051K6U6 which can even generate 7 independent frequencies. Costs about ~$0.50 at LCSC

Thanks for all the great input and help!
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26907
  • Country: nl
    • NCT Developments
Re: Looking for MCU with many timers
« Reply #19 on: August 18, 2019, 09:19:46 am »
Can you use a UART for some of the frequency generation?  They usually have about a 16bit bitrate generator, and could generate a variety of 50% square waves at each bitrate (more if it doesn't need to be exactly 50%)
At the expense of needing to reload the "output character"
This is also a good suggestion. DMA could be used to load the same character over and over without costing much CPU cycles. Come to think of it: in the past I have used a UART to generate a PWM signal for a crude NiCd backup battery charger. An SPI interface can also be used the same way.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Looking for MCU with many timers
« Reply #20 on: August 18, 2019, 01:32:32 pm »
Just bit bang the gpio with the dma. If you already consider degrading uart to a tone generator your requirements aren’t that tight.
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3785
  • Country: de
Re: Looking for MCU with many timers
« Reply #21 on: August 18, 2019, 01:48:13 pm »
Just a thought, but you may not need as many timers as you think either.

E.g. because on STM32s you have 4 output capture compare units per timer (regardless of whether they are connected to actual I/O pins - you can always use interrupt or trigger DMA to twiddle some other pin), so you can effectively generate 4 different frequencies out of a single timer (assuming you can make do with a single prescaler value and timer clock, i.e. that the frequencies are not vastly different).
« Last Edit: August 18, 2019, 07:12:56 pm by janoc »
 
The following users thanked this post: Someone

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14488
  • Country: fr
Re: Looking for MCU with many timers
« Reply #22 on: August 18, 2019, 02:08:51 pm »
Yes,
I need that many timers, because doing it in software would have introduced too much jitter.

Unless you're using "output compare" peripherals (which are not strictly timers, but sometimes linked to them), you're essentially doing it "in software". So you should look for that kind of peripherals instead of looking for timers.

Now if there is no such peripheral and you're toggling an IO in a timer interrupt, you're already introducing some jitter (most MCUs take up to a few clock cycles to service an interrupt and it's not cycle-accurate). The whole point is just to make this negligible in your application (meaning the timer period should be long enough relative to the clock cycle).

Now you can toggle several IOs instead of just one in just ONE ISR to generate different periods (obviously all multiple of the timer's period). Not excessively complicated. Of course for that approach to be usable, the different frequencies you need to generate must all be significantly lower than the CPU clock frequency.

Some even suggested to do that without any interrupt. That's definitely doable especially if the MCU runs fast enough and is doing nothing else (so absolutely no interrupt enabled), using assembly would probably be required though.
« Last Edit: August 18, 2019, 02:10:59 pm by SiliconWizard »
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3147
  • Country: ca
Re: Looking for MCU with many timers
« Reply #23 on: August 18, 2019, 02:34:03 pm »
Now you can toggle several IOs instead of just one in just ONE ISR to generate different periods (obviously all multiple of the timer's period). Not excessively complicated. Of course for that approach to be usable, the different frequencies you need to generate must all be significantly lower than the CPU clock frequency.

I remember I did that once with PIC16 which had to drive 8 stepper controllers all running at different speeds and accelerations. I used 16kHz interrupt and the impact on the CPU was quite small.

The range of desired frequencies determines what is the best model.
 

Offline ubbutTopic starter

  • Regular Contributor
  • *
  • Posts: 100
  • Country: de
Re: Looking for MCU with many timers
« Reply #24 on: August 18, 2019, 03:22:46 pm »
The whole idea was to use 6 independent timers with output compare to generate frequencies directly. Using timer interrupts was never an option because of the relatively large jitter. (especially on ARMs)
So one needs 6 independent timers. One timer with 6 output compare channels is not able to generate 6 different frequencies, just 6 different pulse widths.

While I like to idea of using uart or spi it was never considered by me (because here the frequency resolution is limited by the number of prescalers available [usually not many])

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf