<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRF9160-DK - Make Application From Scratch</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46388/nrf9160-dk---make-application-from-scratch</link><description>Hi, 
 I have nRF9160-DK kit and its environment is set such as nRF Connect SDK and Segger Embedded Studio. 
 I want to build a simple application from scratch for example toggling LEDs on the board or anything else. 
 I have tried some sample application</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 15 Sep 2020 21:36:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46388/nrf9160-dk---make-application-from-scratch" /><item><title>RE: nRF9160-DK - Make Application From Scratch</title><link>https://devzone.nordicsemi.com/thread/269742?ContentTypeID=1</link><pubDate>Tue, 15 Sep 2020 21:36:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f522677-b393-4008-a2ce-69842b0fc5a7</guid><dc:creator>colinodowd</dc:creator><description>&lt;p&gt;Hello, when I try to run the sample code above I get the following error: gpio.h: No such file or directory. Do you know what file this needs to go into for the code to run?&lt;/p&gt;
&lt;p&gt;I do have a gpio.h file in this folder:&amp;nbsp;\ncs\v1.2.0\zephyr\include\drivers. In addition, I tried moving the gpio.h file into my src file but did not work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160-DK - Make Application From Scratch</title><link>https://devzone.nordicsemi.com/thread/184183?ContentTypeID=1</link><pubDate>Sun, 28 Apr 2019 10:58:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ab6a2bc-27c2-4ed3-b39b-dcce9ceca5a2</guid><dc:creator>Aakash_Soni</dc:creator><description>&lt;p&gt;Hi&lt;a class="internal-link view-user-profile" style="background-attachment:scroll;background-color:transparent;background-image:none;background-repeat:repeat;background-size:auto;color:#5bd2e2;font-style:normal;font-weight:600;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;" href="https://devzone.nordicsemi.com/members/gurkan"&gt; Gurkan&lt;/a&gt;, thanks for the link and explanation. Regarding this .overlay file, do I have to write this manually such as text file or it generates automatically when we build the programme?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160-DK - Make Application From Scratch</title><link>https://devzone.nordicsemi.com/thread/183916?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 22:42:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7abb6252-fe09-4e9f-bc53-c6c50363a46e</guid><dc:creator>danielb1194</dc:creator><description>&lt;p&gt;would be so much easier if there was a GUI for choosing the libraries and drivers, as well as config&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160-DK - Make Application From Scratch</title><link>https://devzone.nordicsemi.com/thread/183904?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 19:10:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:855c0c66-75c6-4b39-9c38-7af3f28147fa</guid><dc:creator>Gurkan</dc:creator><description>&lt;p&gt;I&amp;#39;m quite new with the environment as well, as I understand;&lt;/p&gt;
&lt;p&gt;prj.conf = you setup which drivers you would like to use in your application such as I2C, Spi or sensor drivers that you want to add like lis2dhl. Other than you can create and setup threads. You can see the accepted values from this&amp;nbsp;&lt;a href="https://docs.zephyrproject.org/latest/reference/kconfig/index.html"&gt;link&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;sample.yaml is for documentation I believe so.&lt;/p&gt;
&lt;p&gt;Other than these ones you can add overlay files like &amp;quot;nrf9160_pca10090ns.overlay&amp;quot;. in this file you can edit dts file of board, that will allow you to assign different pin for&amp;nbsp;peripherals.&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;i2c2 {
	status = &amp;quot;ok&amp;quot;;
	sda-pin = &amp;lt;21&amp;gt;;
	scl-pin = &amp;lt;22&amp;gt;;
};&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160-DK - Make Application From Scratch</title><link>https://devzone.nordicsemi.com/thread/183622?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 05:10:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:805de367-a8be-4759-9be2-ee12d85ec76c</guid><dc:creator>danielb1194</dc:creator><description>&lt;p&gt;Thank you very much for your reply!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160-DK - Make Application From Scratch</title><link>https://devzone.nordicsemi.com/thread/183573?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 15:30:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f39661ee-476f-4aaa-8cbd-02d0b57a5764</guid><dc:creator>Aakash_Soni</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a class="internal-link view-user-profile" style="background-attachment:scroll;background-color:transparent;background-image:none;background-repeat:repeat;background-size:auto;color:#86deea;font-style:normal;font-weight:600;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;" href="https://devzone.nordicsemi.com/members/oys"&gt; &amp;Oslash;yvind&lt;/a&gt; and&lt;a class="internal-link view-user-profile" style="background-attachment:scroll;background-color:transparent;background-image:none;background-repeat:repeat;background-size:auto;color:#86deea;font-style:normal;font-weight:600;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;" href="https://devzone.nordicsemi.com/members/danielb1194"&gt; danielb1194&lt;/a&gt;. I think CMakeList.txt file is useful when working with SEGGER Embedded Studio for building purposes. See: &lt;a href="https://cmake.org/cmake-tutorial/"&gt;cmake.org/.../&lt;/a&gt; and &lt;a href="http://wiki.ros.org/catkin/CMakeLists.txt"&gt;wiki.ros.org/.../CMakeLists.txt&lt;/a&gt;. In my cmakelist.txt file, I include one file and specify sources to use when compiling a given target. You will not have to update this file every time you add or edit the code. But, if you want to include external files, this is the space to use.&lt;/p&gt;
&lt;p&gt;Regarding sample.yaml and prj.conf, I have no experience with these files. I am with this board from last one week. As I said before, I tried to make similar example by following given sample application files. However, I tried to run above application without these two files, &lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;sample.yaml and prj.conf&lt;/span&gt;, and it worked perfectly. Therefore, these two files may not be mandatory.&lt;/p&gt;
&lt;p&gt;Regarding the GPIO ports, see my new code. It references the pins now therefore it will remain same or change according to hardware pinouts.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;gpio.h&amp;gt;

