This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

IAR Error[Pe020]: identifier "NRFX_TIMER1_INST_IDX" is undefined

Hello,

I am using the NRF52-DK softdevice 6.0.0 and NRF SDK 15.0.The app is based on on the saadc PCA10040 S112. I want to add static const nrf_drv_timer_t m_timer = NRF_DRV_TIMER_INSTANCE(1); in my main.c 

in sdk_config.h I then setup :
#define NRFX_TIMER_ENABLED 1
#define NRFX_TIMER1_ENABLED 1

If I compile, I have the following issue :
Error[Pe020]: identifier "NRFX_TIMER1_INST_IDX" is undefined

Could you please explain me what is my mistake?Thanks

Parents
  • Try to set TIMER_ENABLED and TIMER1_ENABLED to 1 instead:

    #ifndef TIMER_ENABLED
    #define TIMER_ENABLED 1
    #endif
    .
    .
    .
    #ifndef TIMER1_ENABLED
    #define TIMER1_ENABLED 1
    #endif

    Best regards, Simon

  • Why do you recommend this "work around"?

    Is the NRFX_TIMER API not ready to use?

    In the file nrfx_timer.h the NRFX_TIMER1 _INST_IDX is concated with NRFX_CONCAT_3(NRFX_TIMER, id, _INST_IDX), but the enum is defined in the following enum!

    Please advise

    /**
     * @brief Macro for creating a timer driver instance.
     */
    #define NRFX_TIMER_INSTANCE(id)                                   \
    {                                                                 \
        .p_reg            = NRFX_CONCAT_2(NRF_TIMER, id),             \
        .instance_id      = NRFX_CONCAT_3(NRFX_TIMER, id, _INST_IDX), \
        .cc_channel_count = NRF_TIMER_CC_CHANNEL_COUNT(id),           \
    }
    
    enum {
    #if NRFX_CHECK(NRFX_TIMER0_ENABLED)
        NRFX_TIMER0_INST_IDX,
    #endif
    #if NRFX_CHECK(NRFX_TIMER1_ENABLED)
        NRFX_TIMER1_INST_IDX,
    #endif
    #if NRFX_CHECK(NRFX_TIMER2_ENABLED)
        NRFX_TIMER2_INST_IDX,
    #endif
    #if NRFX_CHECK(NRFX_TIMER3_ENABLED)
        NRFX_TIMER3_INST_IDX,
    #endif
    #if NRFX_CHECK(NRFX_TIMER4_ENABLED)
        NRFX_TIMER4_INST_IDX,
    #endif
        NRFX_TIMER_ENABLED_COUNT
    };
    

  • The definitions TIMER_ENABLED and TIMER1_ENABLED originates from older SDK's, but the Timer driver in SDK 15 uses NRFX definitions. 

    The reason it fails, is due to the file apply_old_config.h (located in integration/nrfx/legacy) and the following lines:

    #if defined(TIMER_ENABLED)
    #undef NRFX_TIMER_ENABLED
    #define NRFX_TIMER_ENABLED  TIMER_ENABLED
    .
    .
    .
    .
    #if defined(TIMER1_ENABLED)
    #undef NRFX_TIMER1_ENABLED
    #define NRFX_TIMER1_ENABLED  TIMER1_ENABLED
    #endif

    This will make your project to use the old definitions (not NRFX) in the sdk_config.h file.

    Two ways of solving this:

    • My initial suggestion
    • Use the new definitions (NRFX_TIMER_ENABLED and NRFX_TIMER1_ENABLED) in the sdk config file, and delete/comment out the old definitions (TIMER_ENABLED and TIMER1_ENABLED) to prevent it from being overwritten

    Does this make sense?

    Best regards, Simon

  • Hi,

    I just had the same issue and for the record I just wanted to say this worked perfectly!

    Thanks,

    Jack

  • Hello Simon,

     

    Your first input worked for me. But I am trying to understand the basic issue. Though TIMER_ENABLED is nowhere enabled how macros in apply_old_config.h are executed.

    To cross check, I kept dummy variable as shown below. Irrespective of macro enabled, I am getting compile error.

     

    #if defined(TIMER_ENABLED)

    X;           // Dummy variable

    #undef NRFX_TIMER_ENABLED

    #define NRFX_TIMER_ENABLED  TIMER_ENABLED

     

    Is this due to #if define() same as #ifdef and irrespective of 0 or 1 TIMER_ENABLED is enabled. I mean below all are same.

    #define TIMER_ENABLED 0

    #define TIMER_ENABLED 1

    #define TIMER_ENABLED

     

    To avoid compile error I commented.

    //#define TIMER_ENABLED 0

     

    Is my understanding correct. I feel coding style is wrong. Please let me know your inputs.

     

    Thanks & Regards

    Vishnu Beema

