Avoiding Stack Overflows: Application Monitoring the Stack Usage

One of the biggest fears of embedded systems developers are stack overflows. FreeRTOS includes a cool feature to monitor and catch task stack overflows. But what about the MSP (Main Stack Pointer) on ARM, or the interrupt stack? What if not using an RTOS and running a bare-metal application?

Checking stack size used

There is a simple way monitoring stack usage at runtime, and for this I want to share the routines and what is now available inside the McuArm module.

Continue reading

Visual Studio Code for C/C++ with ARM Cortex-M: Part 4 – Debug

The previous parts were about installation, project setup and building. This one is about debugging an ARM Cortex-M Microcontroller with Visual Studio Code:

Cortex-M4 (NXP K22FN512) Debugging with Visual Studio Code
Continue reading

Tutorial: First Steps with Embedded Artists NXP i.MX RT1052 OEM Module

Not ready for the complexity of a full blown Embedded Linux, but need that extra compute performance? Need an ARM Cortex-M7 running at 600 MHz module on a half-sized business card, ready to be integrated? Here we go: the Embedded Artists i.MX RT1052 OEM module:

Embedded Artists NXP i.MX RT1052 OEM Module

Embedded Artists NXP i.MX RT1052 OEM Module

Compute modules are very common in the Embedded Linux space, for example see this Toradex module. The reason is simple: these high-performance boards simplify the design, as I don’t have to care about the BGA packages and the external SDRAM and FLASH devices: everything is on a module I can easily integrate into my base board.

Continue reading

Flash-Resident USB-HID Bootloader with the NXP Kinetis K22 Microcontroller

The tinyK22 board (see “tinyK22 Boards arrived“) gets rolled out at the Lucerne University of Applied Sciences and Arts, so I thought I write-up an article this weekend how to use that board with a Flash Resident Bootloader.

tinyK22 with USB HID Bootloader

tinyK22 with USB HID Bootloader

Continue reading

Is Developing for ARM more difficult than for other Architectures?

I believe in ‘life-long-learning’. With this I continue to learn and discover new things every day. I’m writing tutorials to give something back to the community from which I have learned so much.

On top of this, I receive emails on a nearly daily basis, asking for help. Many articles have the origin in such requests or questions. I prefer questions or comments in a public forum, because that way I feel all others can benefit from it. Last week Alessandro contacted me with this:

“Hi Erich,

I hope this find you well! I’m starting to using ARM processors, but I find them quite complicated on the configuration side. I started in the past with PIC micro (PIC16) with asm, and I found them quite straightforward to be configured (clock, IO, peripherals, …). Then I moved myself on C language, and on PIC18 without any big issues.

Now I would really like join the ARM community, I see that these processors are what I’ve always looking for, on energy, calc power, peripherals, and FINALLY on IDE (editor, toolchain and utilities)… AMAZING!!!”

The topic is about how to start learning developing for ARM. Alessandro agreed to make this public, so I thought this might be a good topic for an article?

Firmware

Firmware

Continue reading

Cycle Counting on ARM Cortex-M with DWT

Some ARM Cortex-M have a DWT (Data Watchpoint and Trace) unit implemented, and it has a nice feature in that unit which counts the execution cycles. The DWT is usually implemented on most Cortex-M3, M4 and M7 devices, including e.g. the NXP Kinetis or LPC devices.

Continue reading

Tutorial: Running FreeRTOS on NXP i.MX7Dual Cortex-M4F

In my previous article (see “Tutorial: First Steps with NXP i.MX7 and Toradex Colibri Board“) I have booted the i.MX7 on a Toradex CPU module. In this post I’m showing how to run a FreeRTOS application on that board.

UART-A and UART-B Connections

UART-A and UART-B Connections

Continue reading

Tutorial: Using Single Wire Output SWO with ARM Cortex-M and Eclipse

As a standard procedure, I add some console functionality to my embedded applications. That way I have a command line interface and can inspect and influence the target system. One interesting hardware feature of ARM Cortex-M is Single Wire Output (SWO): it allows to send out data (e.g. strings) over up to 32 different stimulus ports, over a single wire.

swo-pin-on-arm-debug-header

swo-pin-on-arm-debug-header

Continue reading

First Steps with Ozone and the Segger J-Link Trace Pro

From time to time I face some problems which are really hard to find. Mostly these kind of bugs are very timing sensitive and depend on interrupt execution order. Maybe a dangling pointer is overwriting memory, code is running wild, or some functions are not reentrant as they should be. For these kind of bugs, good tools are worth their weight in gold. The Percepio FreeRTOS+Trace and the Segger SystemView have helped me many times to narrow down such kind problems in my applications. Another ultimate tools is hardware trace: Now I have a Segger J-Trace Pro for ARM Cortex-M in my arsenal of bug extinguishing weapons on my desk:
Dear bugs, look what I have on my desk. Your hiding time is over! 🙂

tracing-cortex-m4-with-j-trace

tracing-cortex-m4-with-j-trace

Continue reading