Arm microcontrollers are extremely popular in embedded systems and IoT devices. Here are some common interview questions and answers about ARM microcontrollers:
Q1. What is an ARM processor?
ARM processors are RISC-based processors designed by Arm Holdings. Key features of ARM processors include:
- Reduced Instruction Set Computer (RISC) architecture – simpler instructions mean higher efficiency
- Low power consumption suitable for battery-powered devices
- High performance compared to size and cost
- Scalable – different ARM cores available for different needs
- Customizable – companies can license and modify ARM cores
Due to these advantages, ARM processors dominate the mobile and embedded device markets.
Q2. What are the differences between ARM7, ARM9, ARM11, Cortex-A8 and Cortex-A9?
These refer to different generations and families of ARM processor cores:
- ARM7 – 32-bit RISC single-core processors. E.g. used in early mobile phones.
- ARM9 – Improved ARM7 with faster clocks and added DSP instructions. Used in PDAs and early smartphones.
- ARM11 – Further improved performance and power efficiency. Used in later smartphones.
- Cortex-A8 – First multicore ARM core. Used in early iPhones and Android phones.
- Cortex-A9 – Faster and more energy efficient than A8. Used in smartphones and tablets.
In general, the ARM core generations improved on performance, efficiency, and features over time as Moore’s Law progressed.
Q3. What is a System on Chip (SoC)?
A System on Chip (SoC) integrates all the components of a computer system into a single integrated circuit chip. Typical components of an SoC include:
- CPU (such as an ARM core)
- GPU
- Memory interfaces
- Peripherals and device interfaces (USB, Ethernet, etc)
- Wireless interfaces (WiFi, Bluetooth, cellular)
- Power management
ARM processors are commonly used as the CPU in many SoC designs targeted at embedded systems and mobile devices. Some examples of ARM-based SoCs include Qualcomm Snapdragon, Apple A-series, and Samsung Exynos used in smartphones.
Q4. What is a Real Time Operating System (RTOS)?
A Real Time Operating System (RTOS) is an operating system designed for real-time applications that process data as it comes in, typically with microsecond response times. Key features include:
- Very fast and predictable response times to events
- Advanced scheduling algorithms for processing tasks
- Synchronization and inter-task communication methods
- Low latency interrupt handling
Embedded systems often use an RTOS. Some examples of RTOS for ARM devices include FreeRTOS, RIOT OS, Zephyr, and Linux RT patch.
Q5. What is a toolchain? Name some commonly used toolchains for ARM development.
A toolchain refers to the programming tools used to build software that runs on a processor. It consists of:
- Cross compiler – compiles source code into machine code
- Assembler – converts assembly language to machine code
- Linker – links object files into executables
- Debugger – debugs source code
Some commonly used ARM development toolchains include:
- GCC ARM – Open source toolchain for ARM
- Arm Compiler – Arm’s official toolchain
- Keil MDK – Arm toolchain by Arm subsidiary Keil
- IAR EWARM – Popular commercial toolchain by IAR Systems
Q6. Explain the ARM register bank and some commonly used registers.
The ARM processor contains a bank of 32-bit general purpose registers R0 to R15. Some commonly used ones include:
- R0-R3 – Used to pass arguments and return values between functions
- R13 – Stack pointer, points to the current top of stack
- R14 – Link register, stores return address when calling functions
- R15 – Program counter, contains the current instruction address
The ARM banked register architecture allows fast switches between different operating modes through changing the active register bank.
Q7. What is ARM thumb instruction set?
Thumb is a 16-bit instruction set available in ARM processors as a more space efficient alternative to 32-bit ARM instructions. Key points:
- Uses 16-bit Thumb instructions instead of 32-bit ARM instructions
- Higher code density – more compact code size
- Subsets of ARM registers and instructions available in Thumb mode
- Some performance penalty due to more instructions required
- Can switch between ARM and Thumb modes easily
Thumb is very useful for embedded systems where program memory space is limited. Modern ARM cores support intermixing ARM and Thumb instructions.
Q8. What is a vector table in ARM Cortex-M?
The vector table is an array of function pointers that point to ISR handler functions for the CPU exceptions and device interrupts. It is normally located at the start of code memory in Cortex-M devices. Key points:
- Defined by linker script
- First entry is stack pointer initial value
- Followed by exception handler addresses like reset, NMI, hard fault, etc
- IRQ handler addresses come after exceptions
- Initialized before main() in startup code
The vector table allows fast, constant time exception and interrupt handling determined by the addresses in the table.
Q9. What are some commonly used ARM Cortex-M peripherals?
Here are some common peripherals integrated in ARM Cortex-M microcontrollers:
- General purpose I/O ports – for interfacing with external circuits
- Timers and PWM modules – for time measurements, PWM signal generation
- ADCs – analog to digital converters for reading analog signals
- UARTs, I2C, SPI – serial interfaces for external communication
- DMA controllers – allows peripheral I/O without CPU involvement
- USB interfaces – for USB OTG communication
- Clock systems – generates system clocks from internal oscillators or external sources
- Memory interfaces – interfaces for external memories like flash, RAM, etc
Q10. How are peripherals accessed in ARM Cortex-M microcontrollers?
Peripheral access methods in ARM Cortex-M include:
- Memory-mapped peripherals – Peripherals mapped into microcontroller’s memory address space
- Memory-mapped registers – Control/status registers of peripherals accessible by reading/writing addresses
- Direct register access using assembly – Quickly read/write peripheral registers directly
- Using CMSIS-Core peripheral access functions – Portable peripheral library access
- Vendor HAL APIs – Hardware abstraction layer functions provided by vendors
Memory-mapped peripherals with mapped registers allow great flexibility in accessing peripherals from C using different abstraction levels.
Q11. What is NVIC in ARM Cortex-M and how does it work?
NVIC stands for Nested Vectored Interrupt Controller. It is used to handle interrupts in Cortex-M devices. Key features:
- Supports nested interrupt handling – higher priority interrupts can preempt lower ones
- Vector table holds all interrupt handler addresses
- Dynamic reprioritization and masking of interrupts
- Reduces interrupt latency compared to traditional interrupt controllers
NVIC improves interrupt handling performance and flexibility. Interrupts are enabled, prioritized and cleared by accessing NVIC registers.
Q12. What is Systick timer in ARM Cortex-M?
The SysTick timer is a simple decrementing counter available in ARM Cortex-M devices that is used for:
- Providing a simple timer ISR for basic timekeeping
- Generating periodic interrupts for task scheduling in RTOS
- Inserting short delays in code by polling SysTick value
Key features:
- 24 bit decrementing counter
- Clock source can be core clock or external reference
- Interrupt can be generated on counter reaching zero
- Commonly used for RTOS timekeeping
The SysTick timer provides a simple and convenient timer functionality in Cortex-M devices.
Q13. What is a Cross Trigger Interface (CTI) in ARM Cortex-M?
The Cross Trigger Interface (CTI) allows connecting multiple ARM Cortex-M cores together for:
- Synchronization between cores
- Triggering events across cores like halting CPU or triggering interrupt
- Debugging across multiple cores simultaneously
Key capabilities:
- Up to 4 master and 4 slave interfaces
- Complex trigger events using MCU events as sources
- Cross-halting CPUs using trigger outputs
- Debugging multiple cores using multiple CTIs
CTI enables new options in multi-core debugging and synchronization.
Q14. What are some key ARM Cortex-M processor modes?
ARM Cortex-M devices support several processor modes including:
- Thread mode – used to execute normal application code
- Handler mode – used to execute exception handlers
- Privileged modes:
- Thread privileged modes for OS kernel
- Handler privileged modes for OS kernel exceptions
- Debug access mode – for debug access when halted
- Fault handling modes – for hard faults, NMI, etc
The different modes provide isolation, privilege separation, and security through isolating code execution, memory access, and peripherals between modes.
Q15. What are ARM Cortex-M TrustZone security extensions?
TrustZone security extensions provide hardware isolation mechanisms for ARM Cortex-M devices including:
- Separating secure and non-secure states
- Isolation mechanisms between secure and non-secure:
- Flash, RAM, and peripheral partitioning
- Interrupts and interrupt handling
- Debug access blocking in secure state
- Secure attibute to control access to resources
- Monitor mode handles switching between secure/non-secure states
This allows building systems with robust security using Cortex-M TrustZone, ideal for IoT devices.
Q16. What are some advantages of using CMSIS standards for ARM Cortex-M development?
CMSIS (Cortex Microcontroller Software Interface Standard) provides many software interfaces and standards for ARM Cortex-M development including:
- Common APIs across Cortex-M vendors – CMSIS-Core
- Peripheral access functions – CMSIS-Core
- Real time operating system APIs – CMSIS-RTOS
- DSP libraries – CMSIS-DSP
- Driver interfaces – CMSIS-Driver
- Software pack format – CMSIS-Pack
Key benefits are code reuse across vendors, simpler migration between ARM cores, and reduced software overhead.
Q17. What is Cortex Microcontroller Debug (CMDebug)?
CMDebug is an industry standard debug system built into ARM Cortex-M devices that enables:
- Processor core and system debug
- Setting complex hardware breakpoints
- Trace buffer for recording program execution
- Accessing core and peripheral registers
- Starting, halting, and stepping execution
CMDebug provides sophisticated debug capabilities for Cortex-M devices. Debuggers interact with the target CPU using SWD, JTAG or cJTAG interfaces.
Q18. What are some commonly used techniques for reducing power consumption in ARM Cortex-M designs?
Some power reduction techniques include:
- Using lower clock frequencies when high performance is not needed
- Using lower power modes with clock gating and wakeup on interrupts
- Minimizing use of peripherals, and using low power modes in peripherals
- Optimizing code efficiency to reduce CPU cycles needed
- Using DMA transfers instead of CPU transfers
- Optimizing power design and ensuring no high power leaks
- Disabling unused peripherals clocks and power domains
Power optimization is very important for battery operated embedded and IoT devices using Cortex-M processors.
Q19. What are the differences between ARM Cortex-A and Cortex-M series processors?
The Cortex-A and Cortex-M series have significant differences:
- Cortex-A
- Application processors for Linux/Android devices
- High performance, speeds up to multiple GHz
- Superscalar, out-of-order execution
- MMU for virtual memory support
- Usually multicore
- Cortex-M
- Microcontrollers for real-time embedded/IoT
- Lower power, speeds up to hundreds of MHz
- In-order execution, simpler pipeline
- No MMU, simpler memory architectures
- Typically single core
In essence, the Cortex-A focuses on high performance applications processing while the Cortex-M focuses on real-time responsiveness.
Q20. What are some key ways ARM Cortex-M processors differ from traditional microcontrollers?
ARM Cortex-M processors differ from traditional microcontroller architectures in ways like:
- RISC philosophy – simplified instructions for efficiency
- Advanced low power techniques for energy efficiency
- High performance capabilities at low cost
- Sophisticated debugging capabilities
- Abundant development tools and software support
- Certified processors ensure consistent performance
- Scalable processors range from basic to advanced
- Customizable – vendors can integrate customized features
The ARM architecture brought embedded system capabilities to new levels and enabled the growth of IoT.