#define LED_PORT0 LED0_GPIO_CONTROLLER

#define LED0    2
#define LED1    3
#define LED2    4
#define LED3    5

/* 1000 msec = 1 sec */
#define SLEEP_TIME    1000

void main(void)
{
	int cnt = 0;
	struct device *dev0, *dev1, *dev2, *dev3;

	dev0 = device_get_binding(LED_PORT0);
	dev1 = device_get_binding(LED_PORT0);
	dev2 = device_get_binding(LED_PORT0);
	dev3 = device_get_binding(LED_PORT0);
	/* Set LED pin as output */
	gpio_pin_configure(dev0, LED0, GPIO_DIR_OUT);
	gpio_pin_configure(dev1, LED1, GPIO_DIR_OUT);
	gpio_pin_configure(dev2, LED2, GPIO_DIR_OUT);
	gpio_pin_configure(dev3, LED3, GPIO_DIR_OUT);

	while (1) {
		/* Set pin to HIGH/LOW every 1 second */
		gpio_pin_write(dev0, LED0, cnt % 2);
		gpio_pin_write(dev1, LED1, cnt % 2);
		gpio_pin_write(dev2, LED2, cnt % 2);
		gpio_pin_write(dev3, LED3, cnt % 2);
		cnt++;
		k_sleep(SLEEP_TIME);
	}        
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you want to change the port, you will have to use this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* change this to use another GPIO port */
#ifndef LED0_GPIO_CONTROLLER
#ifdef LED0_GPIO_PORT
#define LED0_GPIO_CONTROLLER LED0_GPIO_PORT
#else
#error LED0_GPIO_PORT or LED0_GPIO_CONTROLLER needs to be set in board.h
#endif
#endif
#define PORT	LED0_GPIO_CONTROLLER&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160-DK - Make Application From Scratch</title><link>https://devzone.nordicsemi.com/thread/183361?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 08:56:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b96f9cf7-84b5-46e1-9ee9-6be98f88009c</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Thanks for making this quick tutorial! As &lt;a href="https://devzone.nordicsemi.com/members/danielb1194"&gt;danielb1194&lt;/a&gt; is asking, it could be good to add an explanation of what you are configuring.&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160-DK - Make Application From Scratch</title><link>https://devzone.nordicsemi.com/thread/183214?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2019 16:43:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11b18940-7151-457d-ba49-6178f9e394df</guid><dc:creator>danielb1194</dc:creator><description>&lt;p&gt;Hello, thank you for the reply, but again, that is just a list of steps to take..&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What does CMakeList.txt do? Do I have to update it every time I add new code to the project?&lt;/p&gt;
&lt;p&gt;What do I need to define in sample .yaml?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What about when I wanna develop my own hardware and the defines are no longer usable? How do I reference the GPIO ports in this case?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160-DK - Make Application From Scratch</title><link>https://devzone.nordicsemi.com/thread/183206?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2019 15:55:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d68aecba-c40c-474c-a179-cff35bcd89eb</guid><dc:creator>Aakash_Soni</dc:creator><description>&lt;p&gt;I have figured out how to control LEDs of the board. See following:&lt;/p&gt;
&lt;p&gt;This tutorial targets windows 10 based application development for nRF9160-DK board. This is my way of making this application. I am new with this board and there might be better/official way of developing application for this board. This tutorial does not require sim card activation.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Environment Setup:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It is expected that your environment is set by installing the &lt;em&gt;nRF Connect for Desktop&lt;/em&gt; application and following &lt;em&gt;Getting Started Assistant&lt;/em&gt; from the installed application.&lt;/p&gt;
&lt;p&gt;Link for the nRF Connect for Desktop:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_ins_windows.html"&gt;http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_ins_windows.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Once installed, download the &lt;em&gt;Getting Started Assistant&lt;/em&gt; from &lt;em&gt;add/remove apps&lt;/em&gt; tab and follow the steps carefully.&lt;/p&gt;
&lt;p&gt;The following link is helpful during setting-up an environment for the nRF9160-DK board:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Connect-for-desktop"&gt;https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Connect-for-desktop&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Once the environment is set, you should try running the sample applications provided with the installation to verify everything is working properly.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Actual Tutorial:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In this tutorial, a led blinking application is developed with same sample folder structure provided in &lt;em&gt;\ncs\nrf\samples\nrf9160 &lt;/em&gt;folder.&lt;/p&gt;
&lt;p&gt;First, create a folder in above mentioned directory and name is &lt;em&gt;blink_leds&lt;/em&gt; or anything you would like (&lt;em&gt;\ncs\nrf\samples\nrf9160\blink_leds&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;Then, create another folder inside &lt;em&gt;blink_leds&lt;/em&gt; folder and name it &lt;em&gt;src &lt;/em&gt;(&lt;em&gt;\ncs\nrf\samples\nrf9160\blink_leds\src&lt;/em&gt;). Inside the &lt;em&gt;src&lt;/em&gt; folder, our main &lt;em&gt;main.c&lt;/em&gt; programme is saved. &lt;em&gt;Main.c&lt;/em&gt; programme is provided at the end of this document.&lt;/p&gt;
&lt;p&gt;After that, copy these three files, &lt;em&gt;CMaleLists.txt&lt;/em&gt;, &lt;em&gt;prj.conf&lt;/em&gt; and &lt;em&gt;sample.yaml&lt;/em&gt;, from provided sample files (&lt;em&gt;e.g. \ncs\nrf\samples\nrf9160\at_client&lt;/em&gt;) and paste it into &lt;em&gt;blink_leds&lt;/em&gt; folder.&lt;/p&gt;
&lt;p&gt;Now open these files and replace the content of these files with this:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;For CMakeList.txt:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cmake_minimum_required(VERSION 3.13.1)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(NONE)
target_sources(app PRIVATE src/main.c)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;For prj.conf:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_GPIO=y
CONFIG_SERIAL=n&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;For sample.yaml:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;sample:
  name: blink_leds Sample
tests:
  sample.blink_leds:
    tags: LED gpio
    filter: DT_GPIO_LEDS_LED0_GPIO_CONTROLLER
    depends_on: gpio
    harness: led
    platform_whitelist: nrf9160_pca10090
    tags: ci_build&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Save these files and open the &lt;em&gt;SEGGER Embedded Studio&lt;/em&gt;. In SEGGER, click on File &amp;rarr; Open nRF Connect SDK Project. This gives you following window and set the parameters by navigating to your folder and as shown in the picture.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/500x300/__key/communityserver-discussions-components-files/4/blink_5F00_leds.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;After that, click on &lt;em&gt;Build &amp;rarr; Build zephyr/zephyr.elf&lt;/em&gt; to generate .elf file and then click &lt;em&gt;Build &amp;rarr; Build and Run&lt;/em&gt; to flash the board. It should work. All these LEDs should toggle on and off with 1 second interval.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;//This code is adapted and modified from the Blinky sample project.

#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;gpio.h&amp;gt;

#define LED_PORT0 LED0_GPIO_CONTROLLER
#define LED_PORT1 LED1_GPIO_CONTROLLER
#define LED_PORT2 LED2_GPIO_CONTROLLER
#define LED_PORT3 LED3_GPIO_CONTROLLER

#define LED0    LED0_GPIO_PIN
#define LED1    LED1_GPIO_PIN
#define LED2    LED2_GPIO_PIN
#define LED3    LED3_GPIO_PIN

/* 1000 msec = 1 sec */
#define SLEEP_TIME  1000

void main(void)
{
    int cnt = 0;
    struct device *dev0, *dev1, *dev2, *dev3;

    dev0 = device_get_binding(LED_PORT0);
    dev1 = device_get_binding(LED_PORT1);
    dev2 = device_get_binding(LED_PORT2);
    dev3 = device_get_binding(LED_PORT3);
    /* Set LED pin as output */
    gpio_pin_configure(dev0, LED0, GPIO_DIR_OUT);
    gpio_pin_configure(dev1, LED1, GPIO_DIR_OUT);
    gpio_pin_configure(dev2, LED2, GPIO_DIR_OUT);
    gpio_pin_configure(dev3, LED3, GPIO_DIR_OUT);

    while (1) {
        /* Set pin to HIGH/LOW every 1 second */
        gpio_pin_write(dev0, LED0, cnt % 2);
        gpio_pin_write(dev1, LED1, cnt % 2);
        gpio_pin_write(dev2, LED2, cnt % 2);
        gpio_pin_write(dev3, LED3, cnt % 2);
        cnt++;
        k_sleep(SLEEP_TIME);
    }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160-DK - Make Application From Scratch</title><link>https://devzone.nordicsemi.com/thread/183157?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2019 13:56:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0dc4aa4a-e427-426c-8ab9-121fddf7fab8</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;There are currently no tutorials or documentation other than &lt;a href="https://devzone.nordicsemi.com/tutorials/b/getting-started/posts/getting-started-with-nrf9160-dk"&gt;Getting Started with nRF9160 DK&lt;/a&gt;, &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/index.html"&gt;nRF Connect SDK documentation&lt;/a&gt;&amp;nbsp;and Getting Started Assistant in nRF Connect for Desktop provides.&amp;nbsp;Unfortunately, this is not up to date with the current SDK/user environment.&lt;br /&gt;&lt;br /&gt;We are aware that the current amount of tutorials are scarce. Rest assured more are planned, but I do not have any schedules for these I&amp;#39;m afraid.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160-DK - Make Application From Scratch</title><link>https://devzone.nordicsemi.com/thread/182960?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2019 01:15:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9afc277e-73d9-4236-aff0-2a9a25404049</guid><dc:creator>danielb1194</dc:creator><description>&lt;p&gt;I am curious about this one too. I can see there&amp;#39;s a lot of work and videos about flashing examples, but nowhere to be found is a tutorial about &amp;quot;setting up your project&amp;quot; and &amp;quot;include this file for GPIO&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>