Martin Cowen (32)

Eliminate Useless Timer Interrupts by Coalescing Timers

While learning about RTOSes, I came across the idea of Timer Coalescing which improves performance by eliminating unnecessary context switches. But there is no reason that this technique cannot be applied to bare metal firmware (without RTOS). To test out how well it works, I implemented it using a STM32F4 discovery board. I wanted to see the improvement factor in a typical use case, so I decided on running 8 software timers on a 1ms timer peripheral. The software timers count down to 0 then reload themselves. From previous experience, typical periods were chosen for these timers of 1000, 200, 125, 50, 18, 27, 40 and 600ms. (If they had a common factor of say 5ms, then it would make more sense to use that as the peripheral timer rate, but it restricts the flexibility for future changes.) TIM6 was chosen because we only need a Basic 16 bit timer in the STM32F4 architecture. It runs off APB1 at 42 MHz (HCLK at 168 MHz). Prescaler was set to 41, Counter Period ARR set to 1999 for 1ms and auto-reload preload set to Disable. TIM6 interrupts were enabled. Once all this is set up in the Device Configuration Tool, all…

Continue reading...

How your Obeng Project Type affects your Planning, Methodology and Leadership

Knowing what kind of project you are working on can help you work out which planning method and software methodology to apply, as well as what management strategy to use. Once you have categorised your project into one of these four types, you will improve your expectations about the timescale and velocity. Not knowing about these project types leads to confusion about the project direction and pace, which can be demoralising for staff and leads to misunderstanding by customers, management and other departments. The trend in the last 20 years has been to apply Agile methodologies to all projects, but this Feabhas video explains why that isn't always a good idea. (The click-baity title isn't what it first appears). I'd like to expand on the video by looking at the relationship between these four project types and the appropriate planning and execution strategies. These four project types were described by Eddie Obeng, who said "As a project manager, as a business, we have to understand the type of project that we are working on because each type of project has a different management strategy associated with it. More specifically, we have to apply our effort in different places and in different ways…

Continue reading...

Trying to use nRF5 SDK 12.3.0 for nRF51 on a FreeRTOS project

Continuing from my Getting Started post, we now want to use the same method on a FreeRTOS example such as ble_app_hrs_freertos. When compiling, we get file include path problems, starting with nrf_ble_gatt.h. These can be fixed by adding the following entries into the Project - Options - Preprocessor - User Include Directories ../../../../../../components/ble/nrf_ble_gatt../../../../../../components/libraries/sensorsim../../../../../../external/freertos/source/include../../../../../../external/freertos/portable/ARM/nrf51../../../../../../external/freertos/portable/CMSIS/nrf51../../../config/ble_app_hrs_freertos_pca10028_s130But then we hit a problem in compiling 'port.c' - expected '(' before 'void' on line 92 port.c is in the Third Parties folder since it is a FreeRTOS file This is the compiler not accepting an asm void function, which isn't related to any changes I've made to get this to run but is a provided file. Let's see if it is any different in the later version of the SDK The source code is unchanged but the comments say that this file in SDK16 is for the Cortex M0, which is correct for an nRF51; rather than M4 which is correct for nRF52. But the port.c that is in the project is from SDK\external\freertos\portable\ARM\nrf51 which should be for M0, so why is there a mention of M4 in the SDK12 version? I've looked at differences in FreeRTOSConfig.h that each project uses, comparing the nRF52/SDK16 with the…

Continue reading...

Adding CMSIS Config Wizard to SES Projects

The CMSIS Config Wizard provides a GUI interface to many options which are otherwise tricky to set in sdk_config.h. To add it to your project, follow the instructions in this YouTube video, which I have summarised in text form below. First install Java. You might be lucky and already have Java installed, eg if you go to your Windows Settings - Apps & features and search for Java, if you see Java SE Development Kit then it is installed. File - Open Studio Folder - External Tools Configuration Paste in the following to replace the existing contents <tools> <!-- PC-lint - http://www.gimpel.com/html/pcl.htm --> <if host_os="win"> <item name="Tool.PClint"> <menu>&amp;PC-lint (Unit Check)</menu> <text>PC-lint (Unit Check)</text> <tip>Run a PC-lint unit checkout on the selected file or folder</tip> <key>Ctrl+L, Ctrl+P</key> <match>*.c;*.cpp</match> <message>Linting</message> <commands> &quot;$(LINTDIR)/lint-nt&quot; -v -incvar(__CW_ARM) -i$(LINTDIR)/lnt co-gcc.lnt $(DEFINES) $(INCLUDES) -D__GNUC__ -u -b +macros +macros -w2 -e537 +fie +ffn -width(0,4) -hF1 &quot;-format=%f:%l:%C:\s%t:\s%m [-e%n]&quot; &quot;$(InputPath)&quot; </commands> </item> <item name="Tool.CMSIS_Config_Wizard" wait="no"> <menu>&amp;CMSIS Configuration Wizard</menu> <text>CMSIS Configuration Wizard</text> <tip>Open a configuration file in CMSIS Configuration Wizard</tip> <key>Ctrl+Y</key> <match>*config*.h</match> <message>CMSIS Config</message> <commands> java -jar &quot;$(CMSIS_CONFIG_TOOL)&quot; &quot;$(InputPath)&quot; </commands> </item></if></tools> Save this file, close and restart SES (a project reload is insufficient). Project - Options - Common - Build…

Continue reading...

Getting started with Nordic Semiconductor's nRF51 DK and Segger Embedded Studio

Choosing a Dev KitThe nRF51 is recent enough to be supported by a mature development environment and to have lots of others try it out before me. The Development Kit comes in a handy sized board which only needs micro USB for power and data, and has a built in SEGGER JLink debug chip, as well as 4 user buttons and LEDs, and all the usual ports. It uses the nRF51422 which is Cortex M0 based, so I thought it would be a good way to do some M0 development work. In comparison, the later nRF52 series are M4 based, more capable but more expensive. I decided I didn't need the feature of the nRF52/Cortex M4, which was my first mistake. Nordic's Getting Started Guide v1.3, which covers the nRF51 DK, recommends Segger SES as the preferred development enviroment and is supported by Nordic. While they also provide support for Keil, IAR, and GNU/GCC, the agreement with Segger is that they will licence it for free for use with Nordic chips. Since the nRF51-DK comes with a Segger J-Link debugger chip built in and I had previously noted that Segger seemed to be one of the premium brands for ARM Cortex…

Continue reading...