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

  • LFCLK_XTAL should have nothing to do with TIMERs,

    The define TIMER1_INSTANCE_INDEX is index to the timer driver member, so 0 is fine if Timer0 is not enabled.

    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

    Can you please explain what "It has problems" mean?

  • I meant that that function didn't return(I just put a breakpoint at the following instruction, and it never stops). Now I solved setting the compare at 600, 1200, 1800, 2400, but this lead to another question, is there a lower bound for the compare? To check the interrupt frequency I toggle a pin every compare event, and even if I should have always the same interrupt distance (because of the equidistant comapare settings) the pin toggle is not always at the same interval (I am using an oscilloscope to check). Here's the function code: switch (event_type){

    	case NRF_TIMER_EVENT_COMPARE0:
    			Hw_Interface_SetOutput1();
    	
    	case NRF_TIMER_EVENT_COMPARE1:
    				Hw_Interface_SetOutput();
    				
    	case NRF_TIMER_EVENT_COMPARE2:
    		Hw_Interface_ResetOutput1();
    
    	case NRF_TIMER_EVENT_COMPARE3:
    			Hw_Interface_ResetOutput();
    	}
    

    Is there something wrong, or any limit I should follow? Thanks

  • I did not see anywhere that you have called the function nrf_drv_timer_enable. Without this the timer has been initialized but never actually started.

Related