Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Issue with nrfx_lpcomp.h

I am trying to use the LPCOMP API, but I am having trouble with the following function:

nrfx_err_t nrfx_lpcomp_init ( nrfx_lpcomp_config_t const *  p_config,
nrfx_lpcomp_event_handler_t  event_handler 
)

I think have have the proper header files included, but the compiler outputs "undefined reference to 'nrfx_lpcomp_init'. I am using nRF SDK 15.0.0.

Here are the relevant code snippets:

#include "nrfx_lpcomp.h"

void LPCOMP_INIT(){

uint32_t err_code;
nrfx_lpcomp_config_t config = NRFX_LPCOMP_DEFAULT_CONFIG;
config.input = NRF_LPCOMP_INPUT_2;
nrf_lpcomp_config_t hal_config;
hal_config.reference = NRF_LPCOMP_REF_SUPPLY_4_8;
hal_config.detection = NRF_LPCOMP_DETECT_CROSS;
config.hal = hal_config;

err_code = nrfx_lpcomp_init(&config, LPcomp_handler);
APP_ERROR_CHECK(err_code);
nrfx_lpcomp_enable();
}

What am I doing wrong? Thank you for your help.

Parents
  • Hi,

    "undefined reference" errors come from the linker, and the most typical reason for getting such errors when working with the nRF5 SDK is one of:

    • Not having added the file to the project/Makefile. In this case, you need nrfx_lpcomp.c.
    • Not having enabled the module in sdk_config.h. If not, the implementation will not be included by the preprocessor. So you should make sure to set NRFX_LPCOMP_ENABLED and LPCOMP_ENABLED to 1 in your applications sdk_config.h.
Reply
  • Hi,

    "undefined reference" errors come from the linker, and the most typical reason for getting such errors when working with the nRF5 SDK is one of:

    • Not having added the file to the project/Makefile. In this case, you need nrfx_lpcomp.c.
    • Not having enabled the module in sdk_config.h. If not, the implementation will not be included by the preprocessor. So you should make sure to set NRFX_LPCOMP_ENABLED and LPCOMP_ENABLED to 1 in your applications sdk_config.h.
Children
Related