Can I clear BLE_BASETIMECNT

9 posts / 0 new
Last post
Dave.Renzo
Offline
Last seen:2 years 6 months ago
加入:2015-10-08 13:21
Can I clear BLE_BASETIMECNT

Hello Support,

The short version is, can I clear BLE_BASETIMECNT without screwing up the BLE core? I noticed in reg_blecore.h that there is #define BLE_BASETIMECNT_RESET 0x00000000 which I assume is a bitmask that can be used to clear the count. Is this possible?

My design currently functions as follows: on device power up I Immediately put it to sleep by calling arch_ble_ext_wakeup_on() in my db initialization callback function. The end user can then press a button to turn the device "on" and it starts advertising etc... Part of the requirement for my application is to advertise the elapsed time since the tag was activate(woken from sleep with the pushbutton interrupt). The problem is that calling lld_evt_time_get() reports the total time since power up. What I'd like to be able to do is clear the BLE_BASETIMECNT register right after the device wakes up. Any help or suggestions would be greatly appreciated. Thanks.

Device:
MT_dialog
Offline
Last seen:1 month 5 days ago
Staff
加入:2015-06-08 11:34
Hi Dave,

Hi Dave,

There is no reset bit for the BLE_BASETIMECNT register, also this register is zero every time the 580 falls to sleep and the value is compensated from the function lld_sleep_compensate_func_patched() where it gets the elapsed time from the low power clock. About your implementation you can use a kernel timer to count and set the kernel timer accurancy to the accurancy that your tag needs and when the time elapses increment a counter in the timer handler. Also another idea to try would be to measure time with lld_evt_time_get and retain the value of the previous wake up in the next wake up you can calculate the interval by subtracting the current and the previous wake up.

Thanks MT_dialog

Dave.Renzo
Offline
Last seen:2 years 6 months ago
加入:2015-10-08 13:21
I've tried using the kernel

I've tried using the kernel timer, but it is not accurate. I lost about 20 seconds over 15 hours with the timer set to expire every 60 seconds. Is there a blocking function I can call that will block until the ble core is fully operational? Right now, I am updating the advertising data, when the device wakes and then every minute thereafter. The problem is, as you mentioned, that the BLE_BASETIMECNT register reads as 0's when it is read right after wakeup. I'd like to try the second method you mentioned, but I don't think it will work (at least as my code stands now) unless the ble core is fully active.

MT_dialog
Offline
Last seen:1 month 5 days ago
Staff
加入:2015-06-08 11:34
Hi Dave,

Hi Dave,

I am not sure what you mean about the blocking function until the core is fully operational, If you are talking about the BLE timer, in the SDK5 in the procedure of setting a timer the sw checks if the ble core is active and if it is it sets the timer directly using the ke_timer_set in case it isn't active it sends a mesage to the core and when the core is active it serves that message that sets a ble timer. There is no waiting function that puts the proccessing on hold while the core is waking up. Now about the second method you can try calling the lld_evt_time_get in the user_on_ble_powered callback in order to be sure that the core is active.

Thanks MT_dialog

Dave.Renzo
Offline
Last seen:2 years 6 months ago
加入:2015-10-08 13:21
I created a callback for user

I created a callback for user_on_ble_powered and am getting the dame result, when I call lld_evt_time_get(), it has not yet been updated with the time count from the low power clock.

MT_dialog
Offline
Last seen:1 month 5 days ago
Staff
加入:2015-06-08 11:34
Hi Dave,

Hi Dave,

You mean you are getting zeros ?

In the 5.0.2.1 SDK (in the template for example) if you place the below snippet only zeros are returned from UART ?

enum arch_main_loop_callback_ret user_on_ble_powered(void)
{
arch_set_pxact_gpio();
arch_puts("on-");
arch_printf("%i-", lld_evt_time_get());
arch_puts("\n\r");

return GOTO_SLEEP;
}

Thanks MT_dialog

Joacimwe
Offline
Last seen:1 year 4 months ago
Guru
加入:2014-01-14 06:45
Are you using the internal

Are you using the internal RCX clock or an external XTAL32?

Dave.Renzo
Offline
Last seen:2 years 6 months ago
加入:2015-10-08 13:21
I've tried with both, It

I've tried with both, It doesn't seem to make a difference.

MT_dialog
Offline
Last seen:1 month 5 days ago
Staff
加入:2015-06-08 11:34
Hi Dave,

Hi Dave,

Can you please try again on a fresh template project or on a fresh example like the barebone project ?

Thanks MT_dialog