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

GPIO configuration issue

Hi nRF team,

I am configuring my GPIO pin with below code sample. 

out_config = GPIOTE_CONFIG_OUT_SIMPLE(false); 

err_code = nrfx_gpiote_out_init(MEM_SPI_SS_PIN, &out_config);
APP_ERROR_CHECK(err_code);
nrfx_gpiote_out_set(MEM_SPI_SS_PIN);

While compiling the above code, I am getting below build error. 

expected expression before '{' token 

in expansion of macro GPIOTE_CONFIG_OUT_SIMPLE 

What could be wrong in this? 

Regards

Lakshmi. 

  • Hello Lakshmi,

    It doesn't look like there is anything wrong with the snippet that you included here. What does your GPIOTE_CONFIG_OUT_SIMPLE macro look like? Perhaps you by mistake added/removed something from that file?

    Does it happen if you try to do the same in a fresh, unmodified SDK?

    These types of compiler errors can be quite cryptic sometimes. It may not be related to GPIOTE_CONFIG_OUT_SIMPLE at all. Perhaps you are missing some brackets somewhere above the line:

    out_config = GPIOTE_CONFIG_OUT_SIMPLE(false); as well. Can you check that?

    Does the issue (or a similar issue) occur if you comment out all the lines from the snippet that you have included here as well?

    Best regards,

    Edvin

  • Hi Edvin,

    I tried with fresh copy of SDK without any of my code. Took an example project and added above lines of code. Issue still persists.

    If I commented out the  out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);   line, I am not seeing any errors. 

    Regards

    Lakshmi

  • What SDK version do you use?

    If you look in the example found in SDK\examples\peripheral\pin_change_int

    you can see that this is used:

    nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);

     

    Edvin said:
    What does your GPIOTE_CONFIG_OUT_SIMPLE macro look like?

     If you right click GPIOTE_CONFIG_OUT, and click "Go To Definition", what does it point to? Can you share that snippet?

    If it points to NRFX_GPIOTE_CONFIG_OUT_SIMPLE, do the same with that one. What does NRFX_GPIOTE_CONFIG_OUT_SIMPLE point to if you click "Go To Definition"?

    When you tested this with a new unmodified SDK, did you use the same main.c file as earlier? Do you use any other custom files than main.c and sdk_config? Is it possible to share the custom files? Perhaps the issue is there?

  • Hi Edvin,

    I am using nRF5_SDK_16.0.0. 

    SDK\examples\peripheral\pin_change_int is working alright in both in old copy of SDK too.

    I am using  \examples\ble_peripheral\ble_app_hrs\pca10040\s132\ses project.  And I am not using any custom files. I have just added GPIOTE configuration code in main.c 

    Below is the code snippet you have asked for. 

    #define GPIOTE_CONFIG_OUT_SIMPLE          NRFX_GPIOTE_CONFIG_OUT_SIMPLE

    /** @brief Macro for configuring a pin to use as output. GPIOTE is not used for the pin. */
    #define NRFX_GPIOTE_CONFIG_OUT_SIMPLE(init_high) \
    { \
    .action = NRF_GPIOTE_POLARITY_LOTOHI, \
    .init_state = init_high ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW, \
    .task_pin = false, \
    }

    Regards

    Lakshmi

  • Ok, if you can use GPIOTE_CONFIG_OUT_SIMPLE in pin_change_int, it is probably nothing wrong with that implementation.

     

    Edvin said:
    Do you use any other custom files than main.c and sdk_config? Is it possible to share the custom files? Perhaps the issue is there?

     As I mentioned in the first reply, the compiler errors that you get when you are missing brackets may be a bit cryptic. The compiler is not good at understanding where it is actually missing. This is not really related to nordic, but if you send me a project that can replicate the issue I can have a look. It is probably something before GPIOTE_CONFIG_OUT_SIMPLE in the file that you are using it (main.c?).

    Go through all the brackets in your custom files. Check that there are equally many '{' and '}', and that they are in the right order.

Related