nrfx_timer_init failed with error code 195887109

*** Booting Zephyr OS build v3.2.99-ncs2 ***
 nrfx_timer_init failed with: 195887109

  • /*
     * Copyright (c) 2023 Amengine cooperation.
     *
     */
    
    #include <zephyr/logging/log.h>
    #include "button.h"
    #include "timer.h"
    
    LOG_MODULE_REGISTER(main);
    
    void main(void) {
        LOG_INF("NIRS\n");
        timerButtonInit();
        buttonInit();
    }
    

  • /*
     * Copyright (c) 2023 Amengine cooperation.
     *
     */
    
    #include <nrfx_timer.h>
    #include <zephyr/logging/log.h>
    #include <zephyr/sys/printk.h>
    #include "error.h"
    
    LOG_MODULE_REGISTER(timer);
    
    #define TIMER_INSTANCE_BUTTON     0
    
    static const nrfx_timer_t _gButtonTimer = NRFX_TIMER_INSTANCE(TIMER_INSTANCE_BUTTON);
    
    static void _timerHandlerButton(nrf_timer_event_t eventType, void * pContext) {
        LOG_INF("timer handler for button\n");
    }
    
    int timerButtonInit(void) {
        nrfx_err_t errCode;
        nrfx_timer_config_t timerCfg = {
            .frequency = NRF_TIMER_FREQ_125kHz,
            .mode      = NRF_TIMER_MODE_TIMER,
            .bit_width = NRF_TIMER_BIT_WIDTH_16,
        };
    
        errCode = nrfx_timer_init(&_gButtonTimer, &timerCfg, _timerHandlerButton);
        if (errCode != NRFX_SUCCESS) {
            printk("nrfx_timer_init failed with: %d\n", errCode);
            return -EAGAIN;
        }
    
        return 0;
    }
    

  • /*
     * Copyright (c) 2023 Amengine cooperation.
     *
     */
    
    #include <nrfx_gpiote.h>
    #include <zephyr/logging/log.h>
    #include <zephyr/sys/printk.h>
    #include "error.h"
    #include "nrf52832_board.h"
    #include "timer.h"
    
    LOG_MODULE_REGISTER(button);
    
    static void buttonInterrupt(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
        LOG_INF("button pressed\n");
        nrf_gpio_pin_toggle(LED_G);
        timerButtonInit();
    }
    
    int buttonInit(void) {
        nrfx_err_t errCode;
        if (!nrfx_gpiote_is_init()){
            errCode = nrfx_gpiote_init(2);
            if (errCode != NRFX_SUCCESS) {
                printk("Failed to init gpiote (err %d)\n", errCode);
                return ERROR_GPIOE_INITIALIZE_FAIL;
            }
        }
    
        nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
        inConfig.sense = NRF_GPIOTE_POLARITY_LOTOHI;
        inConfig.pull  = NRF_GPIO_PIN_PULLUP;
    
        errCode = nrfx_gpiote_in_init(POWER_UP, &inConfig, buttonInterrupt);
        if (errCode != NRFX_SUCCESS) {
            printk("Failed to init gpiote in (err %d)\n", errCode);
            return ERROR_GPIOE_INITIALIZE_FAIL;
        }
    
        nrfx_gpiote_in_event_enable(POWER_UP, true);
    
        return 0;
    }
    

  • Hi,

    Thank you for contacting DevZone at NordicSemi.

    I have been assigned this case, and I will look into it and will update you accordingly.

    Thanks and regards,

    Naeem

Related