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!

Parents
  • 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

Reply
  • 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

Children
No Data
Related