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

Using app timer in sdk13

Hi all,

I am using a nRF52832 with SD S132 V4.0.2 ion SDK13.

My application currently uses TWI, SPI and BLE and also 1 wire (which is based on delays). Everything works fine. The 1 wire is used before the SD is enabled and after it is done it will not be used anymore, so it wouldn't interfere with the SD.

On my custom board I have an ADC conected through SPI. I want to take a sample every 100ms based on a app timer timeout. However the timeout interrupt is not fired.

I use the following code in main start:

NRF_LOG_INIT(NULL); // Initialize the logging module

err_code = app_timer_init();
APP_ERROR_CHECK(err_code);


/* Initialize peripherals */
adc_init();
twi_init();
press_init();
batt_init();
ds2431_getprofile();
measurement_init();
NRF_LOG_FLUSH();

/* Initialize bluetooth */
ble_stack_init();
peer_manager_init(erase_bonds);
gap_params_init();
gatt_init();
advertising_init();
ble_services_init();
conn_params_init();

/* Start advertising on start-up */
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code); 

measurement_start();

The timer is started in measurement_start and created in measurement_create:

APP_TIMER_DEF(m_pt100_timer_id);

void measurement_init(void)
{
	uint32_t time_base;
	ret_code_t err_code;

	/* Define a timer id used for 10Hz sample rate */
	err_code = app_timer_create(&m_pt100_timer_id, APP_TIMER_MODE_REPEATED, measurement_handler);
	APP_ERROR_CHECK(err_code);
}

void measurement_start(void)
{
	/* Start timer */
	app_timer_start(&m_pt100_timer_id, MEAS_TIMER_INTERVAL, NULL);

	/* Clear previous measurement in flash */

}

void measurement_handler(void * p_context) // this code is not fired
{
	float 	temperature = 0, pressure = 0;

	// do measurement, code currently not included
}

I have the following questions:

  1. Does app_timer module enable RTC1 or do I need to enable it?
  2. Do I need to initialize the LF clk?
  3. Should I first enable the softdevice and then the timer, or the other way around?
  4. Do you guys know why my timeout is not fired?
Parents
  • Hi,

    Q1: Does app_timer module enable RTC1 or do I need to enable it?

    A1: The app_timer module enable RTC1 in the function app_timer_init()


    Q2:Do I need to initialize the LF clk?

    A2:If you are using the SoftDevice, the LFCLCK gets initialized and enabled when you enable the SoftDevice.


    Q3:Should I first enable the softdevice and then the timer, or the other way around?

    A3: You can do both, but you won't get any timeout before the LFCLK is started.


    Q4:Do you guys know why my timeout is not fired?

    A4: Try to change app_timer_start(&m_pt100_timer_id, MEAS_TIMER_INTERVAL, NULL); with app_timer_start(m_pt100_timer_id, APP_TIMER_TICKS(100), NULL);

  • The rest of the application is working fine? The only problem is that the timeout is not fired?

    Have you tried debugging the application? Are you running into the error handler somewhere? See this post on how to debug.

Reply Children
No Data
Related