Posted on Leave a comment

Arm Based Microcontrollers

At the time of writing this article ARM-based microcontroller means the microcontroller which uses a 32-bit RISC processor design from ARM holdings.

Presently ARM Cortex-M series of processor cores are being integrated into microcontrollers.

The ARM-Cortex M family comprises the following processors.

  • Cortex-M0
  • Cortex-M0+
  • Cortex-M1
  • Cortex-M3
  • Cortex-M4
  • Cortex-M7
  • Cortex-M23
  • Cortex-M33
  • Cortex-M35P
  • Cortex-M55

The Cortex-M4 / M7 / M33 / M35P / M55 cores also have a hardware-based floating-point unit. The addition of a Floating point unit adds the capabilities for digital signal processing.

To see a list of ARM-based microcontrollers.

Keil.com has a great list that has almost all the major microcontrollers out in the market and is supported by the Keil IDE.

https://www.keil.com/dd/chips//arm.htm
Posted on Leave a comment

How to use gdb debugger in raspberry pi for ARM assembly programs

After you have written your program. You try to run your program, sometimes the output produced by your program is not as you would have desired.

That’s when you use the debugger to look into the code and figure out what went wrong.

Debugging gives you an insight look into the low level programming instructions that your compiler have produced. But to understand the logic and program execution; you need to know at least the basics of assembly programming.

On Linux based operating system such as Debian, a gdb debugger is available.

But it not very friendly to operate. So there are various tools that make it easy to work with the gdb debugger. One of them is the GEF extension.

The GEF extension provides you with the view of registers, stack and disassembly of program, on a single page.

Posted on Leave a comment

STM32L476vg ARM Cortex M4F Architecture

It uses ARM v7E-M architecture.

It a Harvard based architecture with two distinct buses for data and memory.

It has all the instruction set of M0, M1 and M3 .

It also has an additional feature set to support Floating-point Arithmetic. IEEE754 standard in single precision and double precision.

The following points are from the programming model.

There are three modes of operations:

  1. Thumb State
    1. Thread mode: Privileged
    2. Thread mode: Unprivileged
  2. Debug mode

Two thread mode are given to support a operating system. Kernel software run in priviledged mode and the user application software runs in unprivledged mode.

Unprivileged mode has some restriction on memory access.

Privileged mode has full access to system resources.

If an operating system is running and a user application needs to access the Privileged resources it has to generate an exception/interrupt and then the interrupt will be taken by the handler and put the system in privilege mode.

You can switch from privilege mode to unprivileged mode by setting nPRIV and SPSEL bit in the CONTROL register.

Just like all the other processors ARM Cotex M4 has registers and pointer registers.

The major difference is the use of two different stack pointer registers.

  1. Main Stack Pointer (MSP)
  2. Process Stack Pointer (PSP)

If application is running in privileged mode than main stack pointer will be used. And if the application is working in unprivileged the process stack pointer will be used.

General Purpose Registers:

R0 – R12 – General Purpose Register

R13 – Stack Pointer (SP) {MSP and PSP}

R14 – Link Register (LR)

R15 – program counter (PC)

Special registers:

  • xPSR – {APSR, EPSR, IPSR}
  • FAULTMASK
  • BASEPERI
  • PRIMASK
  • CONTROL
floating point registers of arm cortex m4f

There are 32 FPU registers from s0 to s31.

They group together to form a single 64-bit register. which are from D0 to D15

There is a Floating Point Status and Control Register (FPSCR).