Follow @jack_ganssle

The logo for The Embedded Muse

For novel ideas about building embedded systems (both hardware and firmware), join the 27,000+ engineers who subscribe to The Embedded Muse, a free biweekly newsletter. The Muse has no hype and no vendor PR. It takes just a few seconds (just enter your email, which is shared with absolutely no one) to subscribe.

This month we're giving away the Zeroplus Logic Cube logic analyzer that I review later in this issue. This is a top-of-the line model that goes for $2149.



Microchip's New PIC16F18877 Family

Summary: Microchip's New Microchip's New PIC16F18877 MCUs offer a lot of interesting peripherals. The ADC is singularly powerful and complete.

Ever-innovative Microchip has a couple of new families of 8 bit microcontrollers. The CPUs remain about the same as in the rest of the PIC16 family, but the peripherals offer some pretty interesting capabilities.

I find the company's part numbers baffling and can no longer correlate feature sets to numeric designations without a cheat sheet. The latest PIC16F18877 family comprises quite a few variants with different memory sizes.

As an old embedded guy, I'm always fascinated by the boundary where digital hardware, firmware and analog intersect. In the early days of micros it was really hard to read analog signals. There were no monolithic A/D converters; you had to buy an epoxy-potted module to sample signals, and 12 bits was about the max resolution that was possible. These things cost hundreds of dollars back when inflation hadn't hollowed out the greenback. Long defunct companies (like Analogic and Burr-Brown) made these, as well as some still with us (e.g., Analog Devices). Conversion speeds were typically in the tens of microseconds.

The following picture shows a typical 12 bit unit dating from the mid-70s. The MAS-1202 retailed for $270, or about $1100 in today's dollars, and was an enormous 4 by 2 inches:

How things have changed! Can you imagine paying a kilobuck for an ADC of, by today's standards, fairly uninspiring performance?

(Potted modules of all sorts were really common, especially for analog components with tough specs. Around 1973 I went overseas for a month to support our products. We used a 40J potted op amp from Analog Devices, which had a very high failure rate. I replaced a sickening number. Finally done, I left Japan to head home and was assigned seat number 40J. Of course, it was broken.)

Microchip's new family has, as is typical with modern MCUs, an ADC on board. But this one is very different from that 1970s device, and is also unlike any 2015 A/D I'm familiar with. A couple of features stand out.

First, the ADC can do math on the sampled signal - with no intervention from the CPU! In fact, the processor can be asleep while the A/D reads and analyzes data. This is nice from a power-reduction standpoint, of course, but it also means that while the processor is awake it can manage other activities while the analog subsystem churns through data.

Math operations are controlled by a blizzard of registers and there are more modes than I care to describe here. But to paint a picture, the part can accumulate a specified number of values, right shifting each new result by any number of bits, average a number of samples (and, yes, a division is done without CPU intervention), or low-pass filter the signal.

But wait - there's more.

After these operations the result can be differenced from the previous reading (a sort of first derivative), against a programmed setpoint, against a filtered value, etc.

And more: that result can create an interrupt based on a number of conditions, like it being outside of a set of thresholds, or between them, or a bunch of other, similar, conditions. All while the CPU tends to other matters or is off in dreamland.

It gets even better. Conversions can be initiated by one of about 30 different conditions. For instance, if a timer overflows, or by an external pin being asserted. Or the output of either of two analog comparators.

Conversions can also start when very complex external events occur. The signal measurement timer, a 24 bit counter that measures things like external pulse widths, frequencies and duty cycles, or even the time difference between two signals, can start acquisition.

Maybe you need a really exotic start-of-conversion, something no vendor would supply since your needs are unique. These MCUs, like some of other parts from Microchip, contain four identical configurable logic cells (CLC). These are poor-person's FPGAs (they refer to them using the amusing phrase "puddle of gates" rather than the lofty "sea of gates" term used by FPGA vendors) that are completely programmable. Any CLC can trigger the ADC. Each CLC looks like this:

The PIC16F18877's ADC is only 10 bits. But outside of that it's a hugely programmable and capable device. It would be fun to have a few beers with some developers to brainstorm some cool applications for it.

In quantity parts are a bit over a buck. A large number of packages are available, including prototyping-friendly DIP as well as an assortment of SMT. There's more info here (, but, alas, as of this writing no datasheet has been published. The information in this article comes from a pre-release datasheet Microchip provided. I'm told the spec documents will be out shortly.

Published August 19, 2015