This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Adding saadc driver to a project

Hi,

I want to use in my project the saadc (I'm using segger embedded studio). So, I found that I have to add the driver file to the driver folder, and I have added the file nrfx_saadc.c (then I have added the folder path to the preprocessor).

Then I have to activate it in the sdk_config.h file, but it is not present, so I add the following code to the file 

// <e> NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver
//==========================================================
#ifndef NRFX_SAADC_ENABLED
#define NRFX_SAADC_ENABLED 1
#endif
// <o> NRFX_SAADC_CONFIG_RESOLUTION - Resolution

// <0=> 8 bit
// <1=> 10 bit
// <2=> 12 bit
// <3=> 14 bit

#ifndef NRFX_SAADC_CONFIG_RESOLUTION
#define NRFX_SAADC_CONFIG_RESOLUTION 1
#endif

// <o> NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period

// <0=> Disabled
// <1=> 2x
// <2=> 4x
// <3=> 8x
// <4=> 16x
// <5=> 32x
// <6=> 64x
// <7=> 128x
// <8=> 256x

#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE
#define NRFX_SAADC_CONFIG_OVERSAMPLE 0
#endif

// <q> NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode

#ifndef NRFX_SAADC_CONFIG_LP_MODE
#define NRFX_SAADC_CONFIG_LP_MODE 0
#endif

// <o> NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority

// <0=> 0 (highest)
// <1=> 1
// <2=> 2
// <3=> 3
// <4=> 4
// <5=> 5
// <6=> 6
// <7=> 7

#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY
#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6
#endif

I built and I expect to find in CMSIS configuration wizard the file related to saadc in order to enable/disable it. The problem is that I do not find it.

So, I do not understand if I miss some steps or I make any errors.

Thanks for helping.

Parents
  • Hi,

    The CMSIS configuration wizard will have problems displaying the sdk_config.h file in the GUI if there is an error in the tags it uses. Here it looks like you are missing a line with "// </e>" at the end. (This has no effect on the preprocessor and compiler though, it is only a problem for the GUI).

  • Thanks for helping.

    I tried to correct th sdk_config.h file, but it still does not compare.

    Also, I tried to include "nrf_saadc.h" and "nrf_drv_saadc.h" library in the main file, but when I build there are errors. 

    For example, one is: 

    'NRFX_SAADC_CONFIG_RESOLUTION' undeclared (first use in this function); did you mean 'NRF_SAADC_INT_RESULTDONE'?

    They are all in nrfx_saadc.h file, which I have not modified, so I think the problem is due to the import and enable of the driver.

    Thanks again

  • Hi,

    If you have the snippet from your original post in your application's sdk_config.h, then NRFX_SAADC_CONFIG_RESOLUTION will not be undeclared. Can you double check that this is not inside a block comment, or that you have not added it to the wrong sdk_config.h file by accident (from another project or similar).

  • Hi,

    I check and NRFX_SAADC_CONFIG_RESOLUTION is declared in this way in the sdk_config.h

    #ifndef NRFX_SAADC_CONFIG_RESOLUTION
    #define NRFX_SAADC_CONFIG_RESOLUTION 1
    #endif

    I also compare the sdk_config.h file from which I take the code with my new sdk_config.h file and the code related to saadc is the same

Reply
  • Hi,

    I check and NRFX_SAADC_CONFIG_RESOLUTION is declared in this way in the sdk_config.h

    #ifndef NRFX_SAADC_CONFIG_RESOLUTION
    #define NRFX_SAADC_CONFIG_RESOLUTION 1
    #endif

    I also compare the sdk_config.h file from which I take the code with my new sdk_config.h file and the code related to saadc is the same

Children
Related