Hello everyone, are you still confused by various MCU and CPU architectures? Are you struggling with whether to use bare metal programming or an RTOS? Don’t worry, today I will guide you through the common MCU and CPU architectures, development methods, and toolchains in embedded systems from scratch, ensuring that you will understand it all by the end!
Overview of Embedded MCUsBefore discussing MCUs, let’s categorize them into two types: 8-bit, 16-bit, and 32-bit.
- • 8-bit: Classic AVR (Arduino), Microchip’s PIC, low learning cost, abundant community resources, suitable for small hardware projects.
- • 16-bit: TI MSP430, ultra-low power, suitable for wearables and sensor nodes; however, it has relatively fewer peripherals and its ecosystem is not as rich as ARM’s.
- • 32-bit: The mainstream today is undoubtedly the ARM Cortex-M series:
- • M0/M0+: Entry-level, not high performance but extremely low power, suitable for low-cost devices;
- • M3/M4/M7: High performance, supports floating-point operations and DSP instructions, such as STM32F4, STM32F7, NXP’s Kinetis, TI’s TM4C;
- • RISC-V is also on the rise, with domestic open-source solutions like GD32V and Sipeed M1, and the community is rapidly growing.Additionally, don’t forget about Wi-Fi/BT board-level MCUs, such as Espressif’s ESP32 and Nordic’s nRF52, which offer comprehensive networking capabilities.
CPU Architecture InsightsMCUs are just packages; the true lineage depends on the CPU architecture:
- • ARM: The elder brother of embedded systems, low power consumption, unified instruction set, and the most complete ecosystem;
- • x86: The Intel/AMD guys, strong performance but higher power consumption and cost, more commonly found in industrial PCs and gateways;
- • MIPS: Once very popular, now mostly seen in router SoCs;
- • RISC-V: An open-source instruction set, flexible and customizable, with a promising future.Choosing an architecture is like selecting a car model: fuel-efficient for family use (Cortex-M0), balanced performance for family use (Cortex-M4), or track performance (Cortex-M7 or x86).
Development Methods: Bare Metal & RTOS
- • Bare Metal: Does not rely on an operating system, directly manipulates registers. The advantages are fast response and streamlined code; the disadvantages are high costs for multi-task management and portability.
- • Lightweight RTOS: FreeRTOS, Zephyr, RT-Thread, Amazon FreeRTOS…
- • Task scheduling, message queues, and timers are all included, making coding more modular;
- • However, it also brings certain memory and learning overhead, as you need to learn about task priorities, interrupt management, and resource synchronization.Common practice: use bare metal for critical performance needs, and RTOS for complex functionalities; even a bare metal + simple scheduling framework can balance the advantages of both.
Complete Development Toolchain
- • Compilers:
- • GCC ARM: Open-source and free, with strong community support;
- • Keil MDK-ARM (armcc/armclang): A well-established commercial option with excellent optimization;
- • IAR Embedded Workbench: Expensive but offers excellent compilation efficiency and code density.
- • IDE/Editors:
- • Keil MDK, IAR, CubeIDE (STM32), MCUXpresso (NXP), Embedded Studio (Segger);
- • VS Code + PlatformIO/CMake/Eclipse: More flexible, suitable for experienced users seeking personalized configurations.
- • Arduino is suitable for beginners.
- • Debuggers:
- • ST-Link: Standard for STM32, stable and inexpensive;
- • J-Link: Powerful, supports multiple vendors, but slightly more expensive;
- • OpenOCD + CMSIS-DAP: Open-source and free, highly customizable.
- • Other essential tools: Logic analyzers (Saleae, USBee), oscilloscopes, multimeters; hardware debugging tools are also essential.
Practical Selection & Tips
- 1. Project-driven: First clarify your project requirements—performance? power consumption? cost? peripherals?
- 2. Ecosystem and resources: STM32 and ESP32 have active communities with many tutorials, forums, and open-source libraries, making them beginner-friendly; RISC-V is suitable for those who want deep customization and embrace open-source.
- 3. Tool budget: For beginners, GCC + VS Code is a good choice; for company projects aiming for productivity, Keil/IAR + hardware emulation debuggers are more efficient.
- 4. Step-by-step approach: Start with the simplest LED blinking or UART printing, iterate in small steps, and refer to manuals and communities when encountering issues; don’t dive into RTOS right away.
Alright, this “hardcore content” has helped you cover the common MCU and CPU architectures, development methods, and toolchains. Embedded systems are not as mysterious as they are said to be; the key is to practice more, debug more, and engage in forums to learn from others. Quickly grab a development board, write some code, and enjoy the fun of “going from 0 to 1”! If you have any questions, feel free to discuss in the comments!