Microcontroller: 16 bit or more timers with 100MHz timer clock - Page 1
Forum section: electronics / general

author: tridac
author_rank: Regular Contributor
timestamp: October 05, 2023, 12:41:50 am
content: Have some ideas around a pwm generator with 24 bits of precision. Could do that with a single 32 bit timer, or two 16, but need a timer clock of at least 100MHz, to satisfy the pwm period requirement. Cortex M2 or M4 series look like they might be suitable, but which can handle the highest timer clock frequency, withut trawling though a myriad of data sheets ?. Lowest possible featuritis and cost, as the pwm geerator will be the main function. Comms needed, serial ok, usb, better, or network capability, best, would be a plus. Cheap eval board via Ebay might be the best way to get started. Things seem to have moved on a lot since the last serious embedded project here, so what is the state of the art now ?...

author: ozcar
author_rank: Frequent Contributor
timestamp: October 05, 2023, 02:08:57 am
content: I made a sort-of PWM generator using one of these:https://www.dfrobot.com/product-2338.htmlHardly state of the art now, but two 32-bit timers, several 16-bit timers, and yes, they can run up to 100MHz. USB, but not network by itself.TBH it had way more flash, ram and who-knows-what for what I was doing, so perhaps not low on the featuritis. Maybe you should give some indication of what cost you have in mind.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 05, 2023, 03:49:38 am
content: In the "lowest cost and features" category: The STM32G031. Timer0 can run up to 128MHz:https://www.st.com/en/microcontrollers-microprocessors/stm32g031g8.htmlFor large production this could be risky, but for yourself or small project, the G030 (Unofficially) also has this capability.All the peripherals from the more expensive G041 are there except AES, also 64KB flash, for 35 cents.See:https://www.eevblog.com/forum/microcontrollers/stm32g030-g031/msg5048995/#msg5048995

author: krho
author_rank: Regular Contributor
timestamp: October 05, 2023, 05:51:43 am
content: Don't know for the MCU, but for the Wired network you could use the SPI chips made by Microchip if 10Mbit is enough. Also If you need the WiFi or both you could look at the espressif offerings. They are really cheap and you have xtensa architecture and on newer ones Risc V. Plenty of RAM and flash available.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: October 05, 2023, 10:02:30 am
content: STM32F411 can run some of it's timers st 100MHz, and it's available on cheap and breadboard friendly breakout boards as the "Black Pill" (WeAct)).There are some uC's which have peripherals that are optimized for very high speed PWM. In general the clock speed of the PWM is the same as the max clock speed as the uC, (Teensy 4 (with an LPC) has a clock speed of some 400MHz), but some uC's have a PWM resolution that is higher then it's clock speed suggests. I think the document below describes such a peripheral, with "5-bit fractional pwm" (on top of normal pwm), but I have not looked into details.https://www.nxp.com/docs/en/application-note/AN4746.pdfBut I don't understand your post about multiple timers. You can't get a higher PWM resolution with that. It is possible to use it to create a higher resolution DC voltage by combining several PWM channels, but that is a separate topic.

author: tridac
author_rank: Regular Contributor
timestamp: October 05, 2023, 12:51:51 pm
content: That sort of thing looks like a low risk option to get started and seems to be the basis of quite a few low cost sellers. 2 x 32 bit timers up to 100MHz, which looks ideal, and there are even variants of that series with ethernet. Devil is in the detail, as usual.Such a plethora of options these days, and far cry from the sort of devices used in the past. Did some initial work with earlier stm32... series, but never had a serious (that is, work) project to run with it. Risc 5 looks interesting, but needs a few more years to achieve volume and cost critical mass. Time to catch up a bit anyway and thanks to everyone for the replies...

author: Chalcogenide
author_rank: Regular Contributor
timestamp: October 05, 2023, 01:52:25 pm
content: The STM32G474 has an HRTIM peripheral which allows 6 channel PWM with a resolution of 184 ps (170 MHz clock with a resolution of 1/32nd of the clock period), although the timer is only 16 bit, but the peripheral also allows some other trickery which you might want to look at. It also has two regular 32 bit timers and a bunch of 16 bit ones.

