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

NRFX_TIMER3_INST_IDX' undeclared (first use in this function), SDK enabled

I'm uploading a BLE & TWI code to nRF52 DK. Now, I'm getting this error: 

NRFX_TIMER3_INST_IDX' undeclared (first use in this function)

According to other similar posts, I have enabled timers in SDK. 

// <e> NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver
//==========================================================
#ifndef NRFX_TIMER_ENABLED
#define NRFX_TIMER_ENABLED 1
#endif
// <q> NRFX_TIMER0_ENABLED  - Enable TIMER0 instance
 

#ifndef NRFX_TIMER0_ENABLED
#define NRFX_TIMER0_ENABLED 1
#endif

// <q> NRFX_TIMER1_ENABLED  - Enable TIMER1 instance
 

#ifndef NRFX_TIMER1_ENABLED
#define NRFX_TIMER1_ENABLED 1
#endif

// <q> NRFX_TIMER2_ENABLED  - Enable TIMER2 instance
 

#ifndef NRFX_TIMER2_ENABLED
#define NRFX_TIMER2_ENABLED 1
#endif

// <q> NRFX_TIMER3_ENABLED  - Enable TIMER3 instance
 

#ifndef NRFX_TIMER3_ENABLED
#define NRFX_TIMER3_ENABLED 1
#endif

// <q> NRFX_TIMER4_ENABLED  - Enable TIMER4 instance
 

#ifndef NRFX_TIMER4_ENABLED
#define NRFX_TIMER4_ENABLED 1
#endif

// <o> NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY  - Timer frequency if in Timer mode
 
// <0=> 16 MHz 
// <1=> 8 MHz 
// <2=> 4 MHz 
// <3=> 2 MHz 
// <4=> 1 MHz 
// <5=> 500 kHz 
// <6=> 250 kHz 
// <7=> 125 kHz 
// <8=> 62.5 kHz 
// <9=> 31.25 kHz 

#ifndef NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY
#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0
#endif

// <o> NRFX_TIMER_DEFAULT_CONFIG_MODE  - Timer mode or operation
 
// <0=> Timer 
// <1=> Counter 

#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE
#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0
#endif

// <o> NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH  - Timer counter bit width
 
// <0=> 16 bit 
// <1=> 8 bit 
// <2=> 24 bit 
// <3=> 32 bit 

#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH
#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0
#endif

// <o> NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
 
// <0=> 0 (highest) 
// <1=> 1 
// <2=> 2 
// <3=> 3 
// <4=> 4 
// <5=> 5 
// <6=> 6 
// <7=> 7 

#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY
#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6
#endif

// <e> NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module.
//==========================================================
#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED
#define NRFX_TIMER_CONFIG_LOG_ENABLED 1
#endif
// <o> NRFX_TIMER_CONFIG_LOG_LEVEL  - Default Severity level
 
// <0=> Off 
// <1=> Error 
// <2=> Warning 
// <3=> Info 
// <4=> Debug 

#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL
#define NRFX_TIMER_CONFIG_LOG_LEVEL 3
#endif

// <o> NRFX_TIMER_CONFIG_INFO_COLOR  - ANSI escape code prefix.
 
// <0=> Default 
// <1=> Black 
// <2=> Red 
// <3=> Green 
// <4=> Yellow 
// <5=> Blue 
// <6=> Magenta 
// <7=> Cyan 
// <8=> White 

#ifndef NRFX_TIMER_CONFIG_INFO_COLOR
#define NRFX_TIMER_CONFIG_INFO_COLOR 0
#endif

// <o> NRFX_TIMER_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
 
// <0=> Default 
// <1=> Black 
// <2=> Red 
// <3=> Green 
// <4=> Yellow 
// <5=> Blue 
// <6=> Magenta 
// <7=> Cyan 
// <8=> White 

#ifndef NRFX_TIMER_CONFIG_DEBUG_COLOR
#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0
#endif

In my nrfx_timer.c file. timer3 section is the only part that is NOT greyed out. 

Any idea, please? Thank you! 

