Book Image

The Insider's Guide to Arm Cortex-M Development

By : Zachary Lasiuk, Pareena Verma, Jason Andrews
Book Image

The Insider's Guide to Arm Cortex-M Development

By: Zachary Lasiuk, Pareena Verma, Jason Andrews

Overview of this book

Cortex-M has been around since 2004, so why a new book now? With new microcontrollers based on the Cortex-M55 and Cortex-M85 being introduced this year, Cortex-M continues to expand. New software concepts, such as standardized software reuse, have emerged alongside new topics including security and machine learning. Development methodologies have also significantly advanced, with more embedded development taking place in the cloud and increased levels of automation. Due to these advances, a single engineer can no longer understand an entire project and requires new skills to be successful. This book provides a unique view of how to navigate and apply the latest concepts in microcontroller development. The book is split into two parts. First, you’ll be guided through how to select the ideal set of hardware, software, and tools for your specific project. Next, you’ll explore how to implement essential topics for modern embedded developers. Throughout the book, there are examples for you to learn by working with real Cortex-M devices with all software available on GitHub. You will gain experience with the small Cortex-M0+, the powerful Cortex-M55, and more Cortex-M processors. By the end of this book, you’ll be able to practically apply modern Cortex-M software development concepts.
Table of Contents (15 chapters)
1
Part 1: Get Set Up
5
Part 2: Sharpen Your Skills

Selecting development boards

In the previous sections, we reviewed several criteria for selecting a processor, as follows:

  • Use cases
  • Power
  • DSP performance
  • ML performance
  • Security
  • Safety
  • Cost

Selecting microcontrollers and development boards introduces a few new factors that impact performance and functionality. These include memory characteristics, power supplies, and peripherals.

Performance

Performance is driven by the compute requirements of software applications. Selecting hardware is always easier when the software is well understood, but it’s not always possible. When software is not available, similar applications can be used to estimate performance. There are a variety of industry benchmarks that may provide performance guidance.

As we have seen in previous sections, microcontroller performance is primarily determined by the Cortex-M processor microarchitecture. The next most important factor is memory.

Important CPU factors include the frequency, instruction pipeline, cache, TCM, floating-point hardware, and any special instructions for DSP or vector processing of larger units of data.

Different types of memory are also available in microcontrollers. Most microcontrollers use a mix of static random-access memory (SRAM) and flash memory. Flash memory can be reprogrammed numerous times and holds data when the power is removed. Flash is ideal for storing software instructions.

SRAM provides faster access compared to flash, but the contents are lost when power is removed.

Dynamic RAM (DRAM) may also be used in embedded systems when larger amounts of memory are required, and SRAM would be too expensive.

A common software strategy is to move important code and data from flash to SRAM after analyzing to improve performance.

Cortex-M microcontrollers are easy to use because they have a standard memory map that places read-only memory (ROM) or flash memory and SRAM at standard locations in the memory map. This makes it easy to set up regardless of the Cortex-M processor being used.

Looking at the memory access times is key to analyzing performance. Microcontrollers may contain caching systems to feed data from flash memory into a CPU much faster than making a single read access to flash and incurring waits. Instruction and data caches also improve access time to memory.

Memory size is also a key parameter for selecting a device. Most Cortex-M systems are memory-constrained. Running out of memory can be a challenge, so keep an eye on the size of each memory type.

Power

Power is driven by the operating environment of a product. Requirements to run on a battery, use a specific type of power supply, or maximum current and voltage values to work in each environment should be considered. Certainly, battery versus always plugged in makes a difference, but power consumption has become more complex than just leaving products plugged in and forgetting about power. Products and consumers are starting to focus on using less energy, even in IoT products that are always plugged in, because saving energy across a trillion IoT devices makes a significant difference. Consumers are starting to ask whether every IoT device needs to continuously monitor and report data even while they are sleeping.

Arm processors have a long history of being efficient and using a reasonable amount of power for the performance they provide. Cortex-M processors emphasize simplicity and low-power sleep modes when processing is not needed.

Development boards will provide technical specifications with power details. Using the board specifications in combination with what we have learned about individual Cortex-M processors will help with making good decisions about power.

Peripherals

One key distinction between the thousands of Cortex-M microcontrollers is the peripherals of each device. In fact, this is a common starting point when narrowing down options to make sure desired functionality is supported. The cost-sensitive nature of microcontrollers leads each vendor to develop families of products, selection guides, and tables of products that mix and match various factors such as processor features, peripherals, memory sizes, and temperature ranges. The tables of options can be overwhelming.

One way to understand peripherals is to break them down into a few categories. Today’s IoT devices perform data collection, processing, and data communication. Historically, embedded systems focused on input/output (I/O) pins to connect many types of hardware for data and control.

You can segment peripherals into categories through the following:

  • Input from the environment (collecting data from sensors)
  • Communication interfaces (storing data)
  • Digital and analog I/O signals to interface with additional hardware

A useful exercise to get an understanding of peripherals is to scan through a variety of microcontroller technical summary descriptions and see what is highlighted. These are the key factors the device vendor decided to highlight. This includes a combination of unique features and common features that many devices may have.

