$1 MCU review — looking for part suggestions! - Page 1
Forum section: electronics / general

author: funkathustra
author_rank: Regular Contributor
timestamp: July 30, 2017, 06:19:30 pm
content: Hey everyone! I'm reviewing $1 (@ 100 QTY) general-purpose 8/16/32-bit MCUs from a wide range of vendors, and I'm looking for leads on parts. The review will include quantitative comparisons between feature sets, benchmarking (via a 16-bit biquad filter test measuring kSPS and nJ/sample), power analysis, plus more qualitative stuff (development environment, SDKs, compiler choices, development/debugging experience, etc).I started with a pretty humble list, then hit up AVRFreaks, where several members recommended some interesting parts. Thought I'd try my luck over here, too!The only rule is that the part has to be $1 or less @ 100 units from reputable sources (something on Octopart, or direct from the manufacturer). If a part isn't available from U.S. based distributors, I'm cool with eBay / Ali Express / Taobao links at that point. Please no Newark close-out specials on NRND parts.So far, the big list is:Atmel ATTiny1616Atmel ATSAMD10Cypress PSoC 4000SFreescale (NXP) MKE04Freescale (NXP) MKL03Infineon XMC1100Microchip PIC16LF18855Microchip PIC24F04KL100Microchip PIC32MMNuvoton N76E003Nuvoton M052LDNNXP LPC811Renesas RL78/G12Silicon Labs EFM8LB11ST STM8S005K6ST STM32F030STC IAP15W4K61S4Texas Instruments MSP430FR2111Anything I'm missing? Thanks!

author: nctnico
author_rank: Super Contributor
timestamp: July 30, 2017, 06:40:33 pm
content: I don't see the value in such a test. At 100 units the engineering costs (*) will swamp the material costs so the point of staying under $1 is rather moot. A comparison between controllers between $8 and $10 is way more interesting.(*)for hobby: compare spending the extra time needed due to device limits and working the same time at the local grocery store.

author: ataradov
author_rank: Super Contributor
timestamp: July 30, 2017, 06:46:12 pm
content: You can add SAMD11, it is still under $1, but has USB.But, yes, I agree, it will be a real waste of time.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 30, 2017, 06:57:00 pm
content: Seems like a lot of work for something that will be of fairly limited use as everyone's requirements will be different.

author: tszaboo
author_rank: Super Contributor
timestamp: July 30, 2017, 07:19:59 pm
content: Quote from: nctnico on July 30, 2017, 06:40:33 pmWell, I think it makes sense, for some special niche. Like making a kickstarter, where you would rather keep the cost low, and you are fine for spending more time, because it is a hobby.i would include some "reference" low cost micros, like Atmega328, STM32F103, Atmega32u4 ... for the reference. What do you get, if you pay more.

author: funkathustra
author_rank: Regular Contributor
timestamp: July 30, 2017, 07:37:49 pm
content: I think you're all focusing on the price / quantity for the wrong reason. In no way am I saying that you should swap out your $5 MCUs for $1 ones to save money at 100 unit quantity production run. Obviously that would be ridiculously stupid.It's more like, "hey, what's out there these days, in 2017? What do all these manufacturer's development environments look like? If you're starting a new, long-term project, what parts should you consider?"I picked "100 units" because it's sort of where pricing trends start to happen. It's a quantity that professionals and hobbyists can both wrap their heads around. And it's also small enough that it avoids shopping / negotiating directly with an MCU vendor. Look, last time I did a high-volume commercial product, I called up NXP and told them what I wanted to pay for their MCUs. So looking at quantities of 1k, 10k or 100k gets more challenging, because it really depends on your relationships with the vendors.And I picked $1 price point because without a price limit on this comparison, it's overwhelming to whittle things down. These days, $1 buys you a mid-range, general-purpose basic microcontroller that's got dozens of I/O, half a dozen or more PWM channels, 10 or 12 bit ADC, decent sets of timers, and enough flash and RAM to cover most general-purpose entry-level needs. Personally, I think limiting price to $1 is a great way to give people some intuition about these families — and if you need more, you can always shop up in price, as most of these families are quite large, and vary quite little as you get up into the $10 price (from a broad perspective, what's the difference between the STM32F0 ecosystem and the STM32F4 ecosystem? Not much)

author: nctnico
author_rank: Super Contributor
timestamp: July 30, 2017, 07:40:03 pm
content: Quote from: NANDBlog on July 30, 2017, 07:19:59 pmI disagree. For a kickstarter you will want the product ready on time. The idea is out there so the competition is watching.

author: tszaboo
author_rank: Super Contributor
timestamp: July 30, 2017, 07:46:22 pm
content: Quote from: nctnico on July 30, 2017, 07:40:03 pmAnyone smart enough would develop the hardware prototype, including the firmware, before going for kickstarter. The really smart people only release a 3d render, and get millions for a not feasible idea though.

author: funkathustra
author_rank: Regular Contributor
timestamp: July 30, 2017, 07:49:39 pm
content: Quote from: evb149 on July 30, 2017, 07:14:39 pmYes! You hit the nail on the head. The other thing I noticed is that the internet is full of these engraved-in-stone beliefs ("ARM always beats 8-bit", "AVR is faster than everything else because it's single-cycle", "8051 is old and shouldn't be used", "It doesn't make sense to learn a new MCU if you can help it"), and in my testing, many of them evaporate.Early observations (not finalized!):Siliicon Labs' 8051s are cycle-for-cycle similar to the AVRs in performance, but run at much higher clock rates.One of the biggest determiners for power consumption is whether the core is supplied by an internal 1.8V LDO or not; this is not as well advertised in the datasheet or on distributor web sites as it should be.The Renesas RL-78 is one of the best MCUs in this price range (considering performance and power consumption), has fantastic free dev tools, and it's virtually unheard of in the U.S.Nuvoton's Cortex-M0 parts are probably the simplest ARM MCUs to use, as they have much simpler power topology. They feel like an 8-bit MCU, which would be great for beginners looking to move up to ARM. They have $10-20 dev boards and free dev tools. But you pay heavily for all this with terrible power consumption numbersDifferent M0 vendors seem to have quite different interrupt structures for their peripherals, which can affect latency hugelyARM-GCC produced much faster (but much larger code) in all my tests when compared to MDK using comparable optimization settings. No flame war until final testing is finished, please.

author: nctnico
author_rank: Super Contributor
timestamp: July 30, 2017, 07:50:09 pm
content: Quote from: NANDBlog on July 30, 2017, 07:46:22 pmLOL!

author: funkathustra
author_rank: Regular Contributor
timestamp: July 30, 2017, 07:58:54 pm
content: Quote from: blueskull on July 30, 2017, 07:50:12 pmOr even if you're a hobbyist working here. The STC, dollar-for-dollar, looks fantastic when compared to other 8-bit MCUs. They have decent English datasheets, and their parts are readily available on Ali Express, which many U.S. shoppers are becoming comfortable using, and Taobao (which hardcore shoppers are fine wtih). All STC parts have a UART bootloader and UART debugging (via a monitor program), so if you've got a USB-to-UART dongle laying around, that's all you need. Developing in Keil is much grosser than the Silicon Labs' 8051 parts, though, which use their free, Eclipse-based IDE — while still calling the (excellent) Keil C51 compiler under the hood.The STM8 is afantasticmicrocontroller that ships with a great peripheral library, and has many features found only on Cortex MCUs (slew rate / drive strength, lots of clocking options, and a nice core design). Biggest problem for me is that STVD feels like it belongs in Windows 98.STM32F0 is pretty average when compared to other Cortex-M0 parts, but it's really cheap in China, and, like the STM8, supports $5 ST-Link debugging. Lots of good, free, Eclipse-based tools.

author: ataradov
author_rank: Super Contributor
timestamp: July 30, 2017, 07:59:31 pm
content: Quote from: funkathustra on July 30, 2017, 07:49:39 pm8051 will lose just because of a single accumulator. C compilers suck at dealing with that.Quote from: funkathustra on July 30, 2017, 07:49:39 pmBut if you do have a problem, good luck getting any support. Manufacturer will not respond unless you are buying millions, and there is no public support, since nobody uses them in hobby and small scale projects.Quote from: funkathustra on July 30, 2017, 07:49:39 pminterrupt latency is defined by the core. Structure of interrupt source may result in needing to handle more interrupts to achieve the same goal though.Quote from: funkathustra on July 30, 2017, 07:49:39 pmTry it with LTO. On big projects I see 10-20% reduction in size.PS: I'm pretty set on ARM parts, I'm not moving to anything else unless there is a HUGE advantage. Anything else just not worth my time and hassle.

author: funkathustra
author_rank: Regular Contributor
timestamp: July 30, 2017, 08:10:04 pm
content: Quote from: ataradov on July 30, 2017, 07:59:31 pmIt's funny that you're literally doing exactly what I was just making fun of — people applying old, tired opinions that don't necessarily hold up in 2017.While what you said was true of compilers when the AVR was designed, it's not necessarily true in 2017. In fact, the fact that the 8051 has fine-grained balance between data space and access time (MOVs and operations can take 1, 2, or 3 cycles to execute -- basically the number of bytes long the instruction is -- based one where the data is) gives you control over performance, in many scenarios. In my testing, an ATTiny and an EFM8 were both tested with identical code to perform high-pass filtering using a 16-bit direct form I biquad implementation. They have almost identical performance numbers. This largely comes down to memory access, with Silicon Labs' pipelined core structure helping edge it out over the ATTiny. To add insult to injury, the EFM8 at the same price point runs at 72 MHz from an internal oscillator, while the ATTiny can only hit 8 MHz from an internal oscillator. And the EFM8 @ 72 MHz uses less power than an ATTiny @ 8 MHz. Obviously, this was *one test* and the results are preliminary.Of course, Cortex-M0 parts that cost the same have come in and wrecked both of these in terms of raw processing performance and nJ-per-sample power consumption figures (but not power consumption in wait/sleep modes!)Again, not starting a flame war -- there's lots and lots and lots of good reasons to pick an AVR part, but just make sure to check your numbers before you talk about performance or power consumption.

author: funkathustra
author_rank: Regular Contributor
timestamp: July 30, 2017, 08:15:42 pm
content: Quote from: ataradov on July 30, 2017, 07:59:31 pmWhich ARM part, though? I'm testing eight of them. All have wildly different performance, features, and development ecosystem friendliness.Also, there's a lot of applications where I've spent way more time hassling with low-power modes trying to get an ARM microcontroller to get near what I get on a low-power 8-bit guy. It always comes down to the application.I think you're going to love reading my write-up when I'm finished.

