Is there a random number generation function and high-precision system time function that can be called directly?

Now I am using nrf9160DK for development. In my project, I need to use a random number generator and a highly accurate system time stamp. Is there an API that I can call directly? If so, can you tell me the API name, calling method, and header files that need to be used. For the random number generator, I have tried to call the function sys_rand32_get (), but I get the following error during the build. Is it because the header file I added is incorrect?

In function `main ':
/opt/sourcecode/ncs/nrf/samples/nrf9160/helloworld/build/../src/main.c:8: undefined reference to `sys_rand32_get '
collect2: error: ld returned 1 exit status

Here are the header files I added.

#include <zephyr.h>
#include <random/rand32.h>
#include <misc/printk.h>
#include <stdio.h>
#include <stdlib.h>

Best wishes!


Parents Reply Children
No Data