Reply
  • Hello Simon,

     

    Your first input worked for me. But I am trying to understand the basic issue. Though TIMER_ENABLED is nowhere enabled how macros in apply_old_config.h are executed.

    To cross check, I kept dummy variable as shown below. Irrespective of macro enabled, I am getting compile error.

     

    #if defined(TIMER_ENABLED)

    X;           // Dummy variable

    #undef NRFX_TIMER_ENABLED

    #define NRFX_TIMER_ENABLED  TIMER_ENABLED

     

    Is this due to #if define() same as #ifdef and irrespective of 0 or 1 TIMER_ENABLED is enabled. I mean below all are same.

    #define TIMER_ENABLED 0

    #define TIMER_ENABLED 1

    #define TIMER_ENABLED

     

    To avoid compile error I commented.

    //#define TIMER_ENABLED 0

     

    Is my understanding correct. I feel coding style is wrong. Please let me know your inputs.

     

    Thanks & Regards

    Vishnu Beema

Children
  • Yes you have understood it correctly. 

    In these cases TIMER_ENABLED IS defined:

    • #define TIMER_ENABLED 0
    • #define TIMER_ENABLED
    • #define TIMER_ENABLED 1

    The code inside #if defined(TIMER_ENABLED) will be executed

    In this case TIMER_ENABLED IS NOT defined:

    • //#define TIMER_ENABLED 0

    The code inside #if defined(TIMER_ENABLED) will not be executed

    Best regards,

    Simon

  • I am having this same issue, porting the saadc_pcs10056e example to the ble_app_hts_pca10056e_s112 using SDK 15.3 and SES. I am trying to use TIMER1 since I have read that TIMER0 is used by the Soft device. Regardless of how I configure the sdk_config.h file, either using the legacy or nrfx timers, the associated timer definition block in the nrfx_timer.h fails to be enumerated. I have the configuration file exactly the same as in the saadc example, but for TIMER1, and it doesn't seem to work. Some help trouble shooting would be greatly appreciated.

  • I assume you mean this block:

    enum {
    .
    .
    .
    #if NRFX_CHECK(NRFX_TIMER1_ENABLED)
        NRFX_TIMER1_INST_IDX,
    #endif
    .
    .
    .
    };

    • In order for NRFX_TIMER1_INST_IDX to be enabled, the macro NRFX_TIMER1_ENABLED has to equal 1
    • If you look in apply_old_config.h, NRFX_TIMER1_ENABLED is set in the following manner:

    #if defined(TIMER_ENABLED)
    .
    .
    #if defined(TIMER1_ENABLED)
        #undef NRFX_TIMER1_ENABLED
        #define NRFX_TIMER1_ENABLED  TIMER1_ENABLED
    #endif
    .
    .
    .

    • So you have to set both TIMER_ENABLED and TIMER1_ENABLED in the sdk_config.h file

    Okay, I see now that I have just repeated my earlier answers. But could you start at nrfx_timer.h and go backwards, to see specifically where it fails. Is the if statement grayed out in nrfx_timer.h or in apply_old_config.h?

    Best regards,

    Simon

Related