author: ataradov
author_rank: Super Contributor
timestamp: July 30, 2017, 08:15:56 pm
content: Quote from: funkathustra on July 30, 2017, 08:10:04 pmI should probably rephrase my statement: "Free and open C compilers suck at dealing with that.". I have no doubt that proprietary win-only compiler may have improved. I personally don't care, I don't want to be stuck in a hell of proprietary tools.And there is no reason to spend a whole lot of effort on making 8051 work, IMO.

author: funkathustra
author_rank: Regular Contributor
timestamp: July 30, 2017, 08:19:24 pm
content: Quote from: ataradov on July 30, 2017, 08:15:56 pm"Open" you're not going to get with Keil, but free? Yes.Silicon Labs gives away full versions of Keil's C51 compilerwhen you install their free Eclipse-based IDE, Simplicity Studio. And, it's completely cross-platform — which should entice some hobbyists to check it out, since they tend to be on macOS / Linux more often than other developers.Quote from: ataradov on July 30, 2017, 08:15:56 pm600 nA sleep current, with RAM retention, with an RTC running.

author: ataradov
author_rank: Super Contributor
timestamp: July 30, 2017, 08:22:01 pm
content: Quote from: funkathustra on July 30, 2017, 08:15:42 pmWell, I work for Atmel/Microchip, and I do like SAM parts (SAM D specifically). I used STM32 a lot in the past, and have no problems with them either.Quote from: funkathustra on July 30, 2017, 08:15:42 pmI only do bare-metal, so vendor ecosystem is not a problem, they all universally suck. And requirement for performance is very specific to a project. I doubt there is a way to do a good chart-like comparison. There may be details that may make or break a project that you will not notice without extensively using the part.Quote from: funkathustra on July 30, 2017, 08:15:42 pmThis is true at times, but much less in recent years. And in my experience ARM datasheets are much more honest about their power consumption numbers.I never had a problem hitting datasheet number straight out of the box. With AVRs I had to dick around a lot to get anywhere close to the claimed number.

author: ataradov
author_rank: Super Contributor
timestamp: July 30, 2017, 08:29:43 pm
content: Quote from: funkathustra on July 30, 2017, 08:19:24 pmUntil they change their mind (or contract expires), and then you are screwed.Keil already scaled down maintenance on anything but ARM after acquisition my ARM. It is a matter of time until they kill it entirely.Quote from: ataradov on July 30, 2017, 08:15:56 pmThis is so far the best argument, but ARMs nowadays are mostly ~2 uA sleep under the same conditions. And the gap narrow every year.

author: coppice
author_rank: Super Contributor
timestamp: July 30, 2017, 08:58:19 pm
content: Quote from: ataradov on July 30, 2017, 08:29:43 pmThe ARMs are actually getting worse for their sleepy state consumptions. At the finer geometries they are moving to its really hard to to get the leakage as low as at, say, 180nm or 130nm. There might be breakthroughs. 180nm leaked like a seive in the early days, but most makers managed to get very respectable leakage later on. Right now the 90nm, 65nm and 45nm geometries being used for new MCUs are still comparatively leaky.

author: nctnico
author_rank: Super Contributor
timestamp: July 30, 2017, 09:12:20 pm
content: Quote from: ataradov on July 30, 2017, 08:29:43 pmIf you get a license which never expires and can be installed on any PC then you won't need Keil's support. I have used Keil's compiler for 8051 and I must say it does a pretty good job. Still like any architecture similar to the 8051 (like 8 bit PIC) you have to write C code with the architecture in minder otherwise the code will be extremely slow.

author: wraper
author_rank: Unknown
timestamp: July 30, 2017, 10:05:18 pm
content: Quote from: funkathustra on July 30, 2017, 08:10:04 pmAlso cortex M at such price don't have such interesting peripherals. For example, with EFM8UB1 I can get MCU with crystal-less USB, 5V tolerant GPIO, internal 3.3V voltage regulator which can supply up to 100 mA to external devices and 12 bit ADC for around $0.60 @100pcs. That is pretty amazing.

author: NorthGuy
author_rank: Super Contributor
timestamp: July 30, 2017, 10:36:29 pm
content: I think making such comparison is a brilliant idea. Don't forget to post the results.I found you one of the newest PIC18s for 99 cents:http://www.microchipdirect.com/ProductSearch.aspx?Keywords=PIC18LF24K40-I/SSUnfortunately PIC16F1454 with USB didn't make it under the dollar limit.If you want to measure sleep current on PICs, use LF versions instead of 5V versions, e.g. PIC16LFxxx instead of PIC16Fxxx - they have sleep current in nA.Also, traditional benchmarks do not reflect performance very well. You may try something non-traditional, e.g. how fast you can toggle a pin, how fast you can squash a bug - e.g. change an output in response to the rising edge on input, how fast you can send/receive UART etc. Although, even then you'll be mostly evaluating C compilers rather than chips.

author: funkathustra
author_rank: Regular Contributor
timestamp: July 30, 2017, 11:07:34 pm
content: Quote from: NorthGuy on July 30, 2017, 10:36:29 pmAbsolutely! I'm writing up an extensive section of pages on my blog which will have a large comparison piece, along with separate in-depth reviews and analysis for each family, which will include "gotchas" that each platform inevitably has, along with some qualitative discussion about available IDEs, peripheral libraries, documentation, and other resources.Quote from: NorthGuy on July 30, 2017, 10:36:29 pmOooh, thanks for the link — I looked for a PIC18 under a buck and couldn't immediately turn something up. Will add this to the list.Quote from: NorthGuy on July 30, 2017, 10:36:29 pmYup, using the LF parts for everything, since all benchmarking and power measurements will be conducted at 3.3V (sorry, AVR).Quote from: NorthGuy on July 30, 2017, 10:36:29 pmTotally agree! Just to get into a little bit more of the mechanics of what I'm doing, in addition to comparing specs, I'm doing three code-oriented tasks on each platform:Wiggling a pin as fast as possible. Analyze number of instructions and cycles per wiggle — doing a bitwise complement like this gives you an idea of how the platform works under the hood; is it a CISC architecture that can directly complement a bit in an SFR? Does it have to do a read-modify-write? Does the machine cycle equal the clock cycle?64-sample high-pass filter implemented as a 16-bit direct-form I biquad.Gives a good indication of math and memory performance, as well as efficiency (as I'm measuring nJ-per-sample in addition to pure maximum sample rate)Implement a DMX-512 receiver attached to an RGB LED; minimize power consumption by using wait states and low-frequency clocking.Looking just at the MCU, this helps develop some basic intuition about peripheral programming and clock management / pin muxing. It shows off power consumption figures when operating in non-deep-sleep / non-fully-active state. But it also shows off how good (or disgusting) the manufacturer-supplied SDK and peripheral libraries are, what the features of the IDE include, and if the code-gen tools are worth using (especially when you have that one extra quirk — that DMX-512 requires detecting a framing error as a 'start of frame' indicator, and some peripheral libraries / code-gen tools don't do this for you).

author: NorthGuy
author_rank: Super Contributor
timestamp: July 30, 2017, 11:18:58 pm
content: Quote from: funkathustra on July 30, 2017, 11:07:34 pmPIC18LF24K42 has built-in hardware DMX support, but it is out of your price range by few cents.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 30, 2017, 11:45:40 pm
content: QuoteBreaks can get interesting when you have a FIFO'd UART, and a UART error interrupt. I don't recall the CPU but I've seen a situation where the error int happens when the UART is still in the FIFO behind some data.This caused an issue only with DMX coming from I think a Pharos unit, which sent the break immediately after the last byte of the previous frame.

author: funkathustra
author_rank: Regular Contributor
timestamp: July 31, 2017, 12:13:20 am
content: Quote from: mikeselectricstuff on July 30, 2017, 11:45:40 pmHaha, it's really serendipitous that you should mention that. The Nuvoton M051 part I just finished testing on last night had this issue. I created a bit of a weird state-machine that sets the FIFO to 1 byte until a framing error happens, and then increases the FIFO to 14 bytes, until it gets halfway through, and then resets it to 1 again. This way I can start receiving at an arbitrary period of time and still use the FIFO....of course, once I did all that, I lowered the clock rate to the minimum (which is still pretty high -- it's only a divide-by-16 system divider from a 22 MHz internal oscillator), and the system could easily handle the single-byte reception, thus making the whole thing pointless in this particular application :-)The wait states in the main busy loop helped a ton with overall power consumption, but didn't change anything at all with or without the FIFO enabled.I want to go back and use the Renesas RL-78's DMA (yes, a 60-cent 8-bit MCU with DMA!) to see if it changes the power consumption, but at 500 µA, it's currently leading the pack (lots more to review, though, and I've basically only been doing industrial-targetted MCUs that don't have good power figures).I can't wait to finish testing all the Cortex-M0 MCUs, since the two that I've tested so far — the Freescale/NXP KL03 and the Nuvoton M051 — have vastly different interrupt routine timings with respect to the UART. The KL03 didn't raise an interrupt until halfway through the next byte, and it took about 70% of the byte period to get through the ISR. The Nuvoton part, running at the same frequency, took no time at all — maybe 1/15th of the period. Same core, same interrupt system. Must have vastly different UARTs with different latencies. Totally different power consumption figures, too.

author: westfw
author_rank: Super Contributor
timestamp: July 31, 2017, 10:11:25 am
content: QuoteDoes the SI license say you can use the compiler they provide on other vendors' chips, or are you just engaging in a subtle form of piracy?The whole comparison thing might be more interesting if done at more price levels (perhaps with fewer chips at each price level.) In general, I feel like I have a much better idea about what a "typical" $1 microcontroller will do than "do you get 5x or 10x the capabilities with a $5 or $10 microcontroller?" (and a comparison at the $15 level (near the top-of-the-line for AVRs) is a lot more dramatic in some ways. The 8bit chips are about 256k flash and 8k of RAM, while the 32bit chips are up at 1MB flash and 256k of RAM!)

author: gamalot
author_rank: Super Contributor
timestamp: July 31, 2017, 12:24:02 pm
content: A few days ago I bought some STM32L011D4P6TR for about $0.97/pc on Taobao.

author: Yansi
author_rank: Super Contributor
timestamp: July 31, 2017, 05:52:49 pm
content: Quote from: wraper on July 30, 2017, 10:05:18 pmLook at STM32F042.

author: funkathustra
author_rank: Regular Contributor
timestamp: July 31, 2017, 07:17:43 pm
content: Quote from: westfw on July 31, 2017, 10:11:25 amOf course it's restricted to SI chips. While I recently wrote a blog post about using Simplicity Studio (thus, Keil C51)to program a 35-year-old MCU, it was done more as a fun exercise — it would be dishonest to program other 8051s in Simplicity Studio with the unlimited Keil license; especially for commercial purposes.There's also not much reason to; most other 8051s are inferior to SiLabs' parts, and aren't much cheaper (if at all) — especially for people developing outside of China.

