Social distancing example hardware timer not running

Learn MoreFAQsTutorials

3 posts / 0 new
Last post
jagath52
Offline
Last seen:9 hours 57 min ago
加入:2020-07-06 10:40
Social distancing example hardware timer not running

Hello

I am using social distancing tag example with Wira sdk.

I created a timer which give intrrupt every 1 minutes and i tested it with gpio handling example by creating a seperate task which runs when timer isr handler gives the signal.

The same task i tried with social distancing example but in this whole application is not running

void _timer_init(void)
{
timer_config cfg = {
.clk_src = HW_TIMER_CLK_SRC_INT,
.prescaler = 0,

.mode = HW_TIMER_MODE_TIMER,
.timer = {
.direction = HW_TIMER_DIR_DOWN,
.reload_val = 1671168,
.free_run = true, /* Timer never stops counting */
},
};

hw_timer_init(HW_TIMER2, &cfg);

hw_timer_register_int(HW_TIMER2, _timer_overflow_cb);

}

void _timer_overflow_cb(void)
{

/* Clear TIMER1 interrupt flag */
hw_timer_clear_interrupt(HW_TIMER2);

printf("minute++");
hw_gpio_toggle(LED1_PORT, LED1_PIN);
OS_EVENT_SIGNAL_FROM_ISR(tempEvent);

}

}

void tempReadTask( void *params )
{
printf("*** TIMER1 Demonstration ***\n\r");

_timer_init();
hw_timer_enable(HW_TIMER2);

int8_t wdog_id;

/* Register ble_multi_link task to be monitored by watchdog */
wdog_id = sys_watchdog_register(false);

OS_EVENT_CREATE(tempEvent);

for (;;) {

/* Notify watchdog on each loop */
sys_watchdog_notify(wdog_id);
sys_watchdog_suspend(wdog_id);
OS_EVENT_WAIT(tempEvent, OS_EVENT_FOREVER);

printf("got intrrupt\r\n");
hw_clk_delay_usec(1000000);

/* Resume watchdog */
sys_watchdog_notify_and_resume(wdog_id);

}

}

I created the timer task in sys_init function

static void system_init( void *pvParameters )
{

.........................................

OS_TASK_CREATE("SDT-Task",
sdt_ble_events_task,
NULL,
4096,
SDT_RANGING_TASK_PRIORITY + 1,
handle);
OS_ASSERT(handle);
OS_BASE_TYPE os_status;

os_status = OS_TASK_CREATE("temprature task",
tempReadTask,
( void * ) 0,
1024,
OS_TASK_PRIORITY_NORMAL,
temp_task_h);
OS_ASSERT(os_status == OS_TASK_CREATE_SUCCESS);

.............

}

I tried creating and starting the timer from prvSetupHardware() function without creating a seperate task then also the whole application is not running

If the hardware timer is included then the social distancing example is not running

Thank you

Jagath

Device:
MHv_Dialog
Offline
Last seen:1 week 4 days ago
Staff
加入:2013-12-06 15:10
Hi Jagath,

Hi Jagath,

I have asked the Dialog team supporting the Social Distancing app to look into this. Expect an answer in a few days,

/MHv

PM_Dialog
Offline
Last seen:6 hours 17 min ago
Staff
加入:2018-02-08 11:03
Hi Jagath,

Hi Jagath,

Apologies for our late response - please see my feedback below :

1. You are using TIMER2 which is used for the OS-TICK. By changing this, you mess-up all the FreeRTOS. This is described in our documentation as well.You can use the TIMER2 for PWM for example BUT NOT re-configure it.

You can use OS-Timers instead which are even easier to use and they will be triggered based on TIMER2 ticking too.

If you want to use HW timer, then you can use TIMER (aka TIMER1) or TIMER3 or TIMER4. TIMER1 and TIMER2 are the only ones available in sleep. Please see datasheet for more info.

2, In the void _timer_overflow_cb(void) in your code you are using printf() which is not safe in ISR context. You should NOT print from ISR.

3. Additionally, in the void tempReadTask( void *params ) you have used hw_clk_delay_usec(1000000); Why don’t you use the OS_DELAY_MS() which will suspend the task and allow the system to sleep too? The hw_clk_delay_usec(); is meant to be used for active delays with a loop when the timeout of the delay is less than the OS_TICK=2ms. For anything else you should be using the FreeRTOS API.

I would recommend first checking theUM-B-092: DA1469x Software Platform Reference Manualuser manual in order to understand the SDK architecture and APIs.

The "fact" that you saw it running with the standard SDK does not prove anything. If you try it with the FreeRTOS retarget for example, took out all the code of the app and added yours, it will appear like working because there are no RTOS events. The RTOS and the system will not wake for anything else other than you trigger it.

Thanks, PM_Dialog