expected expression before '{' token when using WDT

this is causing expected expression before '{' token

/** @brief WDT driver default configuration. */
#define NRFX_WDT_DEAFULT_CONFIG \
{ \
.behaviour = (nrf_wdt_behaviour_t)NRFX_WDT_CONFIG_BEHAVIOUR, \
.reload_value = NRFX_WDT_CONFIG_RELOAD_VALUE, \
NRFX_WDT_IRQ_CONFIG \
}

  • Hello,

    Sorry for the late reply. We have some backlog after the Easter Holidays here in Norway. 

    C is a bit tricky this way, but I believe the error is above what you pasted here. Possibly a missing ";" or something.

    Try to download a new copy of the SDK, unzip it, and see if the SDK\modules\nrfx\drivers\include\nrfx_wdt.h file is identical to the one that you are using now.

    Best regards,

    Edvin

  • If i try the example it builds ok, but, i'm trying to add this to my existing project. 

    So this could be a project setup issue, but i'm not sure.

    Do you need both WDT_ENABLE and NRFX_WDT_ENABLE ?

  • /**
    * @brief WDG function to initialise.
    */
    void wdg_init(void)
    {
    uint32_t err_code;
    //nrfx_wdt_config_t config = wdt_config;
    nrf_drv_wdt_config_t config;


    NRF_LOG_INFO("Watchdog init...");

    config = NRF_DRV_WDT_DEAFULT_CONFIG;

    err_code = nrf_drv_wdt_init(&config,
    wdg_event_handler);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_wdt_channel_alloc(&channel_id);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_INFO("Watchdog enabled %d", channel_id);
    nrf_drv_wdt_enable();
    }

  • So ive changed to non legacy driver i.e. nrfx_ calls and still had the same issue.

    I believe this is a compiler issue, to do with initializing  config = NRFX_WDT_DEAFULT_CONFIG;

    So ive changed to this and it now works

    static const nrfx_wdt_config_t wdt_config =
    {
    .behaviour = NRFX_WDT_CONFIG_BEHAVIOUR,
    .reload_value = NRFX_WDT_CONFIG_RELOAD_VALUE,
    .interrupt_priority = NRFX_WDT_CONFIG_IRQ_PRIORITY
    };

    /**
    * @brief WDG function to initialise.
    */
    void wdg_init(void)
    {
    uint32_t err_code;
    nrfx_wdt_config_t config = wdt_config;



    NRF_LOG_INFO("Watchdog init...");

    err_code = nrfx_wdt_init(&config,
    wdg_event_handler);
    APP_ERROR_CHECK(err_code);

    err_code = nrfx_wdt_channel_alloc(&channel_id);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_INFO("Watchdog enabled %d",channel_id);
    nrfx_wdt_enable();

    }

Related