author: wraper
author_rank: Unknown
timestamp: July 31, 2017, 07:25:48 pm
content: Quote from: Yansi on July 31, 2017, 05:52:49 pmWell, I looked on it briefly. Costs more than twice as much. No internal 5V -> 3.3V regulator, ADC capable inputs are not 5V tolerant. To use it with USB, instead of just a few decoupling caps I would need to use external VREG. ADC is much less versatile, no analog gain adjustment (0.5/1). Only single 1.25V reference voltage (1.65V and 2.4V for UB1). No analog comparator, UB1 has 2 of them, no internal DAC (used with comparators, both inverting and non-inverting inputs). UB1 comparator also has programmable hysteresis.

author: funkathustra
author_rank: Regular Contributor
timestamp: July 31, 2017, 07:33:55 pm
content: Quote from: westfw on July 31, 2017, 10:11:25 amYou have good intuition about that? I don't — and I think a lot of people don't, either. There's a lot ofopinionsfloating around, but not a lot offacts.Is a 24 MHz Cortex-M0 is faster or more efficient than a same-price 72 MHz 8051?Does PIC's super-high clock rate + low-power make it comparable to the more-efficient-clock-cycle AVR? Better? Worse?I know code density is worse on Cortex-M0 chips, but how much worse? What happens when you factor in all the manufacturer-supplied peripheral libraries?Are 16-bit MCUs a "sweet spot" between the 8-bit and 32-bit guys, or just a waste of time? What about weird 16/8-bit hybrids, like the Renesas RL78 that has 8-bit data paths, but a 16-bit ALU?Honestly, is there even a reason to mess with 8- and 16-bit MCUs? Should everyone just use Cortex-M0s for low-end stuff?Which manufacturers have the best IDEs? Code-gen tools? Peripheral libraries?Quote from: westfw on July 31, 2017, 10:11:25 amExcluding the Propeller and XMOS and a few other weird architectures, most every family has a $1 entry on my list, so once you compare the base members, you're good. If you want to compare flash densities or other basic parametrics, just hop on DigiKey or something.Those things don't interest me as much as development environment, code-gen tools, peripheral libraries, development hardware, performance, peripherals, and power consumption — but hey, the Internet is big enough for both of us! Maybe start a parametrics comparison project?

author: funkathustra
author_rank: Regular Contributor
timestamp: July 31, 2017, 07:37:38 pm
content: Quote from: wraper on July 31, 2017, 07:25:48 pmOn the bang-for-your-buck metric, you ain't gonna beat an EFM8UB1. For typical USB full-speed devices, it'snearly perfect.

author: Yansi
author_rank: Super Contributor
timestamp: August 01, 2017, 08:19:28 am
content: Quote from: funkathustra on July 31, 2017, 07:37:38 pmMaybe from the buck point, otherwise no, nope. But it is interesting MCU.What I do not understand is the price point the 32F042 is usually sold at 1-off quantities at the usual distributors. As I do know for what price it is usually sold at quantities (not that large), it is kind of mind boggling. (but not only with this one)

author: coppice
author_rank: Super Contributor
timestamp: August 01, 2017, 09:34:04 am
content: Quote from: westfw on July 31, 2017, 10:11:25 amA real 12-cycle 8051 core is always pretty slow. With a modern single cycle 8051 core code that's heavy in bit banging can be really fast and dense. However, the code looks slower and more bloated as the complexity of the code increases. Try running some C code that uses the full power of the language - lots of structure manipulation, and so on - and 8051 code from the best compilers looks pretty bad. So, speed depends a lot on the kind of code you are running.The PIC is largely in the same category as the 8051, with regard to what it does well and does poorly. The AVR runs most complex C code pretty well.If you think M0 code is less dense, that might reflect the kind of code you have been looking at. Try some serious maths, and the M0 code should look far denser than any PIC or 8051 code. Pretty much anything using the real power of the 32 ALU should result in denser code.One 16 bit core which does hit a sweet spot is the MSP430. It does pretty well on bit banging. It does pretty well on compute. C compiles very well for it. I have seen people get pretty good results with some RL78 devices running full featured C code, but I don't have personal experience.Right now there are quite a few Cortex-M0 devices around, but it will take time for the rich selection of application specific devices available with other cores to be fully replicated by M0 parts. So, during that window 8 bit devices will remain relevant. In the longer term, who knows? Will the M0s hit the same energy efficiency targets as the MSP430 and RL78 families in real world usage (rather than benchmarks)? Will there be a good selection of sub 20 cents M0s?Most hardware manufacturers struggle to take software seriously, even if they know they should. The hardware people tend to look down on software, so there are cultural issues in most companies. Doesn't expect that to change any time soon. You will usually have to use the maker's peripheral library for complex peripherals, like USB or ethernet ports. For simple peripherals the bugs and limitations in most vendor libraries can make them more of a frustration than a benefit. Beyond that, tools can be a rather personal thing. They all have limitations, but which limitations you hit most often can depend on your application and your personal working style.

author: legacy
author_rank: Super Contributor
timestamp: August 01, 2017, 09:46:20 am
content: Quote from: coppice on August 01, 2017, 09:34:04 amIt's the same on 68hc11

author: funkathustra
author_rank: Regular Contributor
timestamp: August 01, 2017, 03:13:50 pm
content: Quote from: coppice on August 01, 2017, 09:34:04 amI was obviously referring to the modern, 1T 8051 cores on my list, like the three-stage pipelined EFM8 ones Silicon Labs makes. The Nuvoton N76 in my lineup is also a 1T 8051, but its instruction timing is quite a bit slower on critical instructions than the EFM8 stuff.Do you have suggestions/recommendations for what, specifically, to run to illustrate this "complex C code"? As far as I understand, struct manipulation is the same thing to a compiler as array manipulation with immediate (const) offsets. Neither the 8051 or AVR has load/store instructions that take an immediate-offset parameter (IIRC? Correct me if I'm wrong!), which means they will perform similarly in this regard (8051 will be a cycle faster than AVR if the data is in RAM, and a cycle slower than the AVR if the data is in XRAM).Quote from: coppice on August 01, 2017, 09:34:04 amSure, obviously, but we're talking about microcontrollers, not GPUs. I'd say that most MCUs I program don't sit around in for() loops running filters all the time.Quote from: coppice on August 01, 2017, 09:34:04 amTotally agree; I had my first experience with the RL78 a few weeks ago, and I really, really enjoy working on it. And unlike the MSP430, it's priced to compete with 8-bit MCUs.

author: wraper
author_rank: Unknown
timestamp: August 01, 2017, 05:07:24 pm
content: Quote from: Yansi on August 01, 2017, 08:19:28 amOf course if you want to process a lot of data it might be not a best option. But it's perfect to build cost efficient HID devices. Like game controllers, joysticks and similar stuff. For example I can have a lot of analog channels sampled pretty fast. And the sweet part is due to built in VREG and versatility of ADC and analog comparators, I can keep the minimal number of additional components required compared to other much more expensive MCUs.

author: coppice
author_rank: Super Contributor
timestamp: August 01, 2017, 05:26:02 pm
content: Quote from: funkathustra on August 01, 2017, 03:13:50 pmNot all 1T 8051 cores are created equal, but the big deal is usually the memory controller. You can be sure the flash isn't keeping up with a 72MHz core. There is no cache to mask that slowness, so the cleverness of the flash controller can be a big deal in extracting good performance.Quote from: funkathustra on August 01, 2017, 03:13:50 pmYou could try compiling something like an open source protocol package. They typically make the 8051 look a bit sick.Quote from: funkathustra on August 01, 2017, 03:13:50 pmA large number of high volume MCU applications involve quite a bit of maths on 16, 32 or 64 bit numbers, although they seldom involve calculating it at high speed. A large number of apps actually drag in several k of floating point software library code, typically to expand the dynamic range of a few divisions. Most MCUs are actually run at way below their rated MHz. It one of the surprises you find when you get visibility of a large number of customer applications.Quote from: funkathustra on August 01, 2017, 03:13:50 pmThe MSP430 competes head on with the RL78 on price, if you buy enough of them. They don't price them very well for small volume applications.

author: wraper
author_rank: Unknown
timestamp: August 01, 2017, 06:04:23 pm
content: Quote from: coppice on August 01, 2017, 05:26:02 pmEFM8 can run directly from flash with up to 25MHz core clock. Anything higher must have prefetch enabled.

author: funkathustra
author_rank: Regular Contributor
timestamp: August 01, 2017, 06:11:36 pm
content: I feel like I came across a lower-cost MCU with 50 MHz flash access recently, but I can't seem to remember which one. Does anyone have any leads?I was thinking it was the Cypress PSoC 4000S, but it looks like it has pretty typical flash memory that requires two wait-states at 48 MHz.

author: Bruce Abbott
author_rank: Frequent Contributor
timestamp: August 01, 2017, 08:53:28 pm
content: Quote from: funkathustra on July 30, 2017, 06:19:30 pmChanging the rules?That particular chip might be out of your (arbitrary) price range, but now you are adding even more limitations. The industry is moving away from 5V, andmany3.3V MCUs are not 5V tolerant on analog inputs - for obvious reasons. Peripherals you don't need are just a waste of silicon and raise the price for no good reason.QuoteThis is silly. A fair comparison would take months if not years, by which time your 'review' will be way out of date.It sounds like you have some specific applications in mind. If so then you should make a short list of chips that have the features youneed, chooseone, and see if it will do the job. Then (if you want to) tell us about it. Bonus points for choosing an obscure MCU that most people wouldn't consider.But if you are just trying to organize a 'shootout' to see which MCU is 'best' then don't bother - unless you have alotof time to waste.

author: wraper
author_rank: Unknown
timestamp: August 01, 2017, 10:45:12 pm
content: Quote from: Bruce Abbott on August 01, 2017, 08:53:28 pmWhich rules? I briefly mentioned what is good in this MCU. You made a post to look for STM32F042. Then I compared them and noticed that STM32F042 is very limited in analog part. Even without analog part, and limited 5V tolerance, lack of 5V-3.3V vreg and much higher price is a showstopper.QuoteUSB provides 5V, just for this reason I want it to be 5V tolerant.QuoteRise of price? Did not notice that for UB1. What is a waste, is need to use numbers of external components which could be avoided. I can connect UB1 to usb directly, connect analog inputs to just anything without circuity to adjust voltage levels and call it a day. Not the case of F042.

author: funkathustra
author_rank: Regular Contributor
timestamp: August 02, 2017, 12:11:25 am
content: Quote from: Bruce Abbott on August 01, 2017, 08:53:28 pmI am not @wraper. I don't care about 5V tolerant inputs. I'm testing everything at 3.3V. Most of these parts are 5V-tolerant digitally, but obviously use clamp diodes which prevents analog signals from getting too hot. Not really testing this, though it's a good idea to mention it — I'll make sure to.The price range is arbitrary, but not unwarranted. If you start going above $1, you start heading off into application-specific land: this part has an LCD controller, that part has better DMA, this part has CAN, that part has QSPI, blah blah blah... I don't want to open that can of worms because:Quote from: Bruce Abbott on August 01, 2017, 08:53:28 pmUnless you limit it to general-purpose MCUs with similar-ish peripherals, and limited test code. Hence, more reasons for $1 price limit.Quote from: Bruce Abbott on August 01, 2017, 08:53:28 pmThis is what I've done every time I've started a new project, but I'm tired of not having data that I can use to make these decisions. Also, I don't have a "specific application" in mind — other than "general purpose, entry-level." Look, I've built surgical robotics motor controllers, data logging platforms, localization systems, embedded Linux systems, deep-low-power underground sensors, and basically everything in between. Please get off your high horse and agree with me that there is a *large* class of embedded designs that my list of $1 general-purpose entry-level MCUs is great for. If you can't agree with that, then I don't know why you're even posting on this thread.Quote from: Bruce Abbott on August 01, 2017, 08:53:28 pmGo away. You're being mean and unhelpful.

author: westfw
author_rank: Super Contributor
timestamp: August 02, 2017, 01:38:57 am
content: QuoteI think I strongly disagree. One of the important factors, even when considered a $1 chip, is the potential for transitioning to a more powerful chip without having to start over. This leads to some depressing facts where you're NOT good if you understand the low end.Consider RAM. None of the 8-bit PIC architecture chips can address more than 4k of RAM. Few 8bit microcontrollers have as much as 16k of on-chip RAM, and even if they're "capable", you start running into restrictions - For example, "such-and-such banking scheme isn't support transparently by anything except xyz compiler", or isn't supported at all... (This applies to program memory as well. I like both the AVR and MSP430s, but neither is something I'd use if I thought I might someday need more than 64k...)Also, between chip complexity and vendor libraries, a lot of the 32bit chips being offered as 8bit replacements (ie the ones that fall in your price range) are a bit disappointing as well. I don't think I believe that a 16k SAMD10 is going to be an adequate replacement for a 16k AVR, for example. The usual answer for ARM chips is "just use a chip with more memory; they're still cheap." That's moderately true, but ... there are no samd10-pinout chips with more than 16k.

