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

'NRFX_TIMER1_INST_IDX' undeclared here (not in a function)

Hello,

I'm developing a program on a NRF52840 DK in the SEGGER Embedded Studio IDE that outputs a PWM signal when a Bluetooth Mesh GenericOnOff signal is recieved.

I got the example code for the Mesh and the PWM driver working in separate projects and now I'm trying to combine the two. However, when I insert a function from the PWM driver to the Mesh driver and insert the corresponding include file, I get an error in a (seemingly) unrelated header file. Here's a specific example:

(1) I add the macro

APP_PWM_INSTANCE(PWM1,1);

to the Mesh driver to initialize a PWM instance, just like the PWM driver does. Of course, without the header file containing the definition of the macro, I would get an error.

(2) So, I included the header files used in PWM Project:

"$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/libraries/pwm"
.
.
.
The compiler accepts the new header file and the added macro but the build fails because of the following error in the middle of the nrfx_timer.h header file:
#define NRFX_TIMER_INSTANCE(id)                                   \
{                                                                 \
    .p_reg            = NRFX_CONCAT_2(NRF_TIMER, id),             \
    .instance_id      = NRFX_CONCAT_3(NRFX_TIMER, id, _INST_IDX), \   <-- 'NRFX_TIMER1_INST_IDX' undeclared here (not in a function)
    .cc_channel_count = NRF_TIMER_CC_CHANNEL_COUNT(id),           \
}

ERROR: 
'NRFX_TIMER1_INST_IDX' undeclared here (not in a function)
in definition of macro 'NRFX_CONCAT_3_'
in expansion of macro 'NRFX_CONCAT_3'
in expansion of macro 'NRFX_TIMER_INSTANCE'
in expansion of macro 'NRF_DRV_TIMER_INSTANCE'
in expansion of macro 'APP_PWM_INSTANCE'
Build failed

The error points to the line that defines .instance_id

Any idea why this would be happening?

Related