Hi!
I have creat two timer with app_timer_init.
start the first timer trigger every 4 ms, every 125 times(approximately 0.5 sec) to start the second timer which trigger every 8 ms, so if i get count by second timer trigger, I think I can get around 60 triggers at once first timer 0.5 sec cycle, but I saw the random number around 60~65 triggers.
I print every trigger's time with second timer, there is some trigger has incorrect time interval. How to make it right?
NRF51422
SDK9
Softdevice S310 3.0.0
There is my code:
static void timers_init(void)
{
err_code = app_timer_create(&m_csc_meas_timer_id,APP_TIMER_MODE_REPEATED,
(app_timer_timeout_handler_t)csc_meas_timeout_handler);
APP_ERROR_CHECK(err_code);
err_code = app_timer_create(&m_peak_timer_id, APP_TIMER_MODE_REPEATED,/*APP_TIMER_MODE_SINGLE_SHOT,*/
(app_timer_timeout_handler_t)ready_meas_timeout_handler);
APP_ERROR_CHECK(err_code);
}
m_csc_meas_timer_id is first timer => interval 4ms
m_peak_timer_id is second timer => calculate about 8ms
first timer =>
static void csc_meas_timeout_handler(void)
{
countA++;
if(countA==125)//4ms*125=500
{
app_timer_stop(m_peak_timer_id);
REV_TIME = rtc_cnt_get() >> 5;
cp_meas_count = 0;
tick_time=round((REV_TIME - B_time) * 0.5333);//for timer2 count 60 times
app_timer_start(m_peak_timer_id, tick_time, NULL);
B_time=REV_TIME;
countA=0;
}
}
second timer =>
static void ready_meas_timeout_handler(void)
{
cp_meas_count++;
TTT_cur = rtc_cnt_get();
printf("cp_meas_count[%d] rtc=%8d T:%5d ",cp_meas_count,TTT_cur, TTT_cur-TTT);
TTT = TTT_cur;
}