author: NorthGuy
author_rank: Super Contributor
timestamp: August 02, 2017, 02:08:34 am
content: Quote from: westfw on August 02, 2017, 01:38:57 amThis is a lot of RAM. You can do a lot with it. There are many projects where you need much less RAM. Of course, it is not enough for graphic LCD controller, but you wouldn't think of building LCD controllers with 8-bit MCUs.

author: funkathustra
author_rank: Regular Contributor
timestamp: August 02, 2017, 03:34:43 am
content: Quote from: westfw on August 02, 2017, 01:38:57 amWhat you're saying is true, and I'm definitely going to mention how much headroom these parts have — but honestly, once you have the base members down, it's just parametrics after that. A 128 KB AVR is going to perform the same way in my testing as an 8 KB AVR. Are you worried about falling in love with a $1 microcontroller that doesn't have much headroom? Total possibility, since some of these families arereallyniche to this price range.But my whole thing with this series is that it's 2017 — code-gen tools are better and easier-to-use than ever, and peripheral libraries are really great, too. Most of the IDEs aren't proprietary anymore, compilers are free, and debuggers and dev boards are <$50. It's obviously not trivial to swap MCUs in the middle of a complex product, but I hope this project encourages people to think of MCUs as commodity items that can be freely selected, without having to pay a huge penalty for working with a new chip.This project isn't about finding the ONE microcontroller to rule them all — I'm not even going to declare a "winner" in this series — instead, it's about getting people comfortable with everything that's out there. And honestly, everything I've done so far is proving that point. I've been banging through a different MCU each night I've been working on it, and only one chip has given me trouble (and, ironically, it's one of my favorite go-to that I've been using for the last two years now for projects in this price range). Everything else has been super straightforward to get up and running. I've been pleasantly surprised by chips I've written off, and getting annoyed by chips I'm super familiar with ("Why isn't that as easy as it was on that new chip I was working with last night...?"). It's been a huge learning experience for myself, and I hope a lot of other people gain a lot of intuition from it.Keep the comments coming!

author: janekm
author_rank: Unknown
timestamp: August 02, 2017, 03:46:11 am
content: For <1$ you've absolutely got to add the Nordic Semi NRF51 to the list... A great little Cortex-M0 which comes with Bluetooth LE (and generic 2.4GHz) radio, the stack for that, pretty great SDK, and great open source (toolchain and library / RTOS) support these days. It's pushing the $1 limit but if you know the right distributor in China it can definitely be done for 100 unitsAnd of course there's the NRF52 range for "headroom".Below that what's fascinating is the STM8S003F3P6 which is the cheapest microcontroller I've been able to find and pretty nice for that (already discussed in this thread). It's <0.2$ which opens up a whole other range of opportunities.

author: funkathustra
author_rank: Regular Contributor
timestamp: August 02, 2017, 04:59:15 am
content: Quote from: janekm on August 02, 2017, 03:46:11 amGreat chip, but totally, definitely, not even close to being <=$1.Quote from: janekm on August 02, 2017, 03:46:11 amI'm actually working through the STM8 review as we speak! Great architecture — much more clock-cycle-efficient than any other 8-bitter that I've tested thus far (unless you count the RL78 an 8-bit MCU, even with its 16-bit ALU).

author: janekm
author_rank: Unknown
timestamp: August 02, 2017, 05:42:13 am
content: Quote from: funkathustra on August 02, 2017, 04:59:15 amThe last quote I got from my distributor was 7.8RMB in December of last year (all my recent projects have been using NRF52...), as far as I know the price has come down a bit since then so I do believe <1$ is possible. I saw a quote of 6.5RMB recently so that would put it over the threshold. Not delivered to outside China, of course, but for Kickstarter pricing etc...You could always give it an "honorable mention" if you think that's too fuzzy, I guessBut while I'm on the topic, we can't forget the ESP8266 either! A little bit of an odd one since you also have to add the EEPROM to the cost but I think it can just squeeze in at <1$:https://item.taobao.com/item.htm?spm=a230r.1.14.18.ebb2eb22ZgRGe&id=532682188102&ns=1&abbucket=2#detail+https://item.taobao.com/item.htm?spm=a230r.1.14.34.ebb2eb2LqPrU2&id=37750426961&ns=1&abbucket=2#detail

author: wraper
author_rank: Unknown
timestamp: August 02, 2017, 06:48:43 am
content: Considering there are a lot of counterfeit nRF24L01 in the wild, I would be concerned about nRF51 too.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 02, 2017, 07:58:39 am
content: Add STM32F103RBT6 to the list too an M3 with huge benefits!https://world.taobao.com/item/42883572952.htm?spm=a312a.7700714.0.0.6419a3bcVpjLuq#detail

author: funkathustra
author_rank: Regular Contributor
timestamp: August 02, 2017, 07:05:06 pm
content: I love Taobao as much as the next guy, but for this series, I'm focusing on general-purpose MCUs from reputable, North American-based distributors, or directly from the company. And I'm trying to find the "best" (obviously subjective!) representative from each family, which typically means the representative from the family that is as close to $1 (without going over).The main reason I'm doing it this way instead of including Taobao/AliExpress/eBay/weird Newark closeout specials is to make sure I'm judging "value" instead of just functionality. If all the parts I'm reviewing cost about the same, it's easy to look across the numbers and the reviews and identify good and bad values. Since a lot of these parts I'm reviewing (like the Nuvoton N76) struggle to hit $1 as it is, if I'm using Taobao pricing, at that point, I'd be comparing a $1 STM32F103 with 15- or 20-cent 8-bit MCUs, which doesn't seem useful for readers.The actual, absolute price isn't particular important, as long as it's consistent across all the families. I could have easily said $2 @ QTY=1, or $0.80 @ 1000 units. It's just that $1 @ 100 units seemed like a nice sweet-spot for general-purpose MCUs.And I think there's still a lot of value when operating with this constraint. For example, I hope that if you read my review of the STM32F0 and end up really liking the peripheral libraries, development ecosystem, and functionality of the part, you'll notice that you can get F103s on Taobao for cheap, and feel confident in the performance, functionality, and ease-of-development you'll get out of the part. That's how the series remains relevant to bigger/fancier chips, as well as making purchases from much cheaper markets.

author: tszaboo
author_rank: Super Contributor
timestamp: August 02, 2017, 08:23:10 pm
content: Quote from: blueskull on August 02, 2017, 05:03:54 amTaobao no good for laowai. Buy digiii key.

author: janekm
author_rank: Unknown
timestamp: August 03, 2017, 01:55:03 am
content: Quote from: funkathustra on August 02, 2017, 07:05:06 pmI think there is still value in mentioning which parts are popular in the Chinese supply chain (and I don't really mean taobao here, it's just useful as a barometer for market prices), since someone looking to choose a <$1 mcu is likely going to have to manufacture there anyway. Though, arguably, if they don't know the market well enough to know what the popular parts are already they probably need to do a bit more research first anyway before trying to build a low-cost product

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: August 03, 2017, 08:34:46 am
content: Quote from: ali_asadzadeh on August 02, 2017, 07:58:39 amAre GD32F103 CPUs on Taobao? I guess they are.. and probably a lot cheaper than STM32, maybe even < $1.

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: August 03, 2017, 11:31:04 am
content: Quote from: blueskull on August 03, 2017, 08:44:42 amNiceAt that price, I don't why I would bother with Cortex M0, 8 or 16 bitters, unless I had special requirements. I'm not quite ready to dive in to Taobao, maybe I should! I haven't been able to find GD32 outside of a few special distributors, nor even ebay or Aliexpress.

