Long delay experienced when using app_timer_set

5 posts / 0 new
Last post
tingwang
Offline
Last seen:5 years 10 months ago
加入:2014-08-19 04:27
Long delay experienced when using app_timer_set

Hello,

Configured with CFG_EXT_SLEEP.

I'm doing periodic SPI RX from peripheral: 1. peripheral set GPIO high to notify DA14580; 2. DA14580 read back data via SPI. The request comes once per second, and it takes about 10ms to read all data.

Using wkupct_register_callback/wkupct_enable_irq, DA is notified by the external interrupt. I scheduled a timer to do the bulk work after 10ms, however it actually takes more than 100ms longer to hit the bulk handler.

What am I missing about the scheduler?

Regards,
Ting

tingwang
Offline
Last seen:5 years 10 months ago
加入:2014-08-19 04:27
Hi Dialog,

Hi Dialog,

I found the same problem has been reported previously in the forum:

http://support.dialog-semiconductor.com/apptimerset

But didn't any see solution there. Could you please share with us the solution or root cause of the problem? I guess the source of timer is not working in sleep modes...

Regards,
Ting

PY_Dialog
Offline
Last seen:2 years 7 months ago
Staff
加入:2014-08-25 09:59
Hi Tingwang,

Hi Tingwang,

Sorry, we can't fully understand your problems. What the bulk work refer to? What the bulk handler refer to? Are you code based on any of Dialog reference code projects?

Regards!
PY

tingwang
Offline
Last seen:5 years 10 months ago
加入:2014-08-19 04:27
Hi PY,

Hi PY,

我应该澄清,“大部分工作”nothing to do with the problem.

In my setup, da14580 port0/pin0 is connected with external interrupt source, there is 1Hz raising edge signal on port0/pin0.

My code is based on keil_projects/proximity/reporter_fh. In the main_func() before the while(1) loop, I did register callback to catch the GPIO trigger signal on port0/pin0:

// Setup ECG interrupt
wkupct_register_callback(ecg_wakeup_cb);

wkupct_enable_irq(1<<0, 0, 1, 0);

Following is the callback:

void ecg_wakeup_cb(void)
{
if(GetBits16(SYS_STAT_REG, PER_IS_DOWN)) {
periph_init();
}

app_timer_set(APP_ECG_TRIGGER_TIMER, TASK_APP, 1);
wkupct_enable_irq(1<<0, 0, 1, 0);

if (!(GetWord16(P0_DATA_REG) & (1<<1))) {
GPIO_SetActive(GPIO_PORT_0, GPIO_PIN_1);
} else {
GPIO_SetInactive(GPIO_PORT_0, GPIO_PIN_1);
}
}

In the callback, I started a timer to expire in 10ms, also toggle port0/pin1 for debug.

int app_ecg_trigger_handler(ke_msg_id_t const msgid,
void const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
ke_timer_clear(APP_ECG_TRIGGER_TIMER, TASK_APP);

if (!(GetWord16(P0_DATA_REG) & (1<<2))) {
GPIO_SetActive(GPIO_PORT_0, GPIO_PIN_2);
} else {
GPIO_SetInactive(GPIO_PORT_0, GPIO_PIN_2);
}

return (KE_MSG_CONSUMED);
}

The above "app_ecg_trigger_handler" is the timeout handler. It toggles another IO for debug purpose.

What I observed is that: when both extend sleep and deep sleep undefined, the timer expires in 10ms, works fine; however, when extend sleep is defined, the first timeout period is 10ms, those following timeout periods have large variation about 400 ~ 500ms.

Regards,
Ting

tingwang
Offline
Last seen:5 years 10 months ago
加入:2014-08-19 04:27
I'm using app_asynch_proc()

I'm using app_asynch_proc() to implement the logic, working fine now.

Regards,
Ting