This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

code gets restarting after nrf_drv_timer_init ()

HI , I am using nrf52832 with s132 . I am trying to measure ADC value at some periodic interval. In nrf_drv_timer_init() function , code gets restarting after executing nrf_timer_event_clear() function. Checked with sample code of SAADC , but no luck . Can anyone guide me on this.

  • Can you try debugging using this method, to see if any functions return an error code?

  • You don't show how you're calling the function nor surrounding code and I'm assuming that you have enabled the timer instance within sdk_config.h but many of the Nordic initialisation functions will trigger an ASSERT and then a hard reset if called twice in succession, so make sure that you call nrf_drv_timer_uninit before initialising again.

  • The function nrf_timer_event_clear() is a void function and the code gets restarted while executing the function nrf_drv_timer_init(). SO I cant get the err_code

  • Let me know if did anything wrong here.

    //timer_initialisation
     err_code = nrf_drv_timer_init(&m_timer, NULL, timer_handler);
        APP_ERROR_CHECK(err_code);
    
    In config.h file i declared like this :
    #define TIMER0_ENABLED 1
    
    #if (TIMER0_ENABLED == 1)
    #define TIMER0_CONFIG_FREQUENCY    NRF_TIMER_FREQ_16MHz
    #define TIMER0_CONFIG_MODE         TIMER_MODE_MODE_Timer
    #define TIMER0_CONFIG_BIT_WIDTH    TIMER_BITMODE_BITMODE_32Bit
    #define TIMER0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
    
    #define TIMER0_INSTANCE_INDEX      0
    #endif
    

    in nrf_drv_timer_init function , I callled the function nrf_timer_event_clear :

    p_cb->handler = timer_event_handler;
    p_cb->context = p_config->p_context;
    
    uint8_t i=0;
    for (i = 0; i < p_instance->cc_channel_count; ++i)
    {
        nrf_timer_event_clear(p_instance->p_reg,
            nrf_timer_compare_event_get(i));
        nrf_delay_ms(10);
    }
    

    FIrst time it will execute and second time it gets restarted.

  • Does this only happen if you use the softdevice? I tested with the SAADC example and cannot reproduce this issue. Which example are you using? Could you upload the entire project for debugging?

Related