Parents
  • Hello,

    Have you defined both the legacy and NRFX TIMER definitions?
    If you leave the legacy TIMER#_ENABLED defined in your SDK config, it will overwrite your NRFX definition.
    Please make sure that only the NRFX_TIMER#_ENABLED is defined, and none of the TIMER#_ENABLED are defined, and see if this resolves the issue.
    For a more in-depth discussion of this apply_old_config issue, please see this ticket.

    If this does not resolve the issue, could you share your entire sdk_config file?

    Best regards,
    Karl

  • Thanks, Karl. 

    I tried your method, unfortunately, the problem didn't solve. Here is how I solved the issue today by 2 steps:

    Step 1) For the error "NRFX_TIMER3_INST_IDX' undeclared (first use in this function)", my solution is: in sdk_config.h, I enabled both "TIMER#_ENABLED" and "legacy TIMER#_ENABLED".

    // <e> NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver
    //==========================================================
    #ifndef NRFX_TIMER_ENABLED
    #define NRFX_TIMER_ENABLED 1
    #endif
    // <q> NRFX_TIMER0_ENABLED  - Enable TIMER0 instance
     
    
    #ifndef NRFX_TIMER0_ENABLED
    #define NRFX_TIMER0_ENABLED 1
    #endif
    
    // <q> NRFX_TIMER1_ENABLED  - Enable TIMER1 instance
     
    
    #ifndef NRFX_TIMER1_ENABLED
    #define NRFX_TIMER1_ENABLED 1
    #endif
    
    // <q> NRFX_TIMER2_ENABLED  - Enable TIMER2 instance
     
    
    #ifndef NRFX_TIMER2_ENABLED
    #define NRFX_TIMER2_ENABLED 1
    #endif
    
    // <q> NRFX_TIMER3_ENABLED  - Enable TIMER3 instance
     
    
    #ifndef NRFX_TIMER3_ENABLED
    #define NRFX_TIMER3_ENABLED 1
    #endif
    
    // <q> NRFX_TIMER4_ENABLED  - Enable TIMER4 instance
     
    
    #ifndef NRFX_TIMER4_ENABLED
    #define NRFX_TIMER4_ENABLED 1
    #endif
    
    
    
    // ==============================================
    
    
    
    // <e> TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer
    //==========================================================
    #ifndef TIMER_ENABLED
    #define TIMER_ENABLED 1
    #endif
    // <o> TIMER_DEFAULT_CONFIG_FREQUENCY  - Timer frequency if in Timer mode
     
    // <0=> 16 MHz 
    // <1=> 8 MHz 
    // <2=> 4 MHz 
    // <3=> 2 MHz 
    // <4=> 1 MHz 
    // <5=> 500 kHz 
    // <6=> 250 kHz 
    // <7=> 125 kHz 
    // <8=> 62.5 kHz 
    // <9=> 31.25 kHz 
    
    #ifndef TIMER_DEFAULT_CONFIG_FREQUENCY
    #define TIMER_DEFAULT_CONFIG_FREQUENCY 0
    #endif
    
    // <o> TIMER_DEFAULT_CONFIG_MODE  - Timer mode or operation
     
    // <0=> Timer 
    // <1=> Counter 
    
    #ifndef TIMER_DEFAULT_CONFIG_MODE
    #define TIMER_DEFAULT_CONFIG_MODE 0
    #endif
    
    // <o> TIMER_DEFAULT_CONFIG_BIT_WIDTH  - Timer counter bit width
     
    // <0=> 16 bit 
    // <1=> 8 bit 
    // <2=> 24 bit 
    // <3=> 32 bit 
    
    #ifndef TIMER_DEFAULT_CONFIG_BIT_WIDTH
    #define TIMER_DEFAULT_CONFIG_BIT_WIDTH 0
    #endif
    
    // <o> TIMER_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    
    // <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef TIMER_DEFAULT_CONFIG_IRQ_PRIORITY
    #define TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6
    #endif
    
    // <q> TIMER0_ENABLED  - Enable TIMER0 instance
     
    
    #ifndef TIMER0_ENABLED
    #define TIMER0_ENABLED 1
    #endif
    
    // <q> TIMER1_ENABLED  - Enable TIMER1 instance
     
    
    #ifndef TIMER1_ENABLED
    #define TIMER1_ENABLED 1
    #endif
    
    // <q> TIMER2_ENABLED  - Enable TIMER2 instance
     
    
    #ifndef TIMER2_ENABLED
    #define TIMER2_ENABLED 1
    #endif
    
    // <q> TIMER3_ENABLED  - Enable TIMER3 instance
     
    
    #ifndef TIMER3_ENABLED
    #define TIMER3_ENABLED 0
    #endif
    
    // <q> TIMER4_ENABLED  - Enable TIMER4 instance
     
    
    #ifndef TIMER4_ENABLED
    #define TIMER4_ENABLED 0
    #endif
    
    // </e>

     

    Step 2) For the error "in nrfx_timer.c file. Timer3 section is the only part that is NOT greyed out. " I simply deleted the code in the red box (see below image). I guess it's because I accidentally deleted some timer 3 code elsewhere. I will share the answer with you if I could find it (Because I shouldn't delete the below red box code). But if you have any idea, please share your answer, too. Thank you very much! 

  • Hello,

    Thank you for your patience with this - we are short staffed due to the national easter holidays here in Norway.

    StevenW807 said:
    Step 1) For the error "NRFX_TIMER3_INST_IDX' undeclared (first use in this function)", my solution is: in sdk_config.h, I enabled both "TIMER#_ENABLED" and "legacy TIMER#_ENABLED".

    If you have left the apply_old_config file unchanged, this would mean that NRFX_TIMER_ENABLED is redefined to 0, since you also define TIMER_ENABLED

    StevenW807 said:
    (Because I shouldn't delete the below red box code).

    I agree, you definitely should not have to delete the offending section - this is often just deleting the symptoms of the real issue.

    StevenW807 said:
    I simply deleted the code in the red box (see below image). I guess it's because I accidentally deleted some timer 3 code elsewhere.

    In general I would have to say that this approach is a short-term solution.
    Are you speculating whether you might have deleted code accidentally elsewhere, or are you stating that you have accidentally deleted code elsewhere?
    I would recommend that you redownload the SDK, to make sure you have a functional and complete version. The code you might have deleted could break other functionality in the SDK.

    Could I ask you to remove the legacy definitions of TIMER_ENABLED and TIMER#_ENABLED all together from your sdk_config, and see if this changes the issue of the greyed out sections?
    As in, do not  just change their definition to 0 (that will still leave them defined to 0), but either comment them out, or remove them entirely from the file.
    Do this, and see if the greyed out NRFX_CHECK is no longer grayed out, after cleaning the build and rebuilding the project.

    Best regards,
    Karl

Reply
  • Hello,

    Thank you for your patience with this - we are short staffed due to the national easter holidays here in Norway.

    StevenW807 said:
    Step 1) For the error "NRFX_TIMER3_INST_IDX' undeclared (first use in this function)", my solution is: in sdk_config.h, I enabled both "TIMER#_ENABLED" and "legacy TIMER#_ENABLED".

    If you have left the apply_old_config file unchanged, this would mean that NRFX_TIMER_ENABLED is redefined to 0, since you also define TIMER_ENABLED

    StevenW807 said:
    (Because I shouldn't delete the below red box code).

    I agree, you definitely should not have to delete the offending section - this is often just deleting the symptoms of the real issue.

    StevenW807 said:
    I simply deleted the code in the red box (see below image). I guess it's because I accidentally deleted some timer 3 code elsewhere.

    In general I would have to say that this approach is a short-term solution.
    Are you speculating whether you might have deleted code accidentally elsewhere, or are you stating that you have accidentally deleted code elsewhere?
    I would recommend that you redownload the SDK, to make sure you have a functional and complete version. The code you might have deleted could break other functionality in the SDK.

    Could I ask you to remove the legacy definitions of TIMER_ENABLED and TIMER#_ENABLED all together from your sdk_config, and see if this changes the issue of the greyed out sections?
    As in, do not  just change their definition to 0 (that will still leave them defined to 0), but either comment them out, or remove them entirely from the file.
    Do this, and see if the greyed out NRFX_CHECK is no longer grayed out, after cleaning the build and rebuilding the project.

    Best regards,
    Karl

Children
No Data
Related