author: brucehoult
author_rank: Super Contributor
timestamp: August 03, 2017, 03:23:04 pm
content: Quote from: funkathustra on July 31, 2017, 07:33:55 pmWorse than what? Other Thumb2 chips? AVR?Over the years, with programming many different architectures, I've come to the conclusion that 16 bit *instructions* are very much in a sweet spot, either fixed size, or with a way to escape to the occasional 32 bit instruction. That's regardless of whether the registers and data are 8 bit (AVR), 16 bit (PDP11 ), 32 bit (Thumb/Thumb2, RISC-V32C), or 64 bit (RISC-V64C).32 bit instructions just have too much generality and wasted space. Sometimes you can use all the power (and aarch64 does a pretty good job), but sometimes you only want to negate a register and 32 bits is a waste for that.Instructions based on 8 bit units seem like they should be better, especially as they can be better Huffman coded than instructions with larger granularity, but it just doesn't work out that way in practice, at least for x86, VAX, z80, 6502 etc. Thumb fits a 3-address add or subtract (destination register, and two source registers) into a two byte instruction. Both VAX and x86 need four bytes to do that. If the destination is the same as one operand then x86 can also do it in two bytes, but VAX needs three. 6502 needs 6 bytes (assuming 8 bit data and sources and destination in Zero Page). 8080/z80 need three bytes, assuming both operands and the destination are registers other than A (mov a,src1; add src2; mv dst,a). the actual instructions are all 16 bit, but some addressing modes have a side effect of loading an immediate or offset and advancing the PC

author: Bruce Abbott
author_rank: Frequent Contributor
timestamp: August 03, 2017, 05:29:32 pm
content: Quote from: brucehoult on August 03, 2017, 03:23:04 pmThis has less to do with instruction size than it does about which instructions are prioritized. The 8080 and Z80 waste most of their base opcodes doing 8 bit register to register transfers, then on the Z80 they had to add prefixes to expand the opcode range.The Z80 is is quite frustrating because many of the enhanced instructions have a cost far exceeding expectations. For example, here are 4 different ways to store the contents of the BC register in memory address $1234:-Code:1. copy B to A and C to A, store direct79ld a,c32 34 12ld (addr),a78ld a,b32 35 12ld (addr+1),a2. store BC directED 43 34 12ld (addr),bc3. using HL as a pointer21 34 12ld hl,addr71ld (hl),c23inc hl70ld (hl),b4. using IX as a pointer with offset (IX preloaded with base address)DD 71 00ld (ix+0),cDD 70 01ld (ix+1),b2. is the shortest and most efficient, but could be even shorter if it didn't need the 'ED' prefix.4. is the most versatile and convenient, but again wastes bytes on prefixes. And since indexed instructions work on 8 bit quantities only (no "ld (ix+0), bc") the code is 3 times the size it could be.