Here are some key highlights we found when looking across a variety of devices.

Cortex-M0 and Cortex-M0+ development boards

Some of the common features advertised for Cortex-M0 and Cortex-M0+ boards include general-purpose I/O (GPIO) pins and analog input pins. These allow projects to connect other digital and analog hardware to the board. A Universal Serial Bus (USB) is also common on most development boards for easy connection to software development tools. Some basic sensors may be included for things such as temperature or other climate sensors. Because of the focus on cost and simplicity, another key feature is the types of expansion connectors that are available. This allows users to expand in a generic way to add more interfaces for both data collection and communication to store data. Standardization of connectors brings better compatibility and a wider selection of add-on hardware.

Cortex-M3, Cortex-M4, and Cortex-M7 development boards

Development boards with these Cortex-M processors highlight IoT. Communication features to store data remotely are highlighted, so the boards can immediately be used for IoT applications. Common technologies are Bluetooth Low Energy (BLE), near-field communication (NFC), radio frequency (RF), and Wi-Fi. This class of boards also highlights more advanced sensors such as accelerometers and gyroscopes, as well as pulse width modulation (PWM) to control lights and motors. Analog-to-digital converters (ADCs) and digital-to-analog converters (DACs) are also common to interface with a variety of digital and analog hardware.

Many applications will be battery-powered, so battery types and means to power the boards are important.

Cortex-M23 and Cortex-M33 development boards

Cortex-M23 and Cortex-M33 development boards emphasize TrustZone features and support for Trusted Firmware-M (TF-M) to provide a trusted environment for secure storage and cryptography.

Interfaces for these development boards will be similar to the previous group but can be more advanced as the processors are newer and security features enable new applications. Communication interfaces include BLE, Wi-Fi, and Long-Term Evolution (LTE) modems. Specialized antennas may be available for advanced communication protocols such as a NarrowBand-IoT (NB-IoT) antenna. More complex features such as a stereo audio codec are common. Additional storage is possible using a microSD card slot.

Some development boards in all categories include a connector to measure the power of a running system. This helps to make it easy to measure actual power during system development.

Other factors

In addition to analyzing the Cortex-M processors, memory types, and peripherals, there are several secondary factors to consider when selecting microcontrollers and development boards.

Software

The most important factor is software, which is why we are writing this book. There are numerous software considerations, and these will be covered specifically in the next chapter. Topics are real-time operating system (RTOS) support, connectivity standards, software development kit (SDK) options and programming languages, and software libraries.

Development boards can also be certified by cloud service providers (CSPs) or serve as primary reference boards, for example, software to make it easier to get going right away with a particular RTOS, connectivity standard, or IoT platform for data collection and visualization.

When possible, it’s also good to use benchmark or representative software that is similar to the application to guide performance and code size in selecting the right development board.

Support community

An important secondary factor when selecting development boards is the ability to find answers to questions. Because there are so many microcontrollers and development boards, some of them may not have a large or active community of users reporting problems and helping each other find answers. This often makes a significant difference in how fast a new development board can be adopted. If you believe having an active community around a board is helpful, try to search for a representative problem and see whether there are answers available. Some development boards just die out, while others seem to have active developer forums. Raspberry Pi has a large following, and there is so much content it feels like somebody has already tried almost every possible thing to be done with the boards. This makes Raspberry Pi boards easy to learn.

Size

Most microcontrollers themselves are physically very small, but the size of the development board could be very small or somewhat larger. If you want to use a development board to prototype an idea for a new product, it is good to know whether a prototype can be created that is close enough to demonstrate the product concept. Even if a custom board will be created later, having a prototype of useful size may accelerate product development.

Temperature range

Microcontroller products may have temperature ranges assigned to them. Historically, devices that operate over a range of 0°C to 70°C or 85°C are considered consumer-grade. A temperature range of -40°C to 85°C is considered industrial-grade. There may also be special characteristics for automotive microcontrollers. It’s worth checking into these extended temperature ranges if needed, but extending the temperature range comes at a higher price. Industrial IoT is popular and a common place to find extended temperature microcontrollers.

Availability

As we write in 2022, the global electronics industry has been suffering from a chip shortage. This has made it harder to find development boards at the various distributors. Having a good handle on availability helps us to know whether more development boards are needed for additional engineers or to build a test lab. Make sure to spend a little time understanding the availability of microcontrollers and development boards before getting too deep into a project. We hope that in the months and years to come, availability will be much less of a factor.

Development board selections

For the upcoming chapters, we selected two boards to demonstrate the concepts and provide detailed steps for you to try things yourself. Trying out the concepts presented in the book is the best way to learn and have the most fun. We selected two boards to cover small Cortex-M devices, security features of Cortex-M, devices with peripherals, and connectivity, as follows:

  • Board 1: Raspberry Pi Pico using the Cortex-M0+
  • Board 2: NXP LPC55S69-EVK using the Cortex-M33

We will also use a virtual board to demonstrate the concepts of the Cortex-M55.

We tried to avoid boards that are very new or may be difficult to obtain. We also tried to select boards with reasonable prices that can demonstrate newer concepts such as security and network connectivity.