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

FreeRTOS with BLE and ADC (nrf52)

Hi,

I'm looking for an example which combines FreeRTOS, BLE and ADC on nrf52 board(10040). I'm able to have FreeRTOS with BLE, FreeRTOS with ADC but not everything together.

I have a conflict in using timer. FreeRTOS clock is launch via nrf_drv_clock_init(). BLE uses app_timer functionnalities. And ADC needs a timer for ppi configuration. I don't understand how the differents timers can coexist. On the differents example I found in github, there is no config with all these constants defined :

#define CLOCK_ENABLED  //Used for FreeRTOS clock
#define TIMER_ENABLED   //Used to enabled Timer 0
#define TIMER3_ENABLED //Timer used for adc (via ppi)

Is anyone has an example. It could help me to understand my misunderstanding of the way it works.

Parents
  • Yes, I ran your code just now and found the problem.

    The problem is that you are not initializing timer priority so it is set with default priority of 0 which is not allowed by softdevice.

    Initialize your timer3 like below

    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    
    err_code = nrf_drv_timer_init(&m_timer, &timer_cfg, timer_handler);
    APP_ERROR_CHECK(err_code);
    

    And you then the timer3 intterupt will be with priority 6 which is allowed by softdevice.

Reply
  • Yes, I ran your code just now and found the problem.

    The problem is that you are not initializing timer priority so it is set with default priority of 0 which is not allowed by softdevice.

    Initialize your timer3 like below

    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    
    err_code = nrf_drv_timer_init(&m_timer, &timer_cfg, timer_handler);
    APP_ERROR_CHECK(err_code);
    

    And you then the timer3 intterupt will be with priority 6 which is allowed by softdevice.

Children
Related