Wednesday, 18 January 2017

Microchip/AVR news

This arrived in my inbox yesterday.

Each time Microchip release news about (what is now) their AVR line, it's often met with suspicion by the long-term hardcore Arduino users. Many of the Arduino fan-boys baulked when it was suggested that Microchip might buy up Atmel. "It's all closed source" they shouted. "Microchip / Microsoft they even sound the same. Boooo. "

But Atmel never released an open source device; their IDE wasn't open. Their hardware wasn't open. The avr compiler was open source and the Arduino platform (which uses AVR chips) is open source. But there's a world of difference between AVR (the company/device line) and Arduino (the development platform).

Just as there's a world of difference between open source and free.
And, just like the hipsters who complained about Microchip not being open source, while running open-source Arduino on their not-so-open Apple MacBooks, it's easy to get the two confused.

But Microchip isn't the big evil baddie in all this. Microchip make great microcontrollers. Even better than AVR did. Some people have tried to argue that the AVR toolchain is "better" than that used by Microchip's PIC. Again, they're confusing AVR with Arduino.

Both AVR and PIC devices require you to use a programmer to "burn" the firmware to the chip. Arduino uses a bootloader, so that you don't need a dedicated programmer - you can upload new firmware over serial. And if you don't have a usb-to-serial device, some Arduino boards even have an onboard converter - meaning you can plug them straight into your computer with no additional hardware.

But this isn't AVR - this is the Arduino ecosystem. Microchip's PIC also supports bootloaders - you can also upload code to a PIC over serial. It's just that the tools to do so aren't necessarily free; the community support isn't there like it is with Arduino. But the tools exist. The toolchain for PIC is no different to AVR. Burning code to my PIC 18F series is no different to burning code to an ATMega via the AVR Studio IDE. Both require a programmer, both compile your code into a hex file, which you then upload to the microcontroller.

It's Arduino that makes things different.
In fact, I'd probably argue that the tools used with PICs are even better than those used with Arduino. Because the PICKit2 (not the three, that's horrible! but the PICKit2) has some extra useful little features built into it that aren't available with most AVR programmers - things like a built-in UART/serial tool.

You don't have to disconnect the programmer, then introduce a different serial device to talk to a PIC (as you would have to when programming an AVR over ICSP then sending data to/from it over serial). PICKit2 lets you use the same programmer as a UART/serial device.

But it gets better than that. Much better. And it's something that a lot of AVR users dismissed. Until they really needed it - then a few even admitted is was a good idea!

The PICKit2 has a built-in logic analyser.
Ok, so it's only got three channels. But if you work with SPI or I2C communications, being able to quickly and easily debug waveforms by seeing them on the screen, without having to unplug and hook up yet more hardware, is brilliant.

Microchip make great hardware.
We've banged on enough times about how much more robust PIC chips are to AVRs. With clamp diodes on their i/o ports, reverse polarity protection on supply lines and so on, they're almost indestructible. The same can't be said for AVR chips. Swap the power and ground on most atmega devices and they'll let the blue smoke quicker than you can say "is this adapter centre positive?"

There's no doubting that Arduino has made things much easier for a whole community of people to make cool and exciting new things. It's allowed people with limited technical ability to make electronics projects which would otherwise be impossible. And that's a great thing.

But booing Microchip for "changing the branding" of AVR is just silly. In their press release, Microchip even specifically mention their support for Arduino. Just think how great the Arduino ecosystem is for developers - it's the one area Microchip was lacking - but now how much better it could be with a really innovative hardware company behind it, making really cool tools and peripherals.

There are even Arduino projects on the 'net that use Microchip devices to make them work! A lot of Arduino-driven ethernet controllers and capacitive sensing modules are simply using Microchip PICs and exposing the data over a serial connection.

Wouldn't it be better for everyone if you could just put those peripherals onto an AVR device and program it using the familiar Arduino IDE? That's exactly what Microchip are doing!

In the mid 2000s - as Linux started to take hold in the marketplace - it became fashionable to knock Microsoft for their "closed" expensive almost-ubiquitous software. Microsoft became a by-word for "big, expensive, over-bloated" technology. They weren't cool and trendy like Apple. Microsoft were "old school".

In the hardware/microcontroller world, Microchip (and their PIC line of mcus) have tended to get the same treatment. They're not cool and groovy and open source and free. Learning to program a PIC means learning how stuff actually works, not just including a library or copy-and-pasting someone else's code. But - just as the detractors to Microsoft missed the very reason they were so successful in the first place - Microchip make great hardware. The make great peripherals. They stuff loads of stuff into their tiny little chips and make it really easy to do cool things like gesture detection in 3d space.

And now they're releasing new devices into the AVR/Arduino community too, things are looking very exciting indeed. There's no AVR/PIC divide any more. Thirty years ago, Spectrum and Commodore owners were as divided about which was "best" as they are today. But there's no division between PIC/AVR; they're becoming one and the same.

And this isn't to say that either is being diluted or compromised by the other - more like each is getting better because of the other's influence. So the next time Microchip send out a press release, I for one will be really pleased to see it drop into my inbox!