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

Timer Prescaler

I have a problem enabling TIMER1: If the prescaler is set between 16MHz and 2 MHz the firmware fails to enable the SoftDevice, even if I didn't manage TIMER0, but TIMER1 which should be dedicated to the softDevice. Using a lower prescaler instead it works. I enable the timer before enabling SoftDevice.

I am working on NRF51822 with softdevice S110 8.0.0.

Am I doing ssomething wrong or not alloweed?

Thank you

Parents
  • I use Timer1, for the reason you mentioned.

    Here some parts of the Code:

    #define TIMER1_ENABLED 1
    
    #if (TIMER1_ENABLED == 1)
    #define TIMER1_CONFIG_FREQUENCY    NRF_TIMER_FREQ_1MHz
    #define TIMER1_CONFIG_MODE         TIMER_MODE_MODE_Timer
    #define TIMER1_CONFIG_BIT_WIDTH    TIMER_BITMODE_BITMODE_16Bit
    #define TIMER1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
    
    #define TIMER1_INSTANCE_INDEX      (TIMER0_ENABLED)
    #endif
    

    Here the initialization:

        Timer_DRV.p_reg 			= NRF_TIMER1;
    Timer_DRV.irq					= TIMER1_IRQn;
    Timer_DRV.instance_id = TIMER1_INSTANCE_INDEX;
    
    Timer_DRV_Conf.frequency					= TIMER1_CONFIG_FREQUENCY;
    Timer_DRV_Conf.mode								= TIMER1_CONFIG_MODE;
    Timer_DRV_Conf.bit_width					= TIMER1_CONFIG_BIT_WIDTH;
    Timer_DRV_Conf.interrupt_priority	= TIMER1_CONFIG_IRQ_PRIORITY;
    Timer_DRV_Conf.p_context					= timer_struct;
    
    nrf_drv_timer_init(&Timer_DRV,
                              &Timer_DRV_Conf,
                              timer_clk_handler);
    

    And then configuration interrupt:

                nrf_drv_timer_compare(&Timer_DRV, NRF_TIMER_CC_CHANNEL0, 60, true);
    	nrf_drv_timer_compare(&Timer_DRV, NRF_TIMER_CC_CHANNEL1, 120, true);
    	nrf_drv_timer_compare(&Timer_DRV, NRF_TIMER_CC_CHANNEL2, 180, true);
    	nrf_drv_timer_extended_compare(&Timer_DRV, NRF_TIMER_CC_CHANNEL3, 240, NRF_TIMER_SHORT_COMPARE3_CLEAR_MASK,
                                        true);
    

    Thank you

  • Looking at the behaviour it seems that calling the function: SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false); it has some problem. While not enabling the timer1 it works correctly. The defines are the ones provided by Nordic SDK, the define #define TIMER1_INSTANCE_INDEX (TIMER0_ENABLED) is 0 because there is no TIMER0 enabled

    If there are any other things you need to clarify the situation just ask.

    Thanks

Reply
  • Looking at the behaviour it seems that calling the function: SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false); it has some problem. While not enabling the timer1 it works correctly. The defines are the ones provided by Nordic SDK, the define #define TIMER1_INSTANCE_INDEX (TIMER0_ENABLED) is 0 because there is no TIMER0 enabled

    If there are any other things you need to clarify the situation just ask.

    Thanks

Children
No Data
Related