Martin Cowen (45)

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_s130 But 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…

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 -…

Continue reading...

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

Choosing a Dev Kit The 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…

Continue reading...

Improving frequency measurement performance by factor of three on STM32 by using DMA

This Youtube video by Controllers Tech shows how to use an STM32 to measure the frequency of an incoming rectangular wave using the input capture functionality of the timers. The code shown the video works but there are a few areas which could be improved, as I will now discuss. Then I make a performance improvement by using DMA instead of interrupts. The code is written using STM's HAL library which means that it does not have to handle the specific STM32's registers, which makes it more portable. However, HAL is still specific to the ARM and STM architecture, so you need to know what features are available in your internal peripherals to be able to write HAL function calls with the appropriate parameters. Initialising Global variables Controllers Tech declares a set of global variables at the top of main.c and initialises them to zero. Since we can rely on the C runtime to clear the RAM, this is unnecessary for globals and can use up code space and boot time. I would remove the initialisations unless it is thought likely that these lines would be moved into a function, making them local automatic variables, in which case they would need to be…

Continue reading...

Replaying a captured 'scope trace using a Siglent DSO and FeelTech FY6900

When you are developing an embedded device, you often find yourself capturing an interesting signal with the 'scope that you would like to send back into your device. If you have invested in an Arb from the same family as your 'scope then this is as easy as moving a USB Flash drive from the 'scope to the Arb, but such Arbs are not the cheapest option out there. Since choosing the FeelTech FY6900 as my Arb, I found that it's software "DDS Signal PC Software" can import a list of points but the format is not the same as exported by the Siglent SDS 1104X-E. So I wrote a utility to convert from one to the other, and with some additional options. This is a utility for converting scope captures from a Siglent Digital Storage Oscilloscope into a format which is usable by a FeelElec FY6900 DDS Function/Arbitrary Waveform Generator so that it can stored in one of the Arb memories for replay. This utility is only a file converter and does not communicate with the FY6900, so you need to have installed the FeelTech “DDS Signal PC Software” and the USB cable so that the resultant waveform can…

Continue reading...