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

Use HF CLK for softdevice s132

Hello,

I am trying to use timer with Bluetooth application . I want to provide precise time stamping using timer for each bluetooth event. But program execution stucks at ble_stack_init since softdevice uses LFCLK source and timer is operating at 16MHz. How can I resolve this problem.

Parents
  • The SoftDevice can use one of two available low frequency clock sources:

    1. The internal RC Oscillator
    2. External Crystal Oscillator.

    The SoftDevice cannot use the high-frequency clock.

  • int main(void) { uint32_t time_ms = 500; //Time(in miliseconds) between consecutive compare events. uint32_t time_ticks; uint32_t err_code = NRF_SUCCESS;

    //UART Program
    uart_init();
    printf("\r\nStart!!");
    
    //Configure all LEDs on board.
    LEDS_CONFIGURE(LEDS_MASK);
    LEDS_OFF(LEDS_MASK);
    
    //Configure TIMER_LED for generating simple light effect - LEDs on board will invert his state one after the other.
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    timer_cfg.frequency = NRF_TIMER_FREQ_125kHz;
    err_code = nrf_drv_timer_init(&TIMER_LED, &timer_cfg, timer_led_event_handler);
    APP_ERROR_CHECK(err_code);
    time_ticks = nrf_drv_timer_ms_to_ticks(&TIMER_LED, time_ms);
    nrf_drv_timer_extended_compare(
         &TIMER_LED, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
    nrf_drv_timer_enable(&TIMER_LED);
    
    while (1)
    {
        __WFI();
    }
    

    }

Reply
  • int main(void) { uint32_t time_ms = 500; //Time(in miliseconds) between consecutive compare events. uint32_t time_ticks; uint32_t err_code = NRF_SUCCESS;

    //UART Program
    uart_init();
    printf("\r\nStart!!");
    
    //Configure all LEDs on board.
    LEDS_CONFIGURE(LEDS_MASK);
    LEDS_OFF(LEDS_MASK);
    
    //Configure TIMER_LED for generating simple light effect - LEDs on board will invert his state one after the other.
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    timer_cfg.frequency = NRF_TIMER_FREQ_125kHz;
    err_code = nrf_drv_timer_init(&TIMER_LED, &timer_cfg, timer_led_event_handler);
    APP_ERROR_CHECK(err_code);
    time_ticks = nrf_drv_timer_ms_to_ticks(&TIMER_LED, time_ms);
    nrf_drv_timer_extended_compare(
         &TIMER_LED, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
    nrf_drv_timer_enable(&TIMER_LED);
    
    while (1)
    {
        __WFI();
    }
    

    }

Children
No Data
Related