Help with nRF Connect SDK on Visual Studio Code extension

Hi, I am new to the nRF Connect extension in VS Code and I am having trouble including dealy.h header file to utilize a DelayMs() function. I found the delay.h in the sdk folder but when I include it and try to build it says: No such file or directory

c:\Users\Michael\Senior-Design\UWB\dw3000_nrf_project\nrf_dw3000_tdoa_base\src\main.c:9:10: fatal error: delay.h: No such file or directory
    9 | #include <delay.h>
      |          ^~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'c:\Users\Michael\Senior-Design\UWB\dw3000_nrf_project\nrf_SDK\v1.7.0\toolchain\opt\bin\cmake.EXE' --build 'c:\Users\Michael\Senior-Design\UWB\dw3000_nrf_project\nrf_dw3000_tdoa_base\build'
The terminal process terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Here is the code that I tried to build that previously built before I tried to add the function

#include <zephyr.h>
#include <sys/printk.h>
#include <delay.h>

void main(void)
{
	while(1){
		printk("Hello Michael %s\n", CONFIG_BOARD);
		DelayMs(1000);
	}
}

I followed the VS code welcome page walkthrough to a tee and can run sample applications but when trying to write my own code inside a sample application it seems like I cannot use the SDK functions. Thanks for your help!

  • Hi 

    Zephyr comes with it's own set of delay functions, such as k_msleep() and k_usleep(), and these are the ones you should use for nRF Connect SDK projects. 

    These functions will suspend the current thread for the duration of the delay, and if no threads are running the CPU will be put to sleep automatically in order to reduce power consumption. 

    I am not sure where the DelayMs() function comes from. Was this function referenced from one of our documentation pages or walkthroughs?

    Best regards
    Torbjørn

  • Thanks for the reply!

    I found the DelayMS() within the 1.7.0 SDK folder somewhere buried which does not sounds like I am using the SDK the right way. I guess proper utilization of the SDK on VS Code is more what I am getting at and can refine my inquiry for you.

    I am used to utilizing Silicon Labs HAL documentation and simplicity studio where I knew which document source to find functions and it would tell me which header file to include in my project, then simplicity would automatically have the files available for the build based on which board I am using and I would just have to make sure I did a #include for the proper header file. Since I am new to it, nrf connect SDK documentation confuses me, I am confused on how to use the documentation and it is hard for me to find the header files the functions are from that I want to use so I can add them to my app. I have also not used Zephyr before and am confused on when to use it vs nrf functions and how to include everything in my application on VS code. I will refine my questions for you.

    What is the document source that you use to look up functions when utilizing the SDK, also what is the best practice or workflow you have seen when working with these documents?

    How do you ensure that the correct header files are linked within the app in VS Code on the nRF Connect extension when utilizing SDK functions?

    How do I include my own header and source files within my project within VS Code on the nRF Connect extension?

    Thank you so much for your help!

    Michael

    PS, I did find the below link which seems to be answering some of my questions on how to link my own files to the build, but is for SES instead of VS Code

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_modifying.html

  • Hi Michael

    We prepared a tutorial series to help getting started with VSCode and the nRF Connect SDK, available here.

    Can you start by looking through those?

    If you still have questions afterwards I will do my best to help Slight smile

    Best regards
    Torbjørn

Related