8. Embedded programming¶
8.1 Comparison(as group assignment)¶
There are several architectures in microcontrollers themselves and microcontrollers on board.
I would like to start with a comparison of PIC and AVR, which had competed each other in 8 bit microcontroller market for a long time.
As for me, I had a longer experience with PIC than AVR(I will write about it again in the following chapter). So I was quite surprised at the popularity of AVR when I joind maker communities.
I expect that I would be able to know the reason of the popuarity by comparing them.
8.1.1 PIC vs AVR¶
A long time war between PIC vs AVR came to an end when Microchip acquired Atmel in 2016. There were several rumors saying Microchip would cease AVR, but it haven’t been realized.
I think that Microchip have gotten access to enormous market and communities where AVR had ruled better than PIC.
Many parameters are similar in both PIC and AVR but there are some parameters that surely differ when compared:
PIC | AVR | Note | |
Manufacturer | Microchip Technology Inc. | Atmel Corporation | Atmel was acquired by Microchip in 2016. |
Frequency, Number of I/O pins, RAM, Flash Memory |
wide variation | wide variation | These parameters are similar in both PIC and AVR. |
Working Voltage | 4.5V (older series) |
3.3V | AVR have been focused on low-voltage previously, PIC now has been transformed for the low-voltage operation, too. |
Target Connectors | RJ11 sockets | ISP/UPDI interfaces | AVR has made it simple in terms of circuit design and development. |
Advanced Interfaces | USB, CAN and Ethernet | None | AVR can use external chips, such as FTDI USB to serial chips, Microchip Ethernet controllers or Philips CAN chips. |
Development IDE | MPLAB X | Microchip Studio (formerly Atmel Studio), Arduino IDE |
By acquisition of Atmel by Microchip, The IDEs have been integrated. But many makers would prefer Arduino IDE. |
Instruction Set | CISC | RISC | 'R' in 'AVR' is said to mean 'RISC'. RISC processors have fewer, simpler instructions compared with CISCs. |
C Compilers | MPLAB XC8 | WINAVR | WINAVR is ANSI C based on GCC compiler which makes it easy to port code and use standard libraries. Since AVR is designed for C in the beginning, the code output is small and fast. PIC has more features compared to AVR but it’s code becomes larger because of the structure of PIC. |
Assembly language | PIC assembly language is tedious with everything forced to operate through the accumulator, forces to use bank switching | AVR assembly language is very easy with lots of instructions and the ability to use all 32 registers as accumulator | Although I am not familiar with assembly language, It seems that AVR is better to work on in terms of programming by assembly language. |
Programmers | PIC Kit 4 | STK500, Atmel-ICE, JTAG-ISP, AVRISP, TinyISP, Arduino and now PIC Kit 4 | Development of PIC programmer is said to be difficult compared with AVR. There are several programmers available for AVR. |
As a result, PIC and AVR are, because of their different characteristics, not rival competing in the same market, but they have their own domains.
It seems that AVR is more open and easier than PIC in terms of programming, maybe it is why AVR is so popular in maker communities.
References:
PIC vs AVR: Which Microcontroller to choose for your Application by Abhiemanyu Pandit Mar 27, 2019
8.1.2 Arduino vs Mbed¶
Next chapter is about microcontrollers on board. I compared Arduino with Mbed, in other words, comparison of 8 bit with 32 bit.
Maybe the comparison isn’t fair that there are already 32 bit Arduinos on the market. But considering that the most popular Arduino is a 8 bit UNO, it would make sense.
Originally, microcontrollers on board had been designed as development boards for microcontrollers, but as they were so convenient, they often have been ‘embedded’ in final products. It is especially the case as for Arduinos.
Arduino | Mbed | Note | |
Overview | Combination of various Arduino boards and deveopment tools | Combination of various Mbed boards and deveopment tools | |
Sponsored by | Arduino LLC | ARM Ltd. | |
IDE | Arduino Desktop IDE Arduino Cloud |
ARM Keil Studio | The IDE for Mbed was formerly called Mbed Complier, but seems to be renamed. |
Programming Language | Arduino | C++ | Arduino language is based on C/C++, but is slightly different. |
Location of IDE | local(Desktop IDE) cloud(Web Editor) |
cloud | |
Processers | 8 bit AVR(UNO) | 32 bit ARM Cortex-M based | There are also 32 bit Arduinos |
Frequency | 8-16 MHz | 48-96 MHz | |
Memories | 32 KB Flash /2 KB SRAM /1 KB EEPROM(UNO) |
Varies by products | |
Working Voltage | 2.7-5.5 V | 3.3 V | |
Interfaces | USB, Digital I/O, Analog I/O, PWM out, I2C, SPI, etc. | USB, Digital I/O, Analog I/O, PWM out, I2C, SPI, etc. | Number of pins varies by products. Some products also have wireless connectibility(Wi-Fi, BlueTooth) |
The word ‘Mbed’ was apparenty created from the word ‘embedded’. It is a little confusing that Mbed is also served as Mbed OS, which is RTOS for IOT devices.
Mbed boards are generally more powerful than Arduinos, but Arduinos seem to be prefered by maker communities, maybe reflecting the long time colaborations and contributions each other.
8.1.2.1 micro:bit is Mbed, too¶
micro:bit was developped by BBC for educational purpose, especially intended for younger people.
It has many interesting features and became popular, but currently it is rather hard to find one in market maybe suffered from world-wide supply shortage of semi-conductors.
micro:bit is designed with Mbed architecture, so it can be programmed with Mbed Compiler.
It stands out in Mbed familly with a special feature: It also can be programmed by other languages like MicroPython, MakeCode(internally JavaScript) and Scratch.