0
votes

Apologies for the incredibly vague title; I will try to be more specific here.

I'm developing a program on a NRF52832 microcontroller in the SEGGER Embedded Studio IDE that receives data from an external ADC via SPI and outputs a PWM signal with a duty cycle that depends on the data from the ADC.

I got the example code for the SPI driver and the PWM driver working in separate projects and now I'm trying to combine the two. However, when I insert a function from, say, the PWM driver to the SPI driver and insert the corresponding include file in the SPI driver, 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 SPI 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 include the header file:

#include "/Users/payton/opt/nRF5_SDK_15.0.0/nRF5_SDK_15.0.0_a53641a/components/libraries/pwm/app_pwm.h"

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), \
    .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?

2
From that page: This happens if you have both TIMER_ENABLED and NRFX_TIMER_ENABLED defined in your sdk_config.h.Barmar

2 Answers

0
votes

Find file header sdk_config.h and #define NRFX_TIMER1_ENABLED 1. I solved it.

-1
votes

NRFX_CONCAT_3 appears (from both its name and the error output) to be a macro that creates symbol by concatenation of three components. The resulting generated symbol is not defined.

Perhaps it is defined in some other header, you have not included, or there is some conditional compilation that means that the required definition is excluded, or perhaps there is no timer instance 3 for your target.

Find the definition for NRFX_TIMER1_INST_IDX and determine whether the file is included and in what configuration it is defined.