author: westfw
author_rank: Super Contributor
timestamp: August 03, 2017, 06:22:35 pm
content: QuoteSomewhat agree...QuoteWhether "wasted space" is a problem is a technology issue. My favorite instruction set of all time used a 36bit instruction word. A memory/register architecture, each instruction had 9bits of opcode, 4 bits of register address, 4 bits of index register, and 18bits of "offset" (or constant.) It had MANY no-op instructions, 64 system call instructions (half for user-implemented instructions...QuoteWell, mostly it doesn't. Thumb has about 2 instructions (add and sub) that fit all three operands into 16bits. And even then, it's done by reducing the number of registers that can be access to only 8. (if 16bits is a sweet spot for instruction size, I think 16 is the sweet spot for usable registers (perhaps including PC, SP, and PSW.) The whole "compress a 32bit instruction into 16bits" thing is clever, but I wish it had been a less "lossy" compression. The CM0 (with only 16bit thumb instructions) is pretty ugly - if users hadn't been lulled into a sense of comfort by the full 32bit arm instructions and the less lossy Thumb-2 instructions, they wouldn't have been impressed :-( (It's hidden by compilers and obscured by documentation, but if you try to program a CM0 in assembly language, or start actually look at the code your compiler produces, you quickly run into "this instruction form isn't supported" or "this offset/immediate value has a very limited range" and such. grr.)Quote(ah - quite similar to the Thumb problem...)Yeah; that was one of the two big nails in the coffin for classic CISC architectures. (the other one was that compiler writers couldn't figure out how to make generic compilers USE all the fancy instructions. The previously-mentioned 36bit CPU added enhanced string and bcd instructions at one point, but they required that you set up 4 to 6 register beforehand, and didn't really execute any faster than a tight loop of simpler instructions...

author: brucehoult
author_rank: Super Contributor
timestamp: August 03, 2017, 06:44:23 pm
content: Quote from: Bruce Abbott on August 03, 2017, 05:29:32 pmYes.Instructions that are byte-encoded *would* allow you to Huffman code the instructions (i.e. giving the most frequently used instructions the shortest opcodes, and give seldom-used things longer opcodes). But in fact they all failed to do that. Instead, they gave the instructions that need the fewest arguments or have the fewest options the shortest encodings -- because they don't seem to "need" more -- regardless of how infrequently they are used.The absolutely classic example is the 8086's AAA instruction: Ascii Adjust AL After Addition, opcode 0x37. This is an instruction so frequently used that gcc doesn't even know how to emit it (without inline assembly language, at least). And yet it and its friends AAS (0x3F), DAA (0x27), DAS (0x2F) together take up 1/64 or 1.56% of the single byte instructions.I guarantee they don't make up 1.56% of instructions in most programs.Similarly, does HLT (0xF4) really need a 1 byte opcode? Or the instructions to set or clear carry/interrupt/direction (0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD). Or Complement Carry Flag (0xF5)?That's 12 instructions now ... 4.7% of the opcode space. Every one of which could have happily had a two or three byte opcode without causing any real program a size problem.There are plenty of examples left!

author: brucehoult
author_rank: Super Contributor
timestamp: August 03, 2017, 08:07:22 pm
content: Quote from: westfw on August 03, 2017, 06:22:35 pm16 or 32 registers total is good, but it's usually not too hard for a compiler to get all the important variables in a loop of even many functions into 8 registers.Add and subtract are by far the most arithmetic operations in programs, especially when including add and subtract of small constant values, which Thumb also gets all three operands (a = b +/- const) into 16 bits, provided const is less than 8. Other arithmetic such as boolean operations AND, OR, EOR shifts LSL, LSR, ASR, ROR and add and subtract with carry can only do a = a op b which means you will sometimes need to do a MOV a = c first, but they are not so common.These restrictions are a bit annoying if you are programming in assembly language, where you like a very orthogonal instruction set, but compilers can easily deal with them.QuoteUgh .. yes. Original Thumb was never intended to be the only instruction set available. There are so many system management things that aren't included at all, and even things such as 32x32->64 multiply.Thumb2 is much nicer in that way, but because it was hacked in later it has an absolutely awful instruction encoding. I can understand 6502 programs quite well directly from a hex dump. Don't try to do that with Thumb2!

author: janekm
author_rank: Unknown
timestamp: August 04, 2017, 03:40:17 am
content: Quote from: blueskull on August 03, 2017, 08:44:42 amThough funny enough you can find STM32F103 for less... I think ST are effectively price dumping to keep that competition in check.

author: funkathustra
author_rank: Regular Contributor
timestamp: November 06, 2017, 12:41:16 am
content: In case anyone was wondering if I ever got around to finishing this write-up, the answer is "Yes! Finally!"Check outThe Amazing $1 Microcontrolleron my blog.It took several months of on- and off-again work, but I got through all 21 parts I selected.I'd like to thank everyone on this thread for their help --- I got some excellent part recommendations --- but even better, I got feedback on some areas to focus on, too.If there are things you think need to be mentioned that I'm forgetting, please drop a line on this thread (or, shamelessly plugging my blog, as a comment on this post)Thanks again for the wonderful discussions!

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: November 06, 2017, 01:23:20 am
content: Quote from: funkathustra on November 06, 2017, 12:41:16 amHoly crap that must have been a huge amount of work!One thing I noticed - in the ISR latency figures, the PIC32MM came in quite high - was this using the shadow register bank ? (They annoyingly left this off the 32MX1xx devices, but makes a big difference where you have a high interrupt rate).This is not especially well documented, and ISTR there's a non-obvious register setting (PRISS) that needs setting as well as the IPLxSRS attribute in the ISR declaration.One other point under "Usual Microchip advantages", though not a property of the chip per se, can be very relevant when looking at overall cost and conveneience - low-cost preprogramming service via MicrochipDirect - I think some of the Atmel parts are also available on the service now. For the smaller chips it's just a few cents to program, mark and re-reel.

author: funkathustra
author_rank: Regular Contributor
timestamp: November 06, 2017, 01:42:45 am
content: Quote from: mikeselectricstuff on November 06, 2017, 01:23:20 amWow — I had no idea this was a thing. I'll look into this at some point in the future and get back to you — otherwise, feel free to submit a pull-request (all the code is over on GitHub) if this is an easy change.Quote from: mikeselectricstuff on November 06, 2017, 01:23:20 amThis is a good point! Though, from my experience, basically everyone does this these days — at least the vendors I've used on recent volume products.I think Microchip was one of the first, though — I'm almost positive I mention that somewhere buried deep in the PIC16 review, I think.Thanks for the feedback!

author: coppice
author_rank: Super Contributor
timestamp: November 06, 2017, 01:54:47 am
content: Quote from: funkathustra on November 06, 2017, 12:41:16 amA lot of good work has gone into producing that page. A key issue I see is how you determined relative pricing. 100 is such a low number that it really skews your impression of relative pricing. At the 100 level prices are almost random. You might have seen a saner set of relative prices if you had used, say, widely published 10k prices. Those are still not always representative of what a little negotiation or a higher volume might get you, but at least it gets you away from the silly prices you get at the 100 level.If a part looks rather expensive compared to its competition you are either missing is special qualities, or seeing the wrong price. Seriously overly expensive parts seldom reach the market.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: November 06, 2017, 01:57:28 am
content: Quote from: funkathustra on November 06, 2017, 01:42:45 amThis is declared in the ISR handler as :void __ISR(_UART2_RX_VECTOR,IPL7SRS) uartint(void)And you also need to tell it which int priority uses the SRS :PRISS=0x10000000; //ipl7 use SRS1I don't know if Microchip's code-gen stuff supports this as I have a pathological hatred of all manufacturer-supplied libraries, code generators etc. due to having spent way too much time tracking down bugs in them, or spending more time figuring out how to use them than it would have taken to just RTFDS and do it manually!

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: November 06, 2017, 02:06:53 am
content: QuoteMicrochip are unusual in that they are one of the few ( only?) MCU makers who supply direct in smaller quantities, so programming is a simple add-on to that.Some distributors offer programming, but there can be issues like prohibitive cost ( especially for smaller parts where it can cost more than the part), limited part/package coverage, and stupid export control issues ( Digikey won't ship programmed parts outside the US as they don't know if the code implements export-controlled encryption etc.)I don't know of any other supplier where you can set up programming jobs and order parts online with a fairly low MOQ ( ISTR it's either 150 parts or $150 value), and get them in a few days.

author: coppice
author_rank: Super Contributor
timestamp: November 06, 2017, 02:49:55 am
content: Quote from: mikeselectricstuff on November 06, 2017, 02:06:53 amIf you want pre-programmed devices done well, you want them programmed during assembly and test. If they are programmed later, SO, QFP and other packages with flimsy legs show a substantially increased rate of defects due to bent legs. It appears Microchip have set themselves up to do this for modest volumes. Most people only do it for serious volumes. I think pretty much any supplier of flash MCU will program them at the factory when you buy millions.Quote from: mikeselectricstuff on November 06, 2017, 02:06:53 amDon't forget that increased defect rate. It hits some people quite hard. If you can't get things programmed at the factory its best to program them after board assembly, to minimise the handling steps.

author: NorthGuy
author_rank: Super Contributor
timestamp: November 06, 2017, 03:41:23 am
content: Interesting review.IMHO, instead of comparing CPU frequencies, then comparing toggle rates in cycles, it would be more useful to compare toggle rates in real-time terms (in us).

author: EEVblog
author_rank: Unknown
timestamp: November 06, 2017, 07:16:57 am
content: EPIC amount of work!https://jaycarlson.net/microcontrollers/

author: jaromir
author_rank: Unknown
timestamp: November 06, 2017, 10:46:07 am
content: Now that's massive amount of work put into this preview. Looks like it's popular, your server is unavailable at times in last few hours.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: November 06, 2017, 11:19:30 am
content: Quote..er isn't that kinda the point of a FIFO'd UART?or do you mean they have worse latency when the FIFO is disabled/set to minimum?

author: funkathustra
author_rank: Regular Contributor
timestamp: November 06, 2017, 11:32:15 am
content: Quote from: mikeselectricstuff on November 06, 2017, 11:19:30 amI meant that first-byte ISRs with the FIFO enabled seem to have slightly worse latency (a few cycles) than ISRs from regular, FIFOless UARTs.ISR latency is caused by prologue code (especially heavy on stack-based parts like AVR and Arm), core design, but also peripherals. From my testing, it looks like a lot of parts with FIFOs had additional ISR latency when compared to parts without FIFOs (of course, I'm assuming the ISR is set to trigger on the first byte received). I mostly used the FIFO functionality to slow down the core — sitting in a while() loop, processing FIFO bytes is a lot faster than exiting and re-entering the ISR.Keep in mind that I didn't do what you usually do with FIFOs — set up an ISR to trigger after they're already full. This was mainly because many FIFOs had strange policies when it came to bytes received with framing errors (which is what I use to detect the start of frame for DMX-512).I suspect the FIFO-enabled UARTs have a bit more register transfer stuff they have to do, which ends up adding in a few extra cycles before they can assert the interrupt signal — but that's just a guess.I'm comparing among the Arm parts, which all have the same core and should have relatively similar prologue code before hitting the register (this second assumption might not be entirely true, though, now that I think about it).There's better ways to isolate and test for this (with "naked" declarations for the ISRs), and admittedly I didn't have time to do this.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: November 06, 2017, 11:48:41 am
content: Quote from: funkathustra on November 06, 2017, 11:32:15 amOh, yeah, been there, done that!Definitely something you need to test as it's rarely mentioned in the datasheet.ISTR some particularly fun times with a NXP part that had seperate ints for UART receive and UART errors, which only manifested with one Artnet device that put the break immediately after the last byte, so it ended up somewhere in the FIFO.Latency on a FIFO's UARTs is very rarely an issue in practice - what I find more annoying is UARTs like the PIC32 which don't have a timeout mechanism to empty the FIFO at the end of a burst of data, so you end up needing to dedicate a hardware timer to do it.

author: mariush
author_rank: Super Contributor
timestamp: November 06, 2017, 11:49:49 am
content: For those impatient, looks like there's an archive.org copy of the long article / website here :https://web.archive.org/web/20171106070102/https://jaycarlson.net/microcontrollers/

author: JPortici
author_rank: Super Contributor
timestamp: November 06, 2017, 11:51:52 am
content: AmazingI have some render issues though (firefox 56.0.2 under win 7 pro, 1920x1080p)as a long time PIC afficionado i'll make one note for the article:for the PIC18F, the "K" series is the one which is actually being developed. the K42 and K83 families (the most recents, came out this year) are the real BEASTS in terms of PIC18 (DMA, vectored interrupt, fully routable PPS, more memory, 12 bit adc with good ENOB, channel scan, digital filters etc., the K83 also has CAN compared to the K42)(and of course everything is pin-to-pin compatible between families.. from different PIC16s up to dsPICs, but with some minor adjustments from 8bit to 16 bit)

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: November 06, 2017, 01:01:13 pm
content: It's a big thumbs up, I think you should have added the 1$ cortex M3 parts like STM32F103RBT6 to the list too, it would be more fair then

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: November 06, 2017, 01:03:22 pm
content: Quote from: funkathustra on November 06, 2017, 12:41:16 amGreat report! And nicely presented too. The overall impressions are similar to what I have got from personal experience or reading other people's experiences. It would be nice to see a ranking by price, even if rough/relative guidance. I have reasonable flexibility to select parts based on dev tools, IDE etc, but price is the #1 for the operations manager.A couple very minor typos "choke-full" => "chock-full", "weary" => "wary", although the homophones are appropriate too.

author: NorthGuy
author_rank: Super Contributor
timestamp: November 06, 2017, 04:08:06 pm
content: Quote from: funkathustra on November 06, 2017, 11:32:15 amPrologue code is 80% (if not more) of the latency. So, the latency measurements are mostly the measure of efficiency of C optimizations of the particular compiler. BTW: toggle times too, to certain degree, evaluate the C compiler quality.The UART module, if it includes hardware FIFO between the receiver and the MCU core, will produce interrupt not when the character is received, but when it is placed into FIFO, which comes later. So, ideally, if you want to measure interrupt latency per se, you must start your measurement from FIFO (which is not really possible).

author: Boscoe
author_rank: Frequent Contributor
timestamp: November 06, 2017, 05:11:34 pm
content: Someone might have already posted this...https://jaycarlson.net/microcontrollers/

author: Howardlong
author_rank: Super Contributor
timestamp: November 06, 2017, 09:26:42 pm
content: Congratulations on such a huge undertaking!I noted that you included a Code Generator section. Do folk really use these for production code? OK, when you need to use complex peripherals, like USB, for some devices it’s the only thing the vendor offers, but for more mundane peripherals like SPI, I2C, UARTs, PWM, really? You’re going to have to understand the device at the peripheral register and hardware level anyway, so what value do they add perhaps beyond short term instant gratification?The two I have the most experience with by a long chalk are Microchip’s MHC and MCC. Both are bug ridden, and both make code incredibly difficult to maintain as the programmer’s business logic (and code genrator bug fixes) are mixed in with the generated code. So if you change, say, a pin assignment, it regenerates the code and you risk it stamping all over your own code. Moving between versions often means you have to start from scratch too. I also despise the proprietary straightjacket directory and file structure it places you under.Maybe others have better experiences of Code Generators than I do?

author: nctnico
author_rank: Super Contributor
timestamp: November 06, 2017, 09:50:03 pm
content: I'm wondering why there is so much difference between the performance of STM32F0 and the LPC811. Given the small difference in clock frequency I'd expect them to be much closer. Is this due to compiler optimisation perhaps? What would be an interesting addition to this test is a comparison of code density and speed between the various compilers.

author: dgtl
author_rank: Regular Contributor
timestamp: November 06, 2017, 10:31:15 pm
content: An awesome work! Thank you!Not being a fanboy of PSOC myself, I tried to implement the 1wire master in UDBs in my spare time and went low-level on PSOC. Actually, the registers datasheet is public ("Register TRM", about 5500 pages!) and the bitstream is actually just an array of registers, not a black box. Getting to the bottom of it to understand what is where took about 1 week of evening reading. Each UDB has some registers in the configuration space and some in runtime space. But this is so complex, that the uc would be of very little use without the psoc creator software, developing on that without tools would be a nightmare. Also, the definitions of the runtime registers depend on the configuration set up at boot and thus the register datasheet is quite useless without decoding the inner workings of the generated peripherals (simple for SCB, a lot of reverse engineering for UDB). In addition, nothing stays put in that chip, things can be re-routed differently and absolute addresses are useless; at least have to use the auto-generated defines made by the placer. All in all, pretty useless going low level unless there is a niche application, that needs some kind of tricky interface and FPGA would be too large.

author: funkathustra
author_rank: Regular Contributor
timestamp: November 06, 2017, 10:48:21 pm
content: Quote from: nctnico on November 06, 2017, 09:53:04 pmIn my testing, I discovered the big problem with the LPC811 is the lack of a flash accelerator/caching mechanism (or if it has one, it's not very good). Flash memory for these parts typically tops out at 25 MHz, so the nice 48 MHz Arm parts all have good caching capabilities (IIRC, the SAM D10 and Kinetis KL03 were the best, but the STM32F0 did well, too).If you ever want to see if that's what's going on, reduce your core clock speed and count cycles — if your code magically takes fewer cycles at slower clock speeds, look at flash wait-states.The higher-end LPC parts are lovely to work with — but I was stuck reviewing bottom-of-the-barrel parts due to the $1 price constraint. I like MCUXpresso a lot, and the NXP folks are helpful to work with — especially for start-ups/small players. I just wish they had some better entry-level parts.Infineon, for what it's worth, has equally-bad (if not worse) flash-constricted performance on the XMC1100 — but the part has16 KB of RAM, so you can just decorate your ISRs and any other performance-critical work with "place in RAM" attributes, and you'll be running at full speed — and with excellent power consumption.

author: funkathustra
author_rank: Regular Contributor
timestamp: November 06, 2017, 11:11:30 pm
content: Quote from: Howardlong on November 06, 2017, 09:26:42 pmThanks! Glad to see people are learning and starting conversations from it.Quote from: Howardlong on November 06, 2017, 09:26:42 pmIn my experience, I see start-ups and R&D teams using code generators all the time, because they're not an "Atmel shop" or an "Infineon shop" — and, for small-volume or R&D work, code generators let you get quick access to the stuff you selected the part for (say, the PIC16's NCO/CLC stuff), without having to futz around with UART baud-rate generator settings and clock-gating. This is especially true in the 32-bit space.When engineering consultants can cost a company north of $200/hr, do you really want to pay an engineer to sit around and read datasheets, or do you want to use a slightly faster part that allows them to quickly build up the demo for the investors meeting?Quote from: Howardlong on November 06, 2017, 09:26:42 pmI had admittedly limited surface-area contact with the code-gen tools in my review, but I didn't notice any outright bugs in the generated code for my DMX-512 receiver, which has to do UART, PWM, and any secondary function (pin muxing, clock gating, timer init, etc).There are some design decisions I would probably change, but that's a give-and-take that different vendors land on.The biggest bugs were with Atmel START on the SAM D10 — which didn't provide any modicum of error-checking, and statically displayed a "48 MHz" label under the DFLL, regardless of what it was actually configured to use.As for the "hard to maintain" argument, the best code-gen tools had no issues with this. For example, Silicon Labs' Simplicity Configurator has no problems adding/modifying/removing ISRs in the same files that had my custom code. ST and Renesas, too --- albeit they cheat a bit and have comment blocks that define precise locations where you can and cannot put user code.The worst offenders for what you were talking about were probably Microchip and Atmel — their code-gen tools seem incapable of merging their changes with custom-written code.It sounds like you have experience with Microchip; one of my goals of this review is to illustrate how other ecosystems work, so people don't accidentally generalize their understanding of a function across every possible product line.For what it's worth, the most efficient (in terms of speed and/or flash) code for the DMX-512 receiver was generated by code-gen tools, compared to those from just standard runtime peripheral libraries.Intuitively, it seems to make sense: runtime libraries have to calculate a bunch of crap that's known at compile time. Theoretically, the optimizer should be able to get in there and eliminate a bunch of that stuff, but in practice, this doesn't happen as much as you'd think.A code-gen tool that just spits out a bunch of raw register writes in an init function for a UART is always going to beat a run-time UART initialization library that calculates baud-rate generator registers on the fly, for example.

author: HwAoRrDk
author_rank: Super Contributor
timestamp: November 07, 2017, 12:00:08 am
content: This guide is awesome. Thank you!I spent a couple of hours today reading. I'm definitely going to come back to this next project I do needing an 8-bit MCU.By the way, I noticed a problem with the standard peripheral library code example on theSTM8 page. It has HTML mixed into the code in a couple of places, e.g.:Code:while (!I2C_CheckEvent(I2C_EVENT_MASTER_ADDRESS_ACKED));I2C_ClearFlag(I2C_FLAG_ADDRESSSENTMATCHED);I2C_SendData<sup id="footnote_plugin_tooltip_1" class="footnote_plugin_tooltip_text" onclick="footnote_moveToAnchor('footnote_plugin_reference_1');">1</sup><span class="footnote_tooltip" id="footnote_plugin_tooltip_text_1">u8)(ReadAddr >> 8</span>%MINIFYHTML9299bf39575ecf70dee23834ee18551524%; /* MSB */while (!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED));Looks like your footnotes plug-in has run amok.

author: funkathustra
author_rank: Regular Contributor
timestamp: November 07, 2017, 12:17:29 am
content: Quote from: HwAoRrDk on November 07, 2017, 12:00:08 amNice catch! Fixed; should be pushed out soon.I thought the (( )) footnote parsing syntax was too good to be true, and now I know...

author: westfw
author_rank: Super Contributor
timestamp: November 07, 2017, 06:22:26 am
content: QuoteIndeed. This is a much more impressive result than what I was expecting from the initial discussions!

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: November 07, 2017, 09:55:44 am
content: Quote from: ali_asadzadeh on November 06, 2017, 01:01:13 pmThey are only $1 in Shenzen... Typical western SMEs are ordering large volumes via reputable distributors such as Avnet, Arrow etc, smaller volumes from Digikey, Mousers (or national equivalent). Ordering via AliExpress or Taobao for production stock is simply not an option for the companies I work for.The code is available, you can always port it to a STM32F103 board and create a report. It would be interesting to know how much an M3 buys over a M0. My suspicion is that M0 is just a market positioning to compete with 8 bitters, if you take an M3 and run it at lower clock speeds it will be nearly identical to an M0 in terms of performance and power consumption. I understand the license fees to silicon vendors for M0 core design are ridiculously cheap.

author: tszaboo
author_rank: Super Contributor
timestamp: November 07, 2017, 10:40:56 am
content: Quote from: donotdespisethesnake on November 07, 2017, 09:55:44 amUnder the hood, there are huge differences between M0 and M3.For example M0 is Neumann architecture, M3 is Harvard.M0 has 2 stage pipeline M3 has 3 stage, and their DMIPS is like 1.5 times higher.Sure, this doesnt matter for flipping bits and sending stuff through UART, because if that is all you do, then it is easy, just use an M0.

author: Whales
author_rank: Super Contributor
timestamp: November 07, 2017, 10:50:00 am
content: My light hobbyist foray into the micro world scarred me. Expensive programmers and crazy toolchains. I expected everything to be supported by GCC and programmable via a simple protocol atop UART.Haha. Ha. Ha. Avrdude you have spoiled me.I now want to try one of those STC8's8051 sounds like a nice option simply because of the interchangeability. I'll also give LCSC a go.funkathustra: thankyou for your investigations and your writeup. I've previously looked for 8051 parts and only found ancient low-stock microprocessors. You have cleared several clouds for me.

author: josip
author_rank: Regular Contributor
timestamp: November 07, 2017, 01:53:07 pm
content: funkathustra,BTW, all MSP430 FRAM devices are with 20-bit CPUXv2, with some 20-bit / 1 cycle (address) assembler instructions. They are also limited by FRAM wait states, but code can be copied to RAM and executed at full speed.I didn't noticed on your (remarkable) page any data regarding flashing erase/write rate. It is more comfortable to work with devices with faster operations, and there is significant difference between vendors. For example, some reference can be found here...https://www.segger.com/products/debug-probes/j-link/technology/flash-download/#tab-3145-1

author: Howardlong
author_rank: Super Contributor
timestamp: November 07, 2017, 03:10:21 pm
content: Quote from: funkathustra on November 06, 2017, 11:11:30 pmI think my favourite method would be for these code generators to just give me a set of code on demand that I can copy and paste into _my_ directory and file structure, not theirs. I don't see any value in being nanny-stated into a generic "framework" which will always be a compromise, being too complex for simple projects, and unnecessarily prescriptive for larger ones.A code generator that dictates a framework must be able to manage and separate clearly between user code and its own code, and deal with bug fixes to generated code, MCC doesn't do that well at all.There are many bugs in MCC, the worst I've encountered was that it initialised a particular peripheral's registers in the wrong order. This is quite common, where you cannot legally change certain peripheral settings after it's been turned on, but the ON bit is one of the first things it sets. The particular scenario I had was a little more complex, but you get the gist. I'd also prefer that there was an option for the generator write code as bitfields or mask macros, rather than a series of opaque hex blobs that each might cover a dozen or so configuration parameters that are not easy to match up with the datasheet when you're trying to figure out why it doesn't work.A particular problem that afflicts MCC is that newly adopted devices tend to be left to the community to test on behalf of Microchip, there rarely seems to be any testing of any sort done, it's not uncommon to be unable to even start the oscillator.I had one a few days ago where it failed to disable the JTAG interface that was shared with a number of GPIOs I was using as status LEDs, as a demonstration for someone on how to use MCC, even though I'd warned against it. Had I written the code myself, this simply would not have happened, and even it had, I'd have had transparency and understanding rather than second guessing some half baked code.

author: MT
author_rank: Super Contributor
timestamp: November 07, 2017, 03:33:15 pm
content: I recall every week there is at least one person reporting bugs created by Cube MX.@funkathustraGreat report but the "timer points" dont reflect on timers ability to IRQ/DRQ which could be considered equally important as having a CC channel. F4 for instance are plagued by crappy IRQ/DRQ assignment which makes even simple DMA sequencing a pain and in many cases impossible (conflicting GPIO assignments and or Timers dont have DRQ at all or are assigned on the wrong DMA unit).Another important factor are "pin routing ability" PIC24 excels STM32 in many cases for instance, even the F0 is quite crap at this. Just my 1/2 cent!

author: josip
author_rank: Regular Contributor
timestamp: November 07, 2017, 07:33:15 pm
content: Quote from: MT on November 07, 2017, 03:33:15 pmThis is one of most important things to me. Thatanyport /peripheral / analog signal can be routed toanydevice pin. And that one peripheral output (for example timer pwm) can be routed tomultipledevice output pins. Didn't found vendor that support this on Cortex M0 / M0+ / M3 / M4 devices.

author: nctnico
author_rank: Super Contributor
timestamp: November 07, 2017, 08:10:18 pm
content: Quote from: josip on November 07, 2017, 07:33:15 pmNXP does on their LPC1500 series. Then again being able to route pins to any I/O is highly overrated. The pins which belong together are usually grouped anyway so if you think a bit about the PCB layout while drawing the schematic you can come up with a good component placement and thus easely routable PCB design.

author: josip
author_rank: Regular Contributor
timestamp: November 07, 2017, 08:24:19 pm
content: Quote from: nctnico on November 07, 2017, 08:10:18 pmNo, it is not related to PCB layout. Let say that I am using one port (with 8 IO lines) in one short period of time like input/output, and in another short period of time as timer pwm output, and switching between two mods. I want to read / write with one assembler instruction from / to all 8 IO lines, not in 5 instructions because timer pwm outputs are distributed on 5 different ports (addresses). I am spoiled with TI MSP430F5xx family that have one port (8 lines) with all peripherals mapped on it. On TI MSP432 there are 3 ports (24 lines) with all peripherals mapped on it. Unfortunately, didn't found similar thing on low cost M0+/M3 from other vendors.

author: nctnico
author_rank: Super Contributor
timestamp: November 07, 2017, 08:41:37 pm
content: I still don't get why you can't solve your problem with carefully selecting the I/O lines. I know NXP ARM devices inside out and they have the I/O pins on a few ports which are packed with pins (except for the last port).

author: thm_w
author_rank: Super Contributor
timestamp: November 07, 2017, 10:12:23 pm
content: Quote from: MT on November 07, 2017, 03:33:15 pmIts not that bad..

author: MT
author_rank: Super Contributor
timestamp: November 07, 2017, 11:18:57 pm
content: Quote from: thm_w on November 07, 2017, 10:12:23 pmYes it is! Sometimes it's close to 3 bugs a week!Quote from: josip on November 07, 2017, 07:33:15 pmRecall the old F100 could have multiple peripherals on at the same time on same pin.Quote from: nctnico on November 07, 2017, 08:10:18 pmOverrated perhaps but with STM32 things arent even pin compatible per package, and the pin mapping is quite badily done, loads of peripherals conflicts with each other particularly timers.QuoteUnfortunately with STM32 thats not the case, many peripherals are spread out on all the sides just inviting for cross-talks and problematic layouts.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: November 08, 2017, 06:32:52 am
content: Quote from: josip on November 07, 2017, 07:33:15 pmSome of the more recent PIC8s ( e.g. 16F153xx) can also route any peripheral function to any pin.This is an extremely useful feature, especially on 2-layer PCBs. PIC32MX isn't quite as flexible, but as there are multiples of most peripherals, between choosing which of the peripherals and the pin mapping you have a lot of flexibility.From memory I think that on the 32MM, one of a pair of peripheral is fixed an the other is mappable to any pin.

author: ebclr
author_rank: Super Contributor
timestamp: November 08, 2017, 07:00:06 am
content: "Anything I'm missing? Thanks!"https://direct.nuvoton.comN76E885AT28N79E715AS16N76E885AT20N79E715AT20N79E715AT28N76E616AL48N76E003AT20N79E8432ASGMini51FDEMini52FDEMini54FDE

author: coppice
author_rank: Super Contributor
timestamp: November 08, 2017, 11:25:25 am
content: Quote from: MT on November 07, 2017, 03:33:15 pmThe presence of pin routing is mostly a matter of when the design started. Across the industry pin routing was quite limited, then suddenly it became flavour of the month to have extensive programmable pin routing. It doesn't cost much die area to add this to a fine geometry MCU, at least for digital pins which are not pushing any speed limits. Going forward I think you can expect this to be an almost universal feature for lowish speed digital peripheral pins.

author: tszaboo
author_rank: Super Contributor
timestamp: November 08, 2017, 01:03:12 pm
content: Quote from: MT on November 07, 2017, 11:18:57 pmWhile I quite like the ST microcontrollers, it is an absolute nightmare to route them. For example an SPI port can be on 3 sides of the micro. Going to an ADC, and driving it with 20-40MHz clock. Or there was one time, probably the last, when I routed a SRAM into a ST micro part. All 4 sides. Criss-crossing with the Ethernet controller RMII lines, and the USB. For some reason, on a 4 layer board, we couldn't run the SRAM at the advertised speed. I wonder why.And the 32F103. OK it has USB and CAN. I designed the board, so it uses both of them. They are on the same pins, but you can re-map the CAN. So no problems, rigth? Well the firmware programmer found hidden on page 15894 of the reference manual, in the footnote in brackets with smaller font size, that:(*Ah, yes, BTW the USB and the CAN are using the same memory space for some reason. They cannot be used at the same time. Sucks to be you!)

author: cv007
author_rank: Frequent Contributor
timestamp: November 08, 2017, 07:45:14 pm
content: QuoteThey still do have port restrictions on the higher pin count devices- like a 28pin 16F18854 for example each in/out peripheral will be restricted to 2 of the available ports (it varies which 2). Which still is quite good. It is a very nice feature to have (and probably necessary with the many peripherals they have on these newer devices).Another nice piece of info to have with these micro comparisons, is the source/sink current per pin and totals.

author: technix
author_rank: Super Contributor
timestamp: November 09, 2017, 06:49:54 pm
content: Since you mentioned STC, the STC15W100 I’m SO-8 is close to 10 US cents each (12?)

author: JPortici
author_rank: Super Contributor
timestamp: November 09, 2017, 07:00:56 pm
content: Quote from: cv007 on November 08, 2017, 07:45:14 pmi am FINALLY evaluating the 18F K42 series. The ADC is impressive but has some quirks i haven't understood (i wish it had channel scan tho). The PPS is a blessing. Many other new peripherals since the K22 are so ugggh, awesome.And if you need that, programmable drive strenght and current source-sink per pin or per port (i don't have the datasheet open)

author: igendel
author_rank: Frequent Contributor
timestamp: November 10, 2017, 12:40:32 pm
content: Quote from: funkathustra on July 30, 2017, 06:19:30 pmWell, I'm reading the review now (it was published on the "Microchip Makes" facebook page) and it's fascinating. Excellent work!

author: janekm
author_rank: Unknown
timestamp: November 11, 2017, 03:26:10 am
content: Really amazing review, I'm in awe of the amount of work you put into it! Definitely a resource I will recommend to others.Quote from: technix on November 09, 2017, 06:49:54 pmIs it? On taobao I'm seeing pricing between 1.2-2RMB (indicative of course, but works as a first approximation).Nuvoton N76E003AT20, a part pin-compatible to the stm8s003f3p6, is showing for 0.76-1RMB (I just asked one of the shop keepers, they're fine with selling 10 at 0.76RMB, around $0.11 currently... 9 for $1).

author: janekm
author_rank: Unknown
timestamp: November 11, 2017, 06:29:21 am
content: Quote from: janekm on November 11, 2017, 03:26:10 amActually I have to take that back... the shop was gaming the taobao search by applying a discount on single quantities, which reduces the more you buy. I think that's the first time I've seen a negative quantity discount10 pieces ended up costing 1.07RMB each. 1 would have been 0.76.

author: technix
author_rank: Super Contributor
timestamp: November 11, 2017, 12:59:03 pm
content: Quote from: janekm on November 11, 2017, 06:29:21 amYou need to source them directly from STC to get the prices right.

author: FrankBuss
author_rank: Unknown
timestamp: November 11, 2017, 01:51:20 pm
content: Quote from: blueskull on November 11, 2017, 03:43:56 amI wonder how much an ATTiny9 would cost in larger quantities. At Digikey you can get it for24 centif you buy 100. And I guess it can do more than some ultra cheap OTP MCUs. At least it is powerful enough to do realtime audio synthesis for playinga chiptune.

author: Siwastaja
author_rank: Super Contributor
timestamp: November 11, 2017, 02:37:00 pm
content: Quote from: ataradov on July 30, 2017, 07:59:31 pmOkay, so Renesas won't help you, so how about others?My experience with STM32 is that if you really need support, you won't get any.Sure, if you are a total beginner and need to see a copypaste of an example code how to get a LED blinking, you'll get it from the forums. They are great for that.With any real problem, you are on your own.For example, when reporting a non-documented silicon bug and asking how to proceed from there, even as a business customer, ST just ignores you.And ST is one of the most used and well known players on the ARM market, STM32 being a well known brand.I guess it's the same game with everyone, really. We just have the feeling of "having support" when we work with the "well known" names, whereas in reality, we can only help ourselves. Starting from the risk that we never know if some part will be available tomorrow or not.--Quality of documentation and theexactnessof it (i.e., is the product working within spec sheet / reference manual?) is, IMO, one of the most important criteria. Even a slightly poor choice of words can easily cost 10 hours of engineering time due to confusion and wrong assumptions. An omission of a small detail may cost another 10 hours. A copy-paste error or a typo is 10 hours more, then a undocumented silicon bug eats 50 hours extra. These do add up, this is typical design flow with STM32 in my experience.Unfortunately, this is very time-consuming to evaluate. You'll know once you have fully stepped in and done full designs with said chips. And at that point, you consider yourself an experienced designer on said architecture, don't want to try anything else, since you already have "won" the battle and fear that another product family will bring you back to square one again.

author: mrcrud5
author_rank: Contributor
timestamp: November 24, 2017, 12:44:27 pm
content: This post got a shout out on the amp hour!

author: coppice
author_rank: Super Contributor
timestamp: November 24, 2017, 12:56:07 pm
content: Quote from: blueskull on November 11, 2017, 03:43:56 amExpensive compiler software and programmer hardware is an interesting industry dynamic. When the required tools are rather expensive they are such an impediment to sales that they typically get "loaned" to serious high volume developers. Of course, their useful life is not that great, as the target devices become obsolete quite quickly, so the "loaned" items never really go back to the vendor at the end of projects. For the developer, those "expensive" tools cost less than a simple JTAG gadget for programming a flash MCU.

author: technix
author_rank: Super Contributor
timestamp: November 25, 2017, 09:28:09 am
content: Quote from: coppice on November 24, 2017, 12:56:07 pmThat is kind of a barrier keeping individual hackers out of their ecosystem, and locking existing customers in.

author: westfw
author_rank: Super Contributor
timestamp: December 06, 2017, 01:59:01 am
content: I'm currently trying to resist buying a bunch of < $0.25 Freescale S09 chips that Newark is flushing... Sigh.

author: technix
author_rank: Super Contributor
timestamp: December 06, 2017, 08:26:02 am
content: Quote from: westfw on December 06, 2017, 01:59:01 amWhat are those? And how do you program them?

author: FrankBuss
author_rank: Unknown
timestamp: December 06, 2017, 10:29:12 am
content: $0.25 is expensive. You can get an ATTiny5 for$0.20 at Digikey, and $0.168 if you buy 100. But the flash size is very small. If you pay $0.35, you can get an ATTiny9, which can be used to play a chiptune:

author: westfw
author_rank: Super Contributor
timestamp: December 06, 2017, 08:47:07 pm
content: QuoteOh, like ($0.05):http://www.newark.com/nxp/mc9rs08kb2csc/microcontroller-mcu-8-bit-rs08/dp/29R0568Or ($0.08):http://www.newark.com/nxp/mc9s08qd4msc/microcontroller-mcu-8-bit-s08/dp/22M5768(There are more <$0.20, but the "sort" function doesn't recognize "special" prices...)If I understand the history right, the HC08 is an enhancement of the old 6805 (which was a "microcontroller oriented) 6800?), the S08 is a modernized version of that, and the RS08 is a "reduced" S08 (rather unpleasantly: looks like 1 level of subroutine "stack"!) They're 8-bit accumulator/memory architecture with index register; rather CISCy. You can still download free "Codewarrior for microcontrollers" that has "unlimited assembler" and "C compiler with irrelevant restrictions for those chips" (though I'm not sure how that'd work for the RS08!)Something like "high voltage serial programmer" and or "Background Debug Mode" (both documented and with some Open Source implementations.)While accumulator architectures are out-of-style, the old motorola implementations were supposed to be "pretty good", and these aren't yet actually "discontinued" (though they're not too cheap "normally"), so youcoulddo worse in a search for ultra-cheap jellybean microcontrollers for trivial applications. (And I have. Anybody want some OTP Toshiba 4-bit microcontrollers? :-( The whole "these things can't be THAT hard to use" feeling is an illusion. Thus my attempt to "resist.")

author: technix
author_rank: Super Contributor
timestamp: December 07, 2017, 10:07:15 am
content: Quote from: westfw on December 06, 2017, 08:47:07 pmWell it is likely that if I ever want to build anything around those I will first need to build myself the programmer and debugger hardware. It is good that my computer actually still had a Super I/O ISA parallel port available but how to get it to show up in macOS... Just like my 8051 boards which is stuck in a dev tool limbo.Maybe I have to stick to STM32 and other ARM for a while.