ARM Cortex-M Interrupts and FreeRTOS: Part 3


This is the third part about ARM Cortex-M and how the interrupts are used. In Part 1 I discussed the Cortex-M interrupt system and in Part 2 I showed nested interrupt examples. This part is about FreeRTOS and how it uses the Cortex-M interrupt system.

NXP KV58F ARM Cortex-M7

NXP KV58F ARM Cortex-M7

Continue reading

Advertisements

ARM Cortex-M, Interrupts and FreeRTOS: Part 2


In “ARM Cortex-M, Interrupts and FreeRTOS: Part 1”  I started with the ARM Cortex-M interrupt system. Because the ARM implementation cann be very confusing, I confused myself and had to fix and extend the description in Part 1 :-). Thank for all the feedback and comments!

Originally I wanted to cover FreeRTOS in Part 2. Based on the questions and discussions in Part 1 I thought it might be a good idea to provide visual examples.

NXP KV58F ARM Cortex-M7

NXP KV58F ARM Cortex-M7

Continue reading

ARM Cortex-M, Interrupts and FreeRTOS: Part 1


The ARM Cortex-M microcontroller are insanely popular. And it features a flexible and powerful nested vectored interrupt controller (NVIC). But for many, including myself, the Cortex-M interrupt system can be counter-intuitive, complex, inconsistent and confusing, leading to many bugs and lots of frustration :-(.

NXP KV58F ARM Cortex-M7

ARM Cortex-M7: NXP KV58

Understanding the NVIC and the ARM Cortex-M interrupt system is essential for every embedded application, but even for if using an realtime operating system: if you mess up with interrupts, very bad things will happen….

Continue reading

GNU Static Stack Usage Analysis


Stack overflows are a big problem: If I see a system crash, the first thing usually is I try to increase the stack size to see if the problem goes away. The GNU linker can check if my global variables fit into RAM. But it cannot know how much stack I need. So how cool would it be to have a way to find out how much stack I need?

Static Stack Usage Analysis with GNU

Static Stack Usage Analysis with GNU

And indeed, this is possible with the GNU tools (e.g. I’m using it with the GNU ARM Embedded (launchpad) 4.8 and 4.9 compilers :-). But it seems that this ability is not widely known?

Continue reading

Tutorial: Adafruit WS2812B NeoPixels with the Freescale FRDM-K64F Board – Part 5: DMA


This is Part 5 of a Mini Series. In Part 4, I described how to set up the FTM (Kinetis Flex Timer Module) to generate the required waveforms used for DMA operations (see “Tutorial: Adafruit WS2812B NeoPixels with the Freescale FRDM-K64F Board – Part 4: Timer“). In this post I describe how to use to trigger DMA (Direct To Memory) events. The goal is to drive Adafruit’s NeoPixel (WS2812B) with the Freescale FRDM-K64F board:

FRDM-K64F with Adafruit NeoPixel

FRDM-K64F with Adafruit NeoPixel

Continue reading

Tutorial: Adafruit WS2812B NeoPixels with the Freescale FRDM-K64F Board – Part 3: Concepts


This is Part 3 of a Mini Series. In Part 2, I described how to set up the development tools and to debug the first project (see “Tutorial: Adafruit WS2812B NeoPixels with the Freescale FRDM-K64F Board – Part 2: Software Tools“). Now it is time to look into the software concepts. The goal is to drive Adafruit’s NeoPixel (WS2812B) with the Freescale FRDM-K64F board:

Adafruit 8x8 NeoPixel Shield with Freescale FRDM-K64F Board

Adafruit 8×8 NeoPixel Shield with Freescale FRDM-K64F Board

Continue reading

Debugging ARM Cortex-M Hard Faults with GDB Custom Command


In “A Processor Expert Component to Help with Hard Faults” I’m using a C handler with some assembly code, created with Processor Expert, to help me with debugging hard faults on ARM Cortex-M. Inspired by a GNU gdb script here, I have now an alternative way. As this approach is using the GDB command line approach, it works both with an Eclipse GUI and with using GDB in command line mode only :-).

GDB script to debug ARM Hard Faults

GDB script to debug ARM Hard Faults

Continue reading

Tutorial: How to Erase the FLASH with the GNU GDB debugger


I have several applications where I store application specific information in the microcontroller FLASH memory (see “Configuration Data: Using the Internal FLASH instead of an external EEPROM“). I have run into issues recently with the Segger J-Link GDB server as by default it does *not* erase all the FLASH memory. So the question is: How can I erase all (or part) of the FLASH memory with GDB (e.g. in Kinetis Design Studio or in Eclipse)?

Memory Monitor with Erased Flash

Memory Monitor with Erased Flash

Continue reading

NeoShield: WS2812 RGB LED Shield with DMA and nRF24L01+


In my earlier post I used a hacked together shield for building a clock based on Adafruit’s NeoPixel/WS2812 (“LED Clock with Kitchen Hot Pan Protector“). The new design supports now 8 parallel data streams, integrated realtime clock and wireless connectivity with the nRF24L01+ module.

