4 posts / 0 new
Last post
liuluan002
Offline
Last seen:6 months 1 week ago
加入:2015-11-27 14:24
about the clock accurate for the clock

Hi Dialog,

我们是trying to use your clock to calibration our system timer. Since we do not have a real-time accurate clock. I am wondering how accurate is your system clock?
我们是using the oscillator you have suggested. Also we go to extended sleep also during running, we never use deep sleep.
The method we are going to get the time from your system is listed below:

#if DEBUG_LOG9
current_time1 = lld_evt_time_get();
print_word(current_time1);
printf_string("\n");
uart2_init(UART_BAUDRATE_115K2, 3);
#endif

Device:
MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi liuluan002,

Hi liuluan002,

lld_evt_time_get() that you mention measures the time based on the 625us base time counter, that counter doesn't have a steady clock input but changes depending whether the device is sleeping or it is awake and measures the time passed from power up based on the XTAL16 and the XTAL32. So the time that is measured is from the XTAL16 and when asleep the time that has elapsed during sleep is measured through the XTAL32 and gets compensated and applied to the timer when the device is awake, so that introduces an error on the time measured which is not fixed.

Thanks MT_dialog

liuluan002
Offline
Last seen:6 months 1 week ago
加入:2015-11-27 14:24
Hi Dialog,

Hi Dialog,

I am using the lld_evt_time_get() in the void press_button(void) interruption function to record the time when the PIN come from low to high suddenly. The button press is done by the interruption.

I have found during the sleeping, I can not get the time correctly. Is any way can I get the time for the button press even the sleeping time. Do I need to wake up and do some other initialization before I can call the function of "lld_evt_time_get()".

I have attached code below:
volatile uint32_t current_time22; //for the time log
void press_button(void)
{
if(GetBits16(SYS_STAT_REG, PER_IS_DOWN))
periph_init();

if((!(GetWord16(P0_DATA_REG) & (1 << 0 ))))
{
button_flag=3;
}

#if PINUP_TEST
if((GetWord16(P1_DATA_REG) & (1 << 5))) //PINUP
{
PINUP=1;
}
#endif
wkupct_register_callback(press_button);
wkupct_enable_irq(0x002000, 0x000000, 1, 0x00);

#if PINUP_TEST
if(PINUP==1)
{
current_time22 = lld_evt_time_get ();
}
#endif

}

void user_app_init(void)
{
//Initialize Manufacturer Specific Data
mnf_data_init();
default_app_on_init();
wkupct_register_callback(press_button);
wkupct_enable_irq(0x002000, 0x000000, 1, 0x00);//P15 INT2 PINUP //wkupct_enable_irq(0x000001, 0x000001, 1, 0x14);
}

Thank you for your help.

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi liuluan002,

Hi liuluan002,

As i ve mentioned above the register that the function that you mention reporrts uses as input different clocks (XTAL16 when operating and when waking up the compensated value of the XTAL32 while the device was in sleep mode), so you wont be able to read the value of the register at any time. If you are doing this via an external interrupt you will have to wake the BLE and when the BLE is up (you can read the value only when the BLE is awake). So what you can do is to invoke the arch_ble_force_wakeup() in order to indicate that you would like to wake up the BLE. But by invoking this functions doesn't mean that the BLE will wake up immidiatelly, this will just request the BLE to wake up, so in order to be sure that the BLE is awaken you need to print or in general use the lld_evt_time_get() in .the app_on_ble_powered callback, that should work.

Thanks MT_dialog