<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Teach Me Microcontrollers: Arduino, ESP32 &amp; Electronics Tutorials</title>
	<atom:link href="https://www.teachmemicro.com/category/tutorials/nrf52-tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.teachmemicro.com/3-3v-5v-logic-level-shifting-arduino-esp32/</link>
	<description>Microcontroller Tutorials and Resources</description>
	<lastBuildDate>Thu, 31 Oct 2024 23:30:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>

<image>
	<url>https://www.teachmemicro.com/wp-content/uploads/2019/04/blue-icon-65x65.png</url>
	<title>Teach Me Microcontrollers: Arduino, ESP32 &amp; Electronics Tutorials</title>
	<link>https://www.teachmemicro.com/3-3v-5v-logic-level-shifting-arduino-esp32/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>nRF52 Development Kit Comparison: Which One Should You Choose?</title>
		<link>https://www.teachmemicro.com/nrf52-development-kit-comparison-which-one-should-you-choose/</link>
		
		<dc:creator><![CDATA[Roland Pelayo]]></dc:creator>
		<pubDate>Sat, 19 Oct 2024 01:00:14 +0000</pubDate>
				<category><![CDATA[nRF52 Tutorial]]></category>
		<guid isPermaLink="false">https://www.teachmemicro.com/?p=7431</guid>

					<description><![CDATA[<p>The nRF52 series by Nordic Semiconductor has been a game-changer in the world of low-power wireless communication. Whether you’re working on Bluetooth Low Energy (BLE), ANT, or 2.4 GHz proprietary protocols, the nRF52 family offers versatile and robust solutions. Choosing the right development kit, however, can be overwhelming with several options available. In this article, &#8230;</p>
<p>The post <a href="https://www.teachmemicro.com/nrf52-development-kit-comparison-which-one-should-you-choose/">nRF52 Development Kit Comparison: Which One Should You Choose?</a> appeared first on <a href="https://www.teachmemicro.com">Teach Me Microcontrollers!</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The nRF52 series by Nordic Semiconductor has been a game-changer in the world of low-power wireless communication. Whether you’re working on Bluetooth Low Energy (BLE), ANT, or 2.4 GHz proprietary protocols, the nRF52 family offers versatile and robust solutions. Choosing the right development kit, however, can be overwhelming with several options available. In this article, we’ll compare the different nRF52 development kits and help you decide which one suits your project best.</p>
<p><span id="more-7431"></span></p>
<h3><strong>Overview of nRF52 Series</strong></h3>
<p>Before diving into the development kits, let’s briefly discuss what makes the nRF52 series so popular. The series is built on a powerful ARM Cortex-M4 CPU and offers excellent RF performance, low power consumption, and multiple I/O peripherals. The key features that make the nRF52 series attractive include:</p>
<div class="starlist tie-list-shortcode">
<ul>
<li><strong>Bluetooth 5.3 Support:</strong> With improvements in speed, range, and throughput.</li>
<li><strong>Power Efficiency:</strong> Ideal for battery-operated applications.</li>
<li><strong>Flexible Multiprotocol Support:</strong> BLE, ANT, and proprietary 2.4 GHz communication.</li>
<li><strong>Advanced Security Features:</strong> Including hardware cryptographic accelerators.</li>
<li><strong>Extensive SDK:</strong> Nordic’s Software Development Kit (SDK) offers various examples, libraries, and APIs to speed up development.</li>
</ul>
</div>
<p>Now let’s move on to the development kits themselves.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3><strong>1. nRF52832 Development Kit (PCA10040)</strong></h3>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" src="https://developer.nordicsemi.com/nRF_Connect_SDK/doc-legacy/1.5.1/zephyr/_images/nrf52dk_nrf52832.jpg" alt="nRF52 DK — Zephyr Project Documentation" class="aligncenter" width="442" height="263" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class="box note  " style="width:600px"><div class="box-inner-block"><i class="fa tie-shortcode-boxicon"></i>
			
<p><strong>Chip:</strong> nRF52832</p>
<p><strong>Flash/RAM:</strong> 512 KB / 64 KB</p>
<p><strong>GPIO:</strong> 48 pins</p>
<p><strong>Peripherals:</strong> SPI, I2C, UART, PWM, ADC, etc.</p>
<p><strong>Power Source:</strong> USB or external battery</p>
<p><strong>BLE Support:</strong> Bluetooth 5.0</p>
<p><strong>Programming and Debugging:</strong> On-board Segger J-Link</p>
<p><strong>Best For: </strong>General BLE Applications: If you are looking to develop basic BLE applications, the nRF52832 development kit is an excellent choice. It provides all the necessary features for simple BLE projects like beacons, fitness trackers, or IoT nodes.</p>

			</div></div>
<p><strong>Pros:</strong></p>
<div class="thumbup tie-list-shortcode">
<ul>
<li>Affordable.</li>
<li>Versatile I/O options.</li>
<li>Supported by the nRF Connect SDK and Nordic's SoftDevices.</li>
</ul>
</div>
<p><strong>Cons:</strong></p>
<div class="thumbdown tie-list-shortcode">
<ul>
<li>Lacks some advanced features found in more recent nRF52 chips.</li>
</ul>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3><strong>2. nRF52840 Development Kit (PCA10056)</strong></h3>
<p><img loading="lazy" decoding="async" src="https://img.alicdn.com/imgextra/i4/2207330432360/O1CN01yVHLnI1TIvTKmKxmN_!!2-item_pic.png" alt="现货nRF52840-DK Kit DK pca10056 Bluetooth 5蓝牙开发板Nordic-Taobao Malaysia" width="452" height="452" class="aligncenter" /></p>
<div class="box note  " style="width:600px"><div class="box-inner-block"><i class="fa tie-shortcode-boxicon"></i>
			
<p><strong>Chip:</strong> nRF52840</p>
<p><strong>Flash/RAM:</strong> 1 MB / 256 KB</p>
<p><strong>GPIO:</strong> 48 pins</p>
<p><strong>Peripherals:</strong> USB, SPI, I2C, UART, NFC, PWM, ADC, etc.</p>
<p><strong>Power Source:</strong> USB, external battery</p>
<p><strong>BLE Support:</strong> Bluetooth 5.3</p>
<p><strong>Programming and Debugging:</strong> On-board Segger J-Link</p>
<p><strong>Best For:</strong> High-End BLE Applications: If your project requires advanced Bluetooth features like Long Range, high throughput, or direction-finding, the nRF52840 is the way to go. It’s also a great option for USB devices thanks to its integrated USB 2.0 controller.</p>

			</div></div>
<p><strong>Pros:</strong></p>
<div class="thumbup tie-list-shortcode">
<ul>
<li>Largest memory capacity in the nRF52 family.</li>
<li>Supports BLE 5.3, Thread, Zigbee, and 802.15.4.</li>
<li>Great for advanced applications like mesh networking.</li>
</ul>
</div>
<p><strong>Cons:</strong></p>
<div class="thumbdown tie-list-shortcode">
<ul>
<li>More expensive than the nRF52832 development kit.</li>
</ul>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3><strong>3. nRF52833 Development Kit (PCA10100)</strong></h3>
<p><img loading="lazy" decoding="async" src="https://circuitpython.org/assets/images/boards/large/pca10100.jpg" alt="nRF52833 DK (PCA10100) Download" class="aligncenter" width="581" height="447" /></p>
<div class="box note  " style="width:600px"><div class="box-inner-block"><i class="fa tie-shortcode-boxicon"></i>
			
<p><strong>Chip:</strong> nRF52833</p>
<p><strong>Flash/RAM:</strong> 512 KB / 128 KB</p>
<p><strong>GPIO:</strong> 42 pins</p>
<p><strong>Peripherals:</strong> USB, SPI, I2C, UART, PWM, ADC, NFC</p>
<p><strong>Power Source:</strong> USB, external battery</p>
<p><strong>BLE Support:</strong> Bluetooth 5.1</p>
<p><strong>Programming and Debugging:</strong> On-board Segger J-Link</p>
<p><strong>Best For:</strong> Cost-Effective with USB Support: If you need a development kit with USB capabilities but don’t require the extensive memory of the nRF52840, the nRF52833 is a good choice. It strikes a balance between performance and price, making it ideal for mid-range projects.</p>

			</div></div>
<p><strong>Pros:</strong></p>
<div class="thumbup tie-list-shortcode">
<ul>
<li>Supports Bluetooth Direction Finding (AoA/AoD).</li>
<li>Better RAM than the nRF52832.</li>
<li>Cost-effective compared to the nRF52840.</li>
</ul>
</div>
<p><strong>Cons:</strong></p>
<div class="thumbdown tie-list-shortcode">
<ul>
<li>Less flash memory compared to the nRF52840.</li>
</ul>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3><strong>4. nRF52811 Development Kit (PCA10056e)</strong></h3>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><img loading="lazy" decoding="async" src="https://www.teachmemicro.com/wp-content/uploads/2024/10/nRF52840-DK-1024x500.jpg" alt="" width="618" height="302" class="aligncenter wp-image-7439 size-large" srcset="https://www.teachmemicro.com/wp-content/uploads/2024/10/nRF52840-DK-1024x500.jpg 1024w, https://www.teachmemicro.com/wp-content/uploads/2024/10/nRF52840-DK-300x147.jpg 300w, https://www.teachmemicro.com/wp-content/uploads/2024/10/nRF52840-DK-768x375.jpg 768w, https://www.teachmemicro.com/wp-content/uploads/2024/10/nRF52840-DK.jpg 1187w" sizes="auto, (max-width: 618px) 100vw, 618px" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class="box note  " style="width:600px"><div class="box-inner-block"><i class="fa tie-shortcode-boxicon"></i>
			
<p><strong>Chip:</strong> nRF52811</p>
<p><strong>Flash/RAM:</strong> 192 KB / 24 KB</p>
<p><strong>GPIO:</strong> 48 pins</p>
<p><strong>Peripherals:</strong> SPI, I2C, UART, PWM, ADC</p>
<p><strong>Power Source:</strong> USB, external battery</p>
<p><strong>BLE Support:</strong> Bluetooth 5.1 (including Direction Finding)</p>
<p><strong>Programming and Debugging:</strong> On-board Segger J-Link</p>
<p><strong>Best For:</strong> Entry-Level BLE Projects: The nRF52811 development kit is ideal for cost-sensitive applications where you need Bluetooth 5 features like AoA (Angle of Arrival) and AoD (Angle of Departure) without needing large memory or advanced features.</p>

			</div></div>
<p><strong>Pros: </strong></p>
<div class="thumbup tie-list-shortcode">
<ul>
<li>Inexpensive.</li>
<li>Ideal for Bluetooth 5.1 projects like direction-finding applications.</li>
</ul>
</div>
<p><strong>Cons:</strong></p>
<div class="thumbdown tie-list-shortcode">
<ul>
<li>Limited memory.</li>
<li>Fewer advanced features compared to other nRF52 kits.</li>
</ul>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3><strong>5. nRF5340 Development Kit (PCA10095)</strong></h3>
<p><img loading="lazy" decoding="async" src="https://docs.zephyrproject.org/2.7.5/_images/nrf5340dk.jpg" alt="nRF5340 DK — Zephyr Project Documentation" width="665" height="665" class="aligncenter" /></p>
<div class="box note  " style="width:600px"><div class="box-inner-block"><i class="fa tie-shortcode-boxicon"></i>
			
<p><strong>Chip:</strong> nRF5340 (Dual-Core: Application Core and Network Core)</p>
<p><strong>Flash/RAM:</strong> 1 MB / 512 KB (App Core), 256 KB / 64 KB (Net Core)</p>
<p><strong>GPIO:</strong> 48 pins</p>
<p><strong>Peripherals:</strong> USB, SPI, I2C, UART, PWM, ADC, NFC</p>
<p><strong>Power Source:</strong> USB, external battery</p>
<p><strong>BLE Support:</strong> Bluetooth 5.3</p>
<p><strong>Programming and Debugging:</strong> On-board Segger J-Link</p>
<p><strong>Best For:</strong> Advanced Multiprotocol Projects: The nRF5340 is Nordic’s most advanced SoC, perfect for cutting-edge applications that require dual-core architecture. One core can handle network operations (e.g., BLE, Zigbee), while the other core processes the application logic, making it suitable for complex IoT, wearable, or industrial projects.</p>

			</div></div>
<p><strong>Pros:</strong></p>
<div class="thumbup tie-list-shortcode">
<ul>
<li>Dual-core architecture provides great flexibility.</li>
<li>Ideal for power-sensitive and complex applications.</li>
<li>Supports multiple protocols like Bluetooth 5.3, Thread, and Zigbee.</li>
</ul>
</div>
<p><strong>Cons:</strong></p>
<div class="thumbdown tie-list-shortcode">
<ul>
<li>The most expensive in the nRF52 family.</li>
<li>Overkill for simpler BLE projects.</li>
</ul>
</div>
<p>&nbsp;</p>
<h3><strong>Conclusion</strong></h3>
<p>Choosing the right development kit depends on the complexity of your project and the specific features you need. Here’s a quick summary:</p>
[table id=1 /]
<div class="starlist tie-list-shortcode">
<ul>
<li><strong>nRF52832 Development Kit:</strong> Best for general BLE applications and cost-conscious projects.</li>
<li><strong>nRF52840 Development Kit:</strong> Ideal for advanced Bluetooth applications and USB integration.</li>
<li><strong>nRF52833 Development Kit:</strong> A balance between performance and price, suitable for direction-finding and USB.</li>
<li><strong>nRF52811 Development Kit:</strong> Perfect for entry-level projects with Bluetooth 5.1 features.</li>
<li><strong>nRF5340 Development Kit:</strong> For high-end, complex applications requiring dual-core processing.</li>
</ul>
</div>
<p>No matter which kit you choose, Nordic's nRF Connect SDK and Segger Embedded Studio will ensure a smooth development experience. Happy coding!</p>
<p>&nbsp;</p>
<p>The post <a href="https://www.teachmemicro.com/nrf52-development-kit-comparison-which-one-should-you-choose/">nRF52 Development Kit Comparison: Which One Should You Choose?</a> appeared first on <a href="https://www.teachmemicro.com">Teach Me Microcontrollers!</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Setting up a New Project in Segger Embedded Studio for nRF52 Using a Project Template</title>
		<link>https://www.teachmemicro.com/setting-up-a-new-project-in-segger-embedded-studio-for-nrf52-using-a-project-template/</link>
		
		<dc:creator><![CDATA[Roland Pelayo]]></dc:creator>
		<pubDate>Wed, 02 Oct 2024 01:00:22 +0000</pubDate>
				<category><![CDATA[nRF52 Tutorial]]></category>
		<guid isPermaLink="false">https://www.teachmemicro.com/?p=7328</guid>

					<description><![CDATA[<p>When working with Segger Embedded Studio (SES) and Nordic's nRF52 chips, one of the quickest ways to get started is by using an existing project template. It simplifies project setup, reducing the need for manual configuration, and you can focus on development right away. In this guide, I'll walk you through setting up a project &#8230;</p>
<p>The post <a href="https://www.teachmemicro.com/setting-up-a-new-project-in-segger-embedded-studio-for-nrf52-using-a-project-template/">Setting up a New Project in Segger Embedded Studio for nRF52 Using a Project Template</a> appeared first on <a href="https://www.teachmemicro.com">Teach Me Microcontrollers!</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><span style="font-weight: 400;">When working with Segger Embedded Studio (SES) and Nordic's nRF52 chips, one of the quickest ways to get started is by using an existing project template. It simplifies project setup, reducing the need for manual configuration, and you can focus on development right away. In this guide, I'll walk you through setting up a project using an nRF52 SES template and explain the project structure, which follows the typical SDK layout like PCA10040.</span></p>
<h3><b>Cloning the nRF52 SES Template</b></h3>
<p><span style="font-weight: 400;">To begin, we’ll use a pre-configured template available on GitHub, which already has some of the initial settings in place. Clone or download the repository from</span><a href="https://github.com/eldstal/nrf52-ses-template"> <span style="font-weight: 400;">this link</span></a><span style="font-weight: 400;">:</span></p>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-plain" data-lang="Plain Text"><code>git clone https://github.com/eldstal/nrf52-ses-template.git</code></pre>
</div>
<p><span style="font-weight: 400;">Once you have the project downloaded, extract the files or navigate to the directory where you cloned the repository.</span></p>
<h3><b>Understanding the SES Project Structure</b></h3>
<p><span style="font-weight: 400;">The structure of an SES project for nRF52 typically follows the layout used in Nordic's SDK. If you're using the PCA10040 SDK, the project is organized in a standard folder hierarchy. Here's a breakdown:</span></p>
<p><b>Project Folder</b><span style="font-weight: 400;">: This is the root of your project, where the </span><span style="font-weight: 400;">main.c</span><span style="font-weight: 400;"> file resides. This file contains the main application code for your project.</span><span style="font-weight: 400;"><br />
</span></p>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-bash" data-lang="Bash"><code>Project_Folder/
├── main.c
└── pca10040/</code></pre>
</div>
<p><b>pca10040 Folder</b><span style="font-weight: 400;">: This folder is specific to the nRF52832-based development kit (PCA10040). Inside, you'll find specific configurations for this board. </span><span style="font-weight: 400;"><br />
</span></p>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-bash" data-lang="Bash"><code>Project_Folder/
├── pca10040/
└── s132/</code></pre>
</div>
<p><b>s132 Folder</b><span style="font-weight: 400;">: This folder corresponds to the SoftDevice you're using, such as S132 for Bluetooth applications on nRF52832.</span></p>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-bash" data-lang="Bash"><code>Project_Folder/
├── pca10040/
└── s132/
└── ses/</code></pre>
</div>
<p><b>ses Folder</b><span style="font-weight: 400;">: This folder contains the Segger Embedded Studio project files, including the </span><span style="font-weight: 400;">.emProject</span><span style="font-weight: 400;"> file that opens the project in SES and </span><i><span style="font-weight: 400;">flash_placement.xml</span></i><span style="font-weight: 400;"> which outlines the memory layout of the nRF52. If you have user-defined headers and source code, it is also advisable to put them in here.</span><span style="font-weight: 400;"><br />
</span></p>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-bash" data-lang="Bash"><code>Project_Folder/
├── pca10040/
├── s132/
└── ses/
    └── your_project.emProject
    └── flash_placement.xml
    └── Source/
       └── user-defined-source-1.c
       └── user-defined-source-2.c
    └── Include/
       └── user-defined-header-1.h
       └── user-defined-header-2.h
    └── Output/
       └── Debug/
            └── Exe/  --&gt; .elf, .hex, .map files are here
            └── Obj/  --&gt; .o files are here</code></pre>
</div>
<p><span style="font-weight: 400;">Thus, when you open the project in SES, you'll typically navigate to </span><em><span style="font-weight: 400;">pca10040 &gt; s132 &gt; ses</span></em><span style="font-weight: 400;"> to locate the </span><em><span style="font-weight: 400;">.emProject</span></em><span style="font-weight: 400;"> file, which is the project’s entry point.</span></p>
<p>The Output folder will be created when the project successfully compiles. If you have a <em>Debug</em> configuration, you will see a Debug folder and inside it are the binaries you need to upload to the nRF52 SDK as well as the compiled object files.</p>
<h3><b>Opening the Project in SES</b></h3>
<p><span style="font-weight: 400;">Once you have your folder structure and project files set up, open the project in SES:</span></p>
<ol>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">In SES, go to </span><b>File</b><span style="font-weight: 400;"> &gt; </span><b>Open Solution</b><span style="font-weight: 400;">.</span></li>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Navigate to </span><em><span style="font-weight: 400;">Project_Folder &gt; pca10040 &gt; s132 &gt; ses</span></em><span style="font-weight: 400;"> and select the </span><span style="font-weight: 400;">.emProject</span><span style="font-weight: 400;"> file.</span></li>
</ol>
<p><span style="font-weight: 400;">This will open the project with pre-configured settings for the PCA10040 development kit and the S132 SoftDevice, assuming you’re working with Bluetooth.</span></p>
<h3><b>Configuring the SDK Path</b></h3>
<p><span style="font-weight: 400;">After opening the project, you'll need to configure the SDK path so SES can find the necessary files. </span></p>
<p><span style="font-weight: 400;">You can create a macro to specify your SDK location and use that everywhere in the project. In <em><strong>Project Explorer &gt; Options</strong></em>, select <strong><em>Debug &gt; Build</em></strong>. Under the <em>Project Macros</em> field, browse the location of your SDK file. You can also make the location relative to the <em>.emProject</em> file for portability. For example, my SDK is always five folders above my <em>.emProject</em> file:</span></p>
<p><img loading="lazy" decoding="async" src="https://www.teachmemicro.com/wp-content/uploads/2024/10/SES-configuration.jpg" alt="" width="933" height="368" class="aligncenter wp-image-7386 size-full" srcset="https://www.teachmemicro.com/wp-content/uploads/2024/10/SES-configuration.jpg 933w, https://www.teachmemicro.com/wp-content/uploads/2024/10/SES-configuration-300x118.jpg 300w, https://www.teachmemicro.com/wp-content/uploads/2024/10/SES-configuration-768x303.jpg 768w" sizes="auto, (max-width: 933px) 100vw, 933px" /></p>
<p>You also need to specify the location of your libraries.</p>
<ol>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Right-click on your project in the </span><b>Project Explorer</b><span style="font-weight: 400;"> and select </span><b>Options</b><span style="font-weight: 400;">.</span></li>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Go to </span><b>Common</b><span style="font-weight: 400;"> &gt; </span><b>Preprocessor</b><span style="font-weight: 400;"> &gt; </span><b>User Include Directories</b><span style="font-weight: 400;">.</span></li>
</ol>
<p><span style="font-weight: 400;">Add the paths to your nRF5 SDK installation. For example:</span><span style="font-weight: 400;"><br />
</span></p>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-bash" data-lang="Bash"><code>$(SDKDir)/components/ble/ble_advertising
$(SDKDir)/components/ble/ble_db_discovery
$(SDKDir)/components/ble/ble_dtm
$(SDKDir)/components/ble/ble_link_ctx_manager
$(SDKDir)/components/ble/ble_racp
$(SDKDir)/components/ble/ble_services/ble_ancs_c
...</code></pre>
</div>
<p><img loading="lazy" decoding="async" src="https://www.teachmemicro.com/wp-content/uploads/2024/10/SES-configuration-modules-300x100.jpg" alt="" width="300" height="100" class="alignnone size-medium wp-image-7387" srcset="https://www.teachmemicro.com/wp-content/uploads/2024/10/SES-configuration-modules-300x100.jpg 300w, https://www.teachmemicro.com/wp-content/uploads/2024/10/SES-configuration-modules-1024x340.jpg 1024w, https://www.teachmemicro.com/wp-content/uploads/2024/10/SES-configuration-modules-768x255.jpg 768w, https://www.teachmemicro.com/wp-content/uploads/2024/10/SES-configuration-modules.jpg 1140w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<p><span style="font-weight: 400;">This ensures that the project can locate the necessary headers, drivers, and libraries provided by the SDK.</span></p>
<h3><b>Modifying </b><b>sdk_config.h</b></h3>
<p><span style="font-weight: 400;">The </span><span style="font-weight: 400;">sdk_config.h</span><span style="font-weight: 400;"> file is the configuration hub for enabling or disabling various modules in your project. The project template includes an </span><span style="font-weight: 400;">sdk_config.h</span><span style="font-weight: 400;"> file, but you may need to tweak it based on your needs. For example, if you want to enable UART logging, you would modify:</span></p>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-bash" data-lang="Bash"><code>#define NRF_LOG_ENABLED 1</code></pre>
</div>
<p><span style="font-weight: 400;">Each peripheral or library you want to use must be enabled in this file. So, depending on whether you're using Bluetooth, UART, GPIO, or other features, you'll need to adjust the </span><span style="font-weight: 400;">sdk_config.h</span><span style="font-weight: 400;"> accordingly.</span></p>
<p><span style="font-weight: 400;">See the examples folder inside the SDK to view how each project contains different </span><i><span style="font-weight: 400;">sdk_config.h</span></i><span style="font-weight: 400;"> files.</span></p>
<h3><b>Customizing </b><b>main.c</b></h3>
<p><span style="font-weight: 400;">In your </span><b>Project Folder</b><span style="font-weight: 400;">, you'll find the </span><span style="font-weight: 400;">main.c</span><span style="font-weight: 400;"> file, which contains the main logic of your program. The template project includes a basic structure that you can build upon. As a simple test, let's create a basic LED blink program:</span></p>
<p>&nbsp;</p>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-bash" data-lang="Bash"><code>#include "nrf.h"
#include "nrf_gpio.h"
#include "boards.h"
#include "nrf_delay.h"

int main(void)
{
    // Initialize LED pin
    nrf_gpio_cfg_output(LED_1);
 
    while (1)
    {
        // Turn LED on
        nrf_gpio_pin_set(LED_1);
        nrf_delay_ms(500);
     
        // Turn LED off
        nrf_gpio_pin_clear(LED_1);
        nrf_delay_ms(500);
    }
}</code></pre>
</div>
<p><span style="font-weight: 400;">This code initializes one of the GPIO pins connected to an LED and makes the LED blink with a 500ms delay.</span></p>
<h3><b>Building and Flashing the Project</b></h3>
<p><span style="font-weight: 400;">Now that the code is ready, let's build and flash it onto the nRF52 device.</span></p>
<ol>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Click the </span><b>Build</b><span style="font-weight: 400;"> button (or press </span><span style="font-weight: 400;">F7</span><span style="font-weight: 400;">) to compile the project.</span></li>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Connect your PCA10040 development board to your PC via USB.</span></li>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">In SES, go to </span><b>Target</b><span style="font-weight: 400;"> &gt; </span><b>Download &lt;Project Name&gt;</b><span style="font-weight: 400;"> to flash the program to the chip.</span></li>
</ol>
<p><span style="font-weight: 400;">If everything is working correctly, the LED should start blinking.</span></p>
<h3><b>Troubleshooting</b></h3>
<p><span style="font-weight: 400;">Here are a few common issues you might encounter:</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><b>Header or library not found</b><span style="font-weight: 400;">: Double-check that the SDK path in </span><b>User Include Directories</b><span style="font-weight: 400;"> points to the correct folders.</span></li>
<li style="font-weight: 400;" aria-level="1"><b>Configuration errors</b><span style="font-weight: 400;">: Ensure that the </span><em><span style="font-weight: 400;">sdk_config.h</span></em><span style="font-weight: 400;"> file is correctly set up to enable the peripherals or libraries you need.</span></li>
<li style="font-weight: 400;" aria-level="1"><b>Flashing issues</b><span style="font-weight: 400;">: Make sure that the correct development kit is connected and that you’ve selected the correct target device in SES.</span></li>
<li style="font-weight: 400;" aria-level="1"><b>“.text section is larger than specified size”</b><span style="font-weight: 400;">: open the <em>flash_placement.xml</em> file and remove the part that says “size  = 0x4”.</span></li>
</ul>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-plain" data-lang="Plain Text"><code>&lt;ProgramSection alignment="4" load="Yes" name=".text" size="0x4" /&gt;</code></pre>
</div>
<h3><b>Customizing the Template for Future Use</b></h3>
<p><span style="font-weight: 400;">One of the best parts about using a template is that you can customize it for future projects. For example:</span></p>
<ul>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Add your own commonly used libraries or peripherals to the project.</span></li>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Pre-configure frequently used settings in </span><em><span style="font-weight: 400;">sdk_config.h</span><span style="font-weight: 400;">.</span></em></li>
<li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">Create multiple </span><em><span style="font-weight: 400;">.emProject</span></em><span style="font-weight: 400;"> configurations if you work with different devices or development boards.</span></li>
</ul>
<h3><b>Final Thoughts</b></h3>
<p><span style="font-weight: 400;">Using the template project from GitHub saves time and effort in setting up a new project in Segger Embedded Studio for nRF52. With a solid understanding of the project structure and how to configure the SDK, you can easily start working on firmware without having to set everything up from scratch. By reusing this template and customizing it for your specific needs, you’ll speed up your development process significantly.</span></p>
<p>&nbsp;</p>
<p>The post <a href="https://www.teachmemicro.com/setting-up-a-new-project-in-segger-embedded-studio-for-nrf52-using-a-project-template/">Setting up a New Project in Segger Embedded Studio for nRF52 Using a Project Template</a> appeared first on <a href="https://www.teachmemicro.com">Teach Me Microcontrollers!</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Using Flash Data Storage (FDS) in the nRF52832</title>
		<link>https://www.teachmemicro.com/using-flash-data-storage-fds-in-the-nrf52832/</link>
		
		<dc:creator><![CDATA[Roland Pelayo]]></dc:creator>
		<pubDate>Sat, 28 Sep 2024 01:29:09 +0000</pubDate>
				<category><![CDATA[nRF52 Tutorial]]></category>
		<guid isPermaLink="false">https://www.teachmemicro.com/?p=7293</guid>

					<description><![CDATA[<p>The nRF52832 is a versatile SoC (System on Chip) from Nordic Semiconductor that supports various features, including Flash Data Storage (FDS) for non-volatile data management. This post gives some basic examples of how to use FDS to save, delete, and update data, as well as how garbage collection works to manage flash memory on the &#8230;</p>
<p>The post <a href="https://www.teachmemicro.com/using-flash-data-storage-fds-in-the-nrf52832/">Using Flash Data Storage (FDS) in the nRF52832</a> appeared first on <a href="https://www.teachmemicro.com">Teach Me Microcontrollers!</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><span style="font-weight: 400;">The </span><b>nRF52832</b><span style="font-weight: 400;"> is a versatile SoC (System on Chip) from Nordic Semiconductor that supports various features, including </span><b>Flash Data Storage (FDS)</b><span style="font-weight: 400;"> for non-volatile data management. This post gives some basic examples of how to use FDS to save, delete, and update data, as well as how garbage collection works to manage flash memory on the nRF52832.</span></p>
<h3><b>What is Flash Data Storage (FDS)?</b></h3>
<p><span style="font-weight: 400;">Flash Data Storage (FDS) is a library provided by Nordic Semiconductor that simplifies the process of writing, deleting, and updating data in non-volatile flash memory. This is useful for storing configuration settings, device state, and other critical information that must persist across power cycles or resets.</span></p>
<p><span style="font-weight: 400;">FDS manages flash memory by organizing data into records,  identified by a </span><b>file ID</b><span style="font-weight: 400;"> and a </span><b>record key</b><span style="font-weight: 400;">. This abstraction layer eliminates the need for the developer to manage low-level flash operations manually.</span></p>
<p><img loading="lazy" decoding="async" src="https://www.teachmemicro.com/wp-content/uploads/2024/09/NRF52-DK-300x300.jpg" alt="" width="300" height="300" class="size-medium wp-image-7308 aligncenter" srcset="https://www.teachmemicro.com/wp-content/uploads/2024/09/NRF52-DK-300x300.jpg 300w, https://www.teachmemicro.com/wp-content/uploads/2024/09/NRF52-DK-150x150.jpg 150w, https://www.teachmemicro.com/wp-content/uploads/2024/09/NRF52-DK.jpg 640w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<h3><b>Key Components in FDS</b></h3>
<ol>
<li style="font-weight: 400;" aria-level="1"><b>File ID</b><span style="font-weight: 400;">: A unique identifier for a group of records.</span></li>
<li style="font-weight: 400;" aria-level="1"><b>Record Key</b><span style="font-weight: 400;">: A unique identifier for each record within a file.</span></li>
<li style="font-weight: 400;" aria-level="1"><b>Record</b><span style="font-weight: 400;">: A single data entity that you want to store.</span></li>
<li style="font-weight: 400;" aria-level="1"><b>Pages</b><span style="font-weight: 400;">: Flash memory is divided into pages -- the minimum unit that can be erased in flash memory.</span></li>
</ol>
<h3><b>Saving Data in Flash</b></h3>
<p><span style="font-weight: 400;">To save data using FDS, you need to define a record that contains the data you want to store, and then call the FDS API to write this record to flash memory.</span></p>
<h4><b>Example of Saving Data</b></h4>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-c" data-lang="C"><code>#include "fds.h"

// Sample data to be stored
uint32_t sample_data = 0x12345678;

// File ID and Record Key
#define FILE_ID 0x1111
#define RECORD_KEY 0x2222

void save_data(void) {
    fds_record_t record;
    fds_record_desc_t record_desc;
    fds_record_chunk_t record_chunk;

    // Set up the record chunk
    record_chunk.p_data = &amp;sample_data;
    record_chunk.length_words = sizeof(sample_data) / sizeof(uint32_t);

    // Define the record
    record.file_id = FILE_ID;
    record.key = RECORD_KEY;
    record.data.p_chunks = &amp;record_chunk;
    record.data.num_chunks = 1;

    // Write the record to flash memory
    ret_code_t err_code = fds_record_write(&amp;record_desc, &amp;record);
    if (err_code == NRF_SUCCESS) {
        // Data was written successfully
    }
}</code></pre>
</div>
<p><span style="font-weight: 400;">In this example, a simple </span><em><span style="font-weight: 400;">uint32_t</span></em><span style="font-weight: 400;"> value is stored in flash memory. The FDS library handles the details of writing the record, and the data is identified by the file ID and record key.</span></p>
<h3><b>Updating Data in Flash</b></h3>
<p><span style="font-weight: 400;">Updating data in flash is a common requirement when working with configuration settings or other dynamic information. The FDS library allows records to be updated efficiently by writing a new record and marking the old one as obsolete.</span></p>
<h4><b>Example of Updating Data</b></h4>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-c" data-lang="C"><code>void update_data(uint32_t new_data) {
    fds_record_desc_t record_desc;
    fds_find_token_t ftok = {0};

    // Find the record to update
    if (fds_record_find(FILE_ID, RECORD_KEY, &amp;record_desc, &amp;ftok) == NRF_SUCCESS) {
        // Create the new record data
        fds_record_t record;
        fds_record_chunk_t record_chunk;
        record_chunk.p_data = &amp;new_data;
        record_chunk.length_words = sizeof(new_data) / sizeof(uint32_t);
       
        record.file_id = FILE_ID;
        record.key = RECORD_KEY;
        record.data.p_chunks = &amp;record_chunk;
        record.data.num_chunks = 1;

        // Update the record
        ret_code_t err_code = fds_record_update(&amp;record_desc, &amp;record);
        if (err_code == NRF_SUCCESS) {
            // Record updated successfully
        }
    }
}</code></pre>
</div>
<p><span style="font-weight: 400;">In this example, the </span><em><span style="font-weight: 400;">fds_record_update</span></em><span style="font-weight: 400;"> function updates the existing record with new data.</span></p>
<h3><b>Deleting Data in Flash</b></h3>
<p><span style="font-weight: 400;">To delete data from flash memory, you can use the </span><em><span style="font-weight: 400;">fds_record_delete</span></em><span style="font-weight: 400;"> function. Deleting a record does not immediately free up space, but marks it as obsolete. Space will be freed during garbage collection.</span></p>
<h4><b>Example of Deleting Data</b></h4>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-c" data-lang="C"><code>void delete_data(void) {
    fds_record_desc_t record_desc;
    fds_find_token_t ftok = {0};

    // Find the record to delete
    if (fds_record_find(FILE_ID, RECORD_KEY, &amp;record_desc, &amp;ftok) == NRF_SUCCESS) {
        // Delete the record
        ret_code_t err_code = fds_record_delete(&amp;record_desc);
        if (err_code == NRF_SUCCESS) {
            // Record marked for deletion
        }
    }
}</code></pre>
</div>
<p><span style="font-weight: 400;">Once a record is marked for deletion, it will not be accessible, but the space it occupies in flash memory will not be immediately reclaimed.</span></p>
<h3><b>Garbage Collection</b></h3>
<p><span style="font-weight: 400;">Flash memory has limited erase cycles, and the smallest unit that can be erased is a page. This means that you cannot immediately reuse the memory occupied by deleted or updated records. The FDS library handles this by performing </span><b>garbage collection</b><span style="font-weight: 400;">.</span></p>
<p><span style="font-weight: 400;">Garbage collection reclaims flash memory by erasing pages that contain obsolete records (those marked for deletion or old versions of updated records). This process can be triggered manually using the </span><em><span style="font-weight: 400;">fds_gc()</span></em><span style="font-weight: 400;"> function or will happen automatically when necessary.</span></p>
<h4><b>Example of Triggering Garbage Collection</b></h4>
<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-c" data-lang="C"><code>void trigger_garbage_collection(void) {
    ret_code_t err_code = fds_gc();
    if (err_code == NRF_SUCCESS) {
        // Garbage collection was successful
    }
}</code></pre>
</div>
<p><span style="font-weight: 400;">Garbage collection will erase entire flash pages, freeing up space for future writes. It’s important to note that if a page contains any active (non-obsolete) records, it cannot be erased until all records are either moved or deleted.</span></p>
<h3><b>Best Practices for FDS and Flash Memory Management</b></h3>
<ol>
<li style="font-weight: 400;" aria-level="1"><b>Avoid frequent writes</b><span style="font-weight: 400;">: Flash memory has a limited number of erase/write cycles. Try to minimize the frequency of updates to prolong the life of the flash.</span></li>
<li style="font-weight: 400;" aria-level="1"><b>Use garbage collection proactively</b><span style="font-weight: 400;">: Trigger garbage collection periodically to ensure that flash space is freed up for future use.</span></li>
<li style="font-weight: 400;" aria-level="1"><b>Monitor flash usage</b><span style="font-weight: 400;">: Keep an eye on how much flash memory is being used and reclaimed. FDS provides functions like </span><span style="font-weight: 400;">fds_stat</span><span style="font-weight: 400;"> to check memory usage.</span></li>
<li style="font-weight: 400;" aria-level="1"><b>Error handling</b><span style="font-weight: 400;">: Always handle the return codes from FDS functions to ensure that operations like writing and deleting are successful.</span></li>
</ol>
<h3><b>Conclusion</b></h3>
<p><span style="font-weight: 400;">The FDS library in the </span><b>nRF52832</b><span style="font-weight: 400;"> simplifies the use of flash memory by providing functions for saving, deleting, and updating data. It abstracts the complexities of flash memory management, allowing you to focus on the functionality of your application. Understanding how to use FDS efficiently, along with triggering garbage collection, is essential for maintaining the longevity and reliability of your device's flash memory.</span></p>
<p>&nbsp;</p>
<p>The post <a href="https://www.teachmemicro.com/using-flash-data-storage-fds-in-the-nrf52832/">Using Flash Data Storage (FDS) in the nRF52832</a> appeared first on <a href="https://www.teachmemicro.com">Teach Me Microcontrollers!</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: www.teachmemicro.com @ 2026-11-06 11:02:10 by W3 Total Cache
-->