NeoPixel Shield for FRDM Boards

NeoPixel Shield for FRDM Boards

Continue reading

RAM Target with Kinetis Design Studio and FRDM-K64F


Newer microcontroller have increase RAM areas, making it suitable to run the application from RAM instead of FLASH. For the FRDM-K64F board and the Kinetis Design Studio (V1.1.1), I have explored how to run the application out of RAM instead of FLASH memory, both for P&E and Segger connections.

MK64FN1M0VLL12

MK64FN1M0VLL12

Continue reading

Configuration Data: Using the Internal FLASH instead of an external EEPROM


Many applications need to store persistent (non-volatile) data at runtime: configuration data, error logs, sensor data, calibration values, etc. The question is: where to store that data? If it is only a few kBytes, an SD card or similar is an overkill. Adding an external EEPROM? Sure, that works, but adds an extra part to the design. Some microcontroller have internal EEPROM. But what if not? Why not using the microprocessor internal flash memory?

Internal FLASH vs. external EEPROM

Internal FLASH vs. external EEPROM

Continue reading

Tutorial: User Interrupts with Processor Expert


I have been asked this question several times:

“How can I define my own interrupt vector with Processor Expert?”

So I think it deserves a short tutorial, if more than one person is asking this ;-).

My user interrupt in the vector table

My user interrupt in the vector table

Continue reading

Starting Point for Kinetis Low Power LLS Mode


In “IoT: FreeRTOS Down to the Micro Amps” I’m using an application with FreeRTOS to get down in micro amps low power mode. Well, nearly all or my applications are using FreeRTOS because it makes the application scalable and extensible. Still, for anyone not used to an RTOS, that might be a hard start. So here we go: how to get into the Kinetis Low Power LLS Mode *without* an RTOS.

Power Measurement

Power Measurement

Continue reading

CriticalSection Component


I have created and published on GitHub a new component ‘CriticalSection’:

Critical Section Component Methods

Critical Section Component Methods

This component is a wrapper between my components and the problematic current implementation in Processor Expert (see EnterCritical() and ExitCritical(): Why Things are Failing Badly). It uses a flexible approach and uses macros to either use my modified version of EnterCritical() and ExitCritical(), or simply defaults to the original implementation.

Continue reading

Tutorial: Ultra Low Cost 2.4 GHz Wireless Transceiver with the FRDM Board


For my embedded systems lecture I need a wireless connection to the robot we will develop during that course. So far I have SMAC (IEEE802.15.4) and Bluetooth worked out. But that IEEE802.15.4 (ZigBee) is expensive, and the cheap Bluetooth modules are great for robot-to-host connection, but not for swarm robots which need to communicate to each other. Alex Vecchio (see this post) pointed me to a $2.75 (!) wireless module featuring the Nordic Semiconductor nRF24L01+. Exactly what I needed, with an incredible low price :-).

nRF24L01+ Module Detail

nRF24L01+ Module Detail

Continue reading

Bricking and Recovering FRDM-KL25Z Boards: Reset, SWD Clock and Low Power


I’m working with a student on building a small autonomous robot platform, based on the FRDM-KL25Z board. We integrated new software modules, compiled and linked, and then downloaded the application to the board. While debugging and stepping through the application startup, I had this:

The Debugger has lost communication on connection

The Debugger has lost communication on connection

Outsch! That’s not good. Even worse, trying to connect again to the board failed :-(. What happened?

Continue reading

Tutorial: Arduino Motor/Stepper/Servo Shield – Part 2: Timed Servo Moves


You have decided: More than 52% voted in Part 1 that the next topic should be Timed Servo Moves. So here we go :-).

This is about how to move the servos over time, instead of moving it to the given position as fast as possible. I’m using a linear approach here: moving the servos linearly over time.

Moving Servo Motors

Moving Servo Motors

Continue reading

Zumo Line Following with FRDM-KL25Z


With the Zumo I have a base platform for cool robotics applications. So why not build a line following robot with this? Especially as Pololu offers a reflectance sensor array for it. The result is: I have a line following robot 🙂

Line Following ZumoBot

Line Following ZumoBot

It turned out that things were not working out of the box with the FRDM-KL25Z board. So if you want to do the same thing, here are some tips how to make it working with the Freedom board.

Continue reading

Traps&Pitfalls: Overlapping Interrupt Priorities


It happens to me that I run into a really, really nasty problem. I spend hours (if not weeks) to get it resolved. Strong coffee and the problem keeps me up at long nights. I think every embedded system engineer knows what I’m talking about. Yeah, most of the time it is my fault or an oversight. But once in a while I’m convinced that I have found a real bug. Then I report it back to the vendor to fix it. I hope my report will prevent another engineers to run into the same problem. Or that I learn something else as a by-product. Oh yes….

Continue reading