author: tridac
author_rank: Regular Contributor
timestamp: October 05, 2023, 08:53:46 pm
content: With 100MHz clock, the minimum pulse width will be 10nS, so may have to limit that because of rise and fall time of the timer output, which will be significant. Really just need to build something up, to find out what the limits are...

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 08, 2023, 08:03:19 pm
content: Quote from: tridac on October 05, 2023, 12:41:50 amDo you really need 16 timers, or did you mean 16 PWM channels ?Do those PWM’s need to be 16b, or more ?A lot of 32 bit MCU are stuck back at 16 b pwm tho some do have 24b (nuvoton) or 32b (nxp)Many new MCU have PLL for timers, even 8 b MCU can have 144MHz or 256MHz PWM

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 08, 2023, 08:08:48 pm
content: Quote from: tridac on October 05, 2023, 08:53:46 pmYes, PWM clocks can be much faster than a gpio pin these days.The delays and slews are moderately stable, but very extreme limits +/- a few, will have pin limits.

author: Kleinstein
author_rank: Super Contributor
timestamp: October 08, 2023, 08:31:55 pm
content: For PWM out some timers have the option to a few bits (like 4) via delay settings. This give a resolution like a GHZ range clock for a simple PWM timer.There can however still be limitiations, e.g. from jitter of the clock, when generated via PLL.

author: tridac
author_rank: Regular Contributor
timestamp: October 09, 2023, 12:31:09 pm
content: One technique used here in the past was to get more accuracy from a baud rate generator. Assuming an interrupt driven timer to generate the clock, if the division ratio comes out to a fractional value, say 125.5. then reload the timer with 124, then 126, on alternate interrupts. That can be modified to achieve other fractional division ratios. There will be a some jitter on the uart clock, but it won't care about that..

author: zapta
author_rank: Super Contributor
timestamp: November 03, 2023, 04:44:24 am
content: >> TBH it had way more flash, ram and who-knows-what for what I was doing,That's an expensive source. F411 are available now for much less. E.g. from Weact Sutdioshttps://www.aliexpress.us/item/3256801269871873.html

author: tridac
author_rank: Regular Contributor
timestamp: November 03, 2023, 07:00:41 pm
content: Looks like I will be standardising on ST Cortex M series for future projects, m more functionality and speed than needed for most projects. Cheap boards all over the web and Ebay as well + wide variety of toolchain support, free and otherwise...

author: SiliconWizard
author_rank: Super Contributor
timestamp: November 03, 2023, 08:13:35 pm
content: Not sure what you want to achieve, but PWM with 24 bits of resolution? Not too convinced it's the best approach whatever the use case is.

author: tridac
author_rank: Regular Contributor
timestamp: November 05, 2023, 10:48:27 pm
content: I'm not sure it's even possible, hence building a test rig to investigate. Application is digatal to analog interface related...

author: SiliconWizard
author_rank: Super Contributor
timestamp: November 05, 2023, 11:50:13 pm
content: Not sure yet what *exactly* you want to do, but the "usual" way of getting that kind of resolution with lower frequencies is to implement a sigma-delta modulator rather than use plain PWM.Whether you can implement one at the required frequency for your application on a given MCU, that's something you'll need to figure out. But at least you won't need to be running the modulator at 100 MHz, in all likelihood.Some MCUs do embed a sigma-delta modulator as a peripheral.One MCU that would surprinsingly work probably even for PWM'ing at 100 MHz is the modest RP2040.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: November 06, 2023, 03:10:55 am
content: Quote from: tridac on November 05, 2023, 10:48:27 pmFor DAC usage, yes it is possible to get higher resolutions with dual PWMs.It's routine to see dual 8 bit PWMs merged with scaled resistors to create a 16b DAC.You could merge two 12b PWM, with high precision resistors, to get 24b ballpark.Normally, these are used in a calibrate or closed loop, where small step size matters more than absolute precision and stability.There are also some MCUs that extend precision by PWM dither.They use eg 12 bits of PWM and another 4 bits dither LSB over 16 periods, in a hybrid of SDM and PWM.