Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
1,658 Views

Have to get somethings millis function

Hi

I´m working on a time critical process and i need the time stamp of the processor. How can i get the time from the start of the quark to the present. I want to make a temperature chart and I need the time that happens during the whole process.

Thanks.

0 Kudos
6 Replies
TEarl1
Novice
65 Views

Hi estebaan,

I am not sure if there is a 'millis' function in the standard library or not, but you can definitely get a timestamp from the processor.

What kind of resource are you looking for? Is millisecond resolution enough, or do you need microsecond resolution?

If you take a quick look at section 18 of the https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwj5sp-lqc_R... Quark D2000 datasheet, you will find the registers will let you set up a timer when the processor first boots, either based on the system clock or based on a 32,768Hz RTC clock (if you enable the RTC clock).

If you use the slower clock, the timer will overflow in (2 to the power of 17 seconds or) roughly 1.5 days. So you will need to increment a static variable when the overflow event occurs, to measure time beyond 1.5 days.

Then again, there may be a 'millis' function built in. In that case you can just call it and won't need to dig into the registers. Intel might have more helpful insights on that.

Tandy

Jose_P_Intel
Employee
65 Views

Hi estebaan,

Thanks for your interest in the Intel Quark Microcontrollers Platform.

I don't have knowledge of a function similar to "millis()", nevertheless I would recommend to check this thread ( ) where a user did a equivalent of "millis()" in C++.

I would recommend to use the RTC of the Quark instead of the function "clock_gettime(CLOCK_REALTIME, &t)".

Hope you find this information useful, have a nice day!

Best Regards,

-Jose.

idata
Community Manager
65 Views

Hi J.Pacheco

I wonder if you have some example of using the RTC of the Quark instead of the function clock_gettime()

Thanks in advance.

idata
Community Manager
65 Views

Hi

Thanks for the information, but look in the manual and there is no clear information to make the code, as FelipeDelgado, it would be useful to have an example of rtc. For the moment I am testing a code but the reading time is very small.

# include "qm_rtc.h"

# include "qm_gpio.h"

# include "qm_scss.h"

uint32_t itimex;

qm_pic_timer_config_t timer_handler;

//Init function, set initial time.

void millis_emulator_start() {

timer_handler.mode = QM_PIC_TIMER_MODE_PERIODIC;

qm_pic_timer_set_config(&timer_handler);

qm_pic_timer_set(0xFFFFFFFF);

qm_pic_timer_get(&itimex);

}

//Get function, get current emulated time in millis, overflow at 143 seconds.

uint32_t millis_emulator_get() {

uint32_t timex;

qm_pic_timer_get(&timex);

uint32_t realtimex = (itimex-timex)/30000;

return realtimex;

}

Jose_P_Intel
Employee
65 Views

Hi guys,

At the moment I don't have an example that uses the RTC of the Quark instead of the function clock_gettime(), but I have found this code that explains how to configure the RTC: https://github.com/01org/qmsi/blob/fd5a6a783df1ab99260302ea25e1efb6208dbd8f/examples/power/main.c qmsi/main.c at fd5a6a783df1ab99260302ea25e1efb6208dbd8f · 01org/qmsi · GitHub . Maybe it will be useful to you.

I hope this helps, have a nice day!

Best Regards,

-Jose

Jose_P_Intel
Employee
65 Views

Hi guys,

Do you have any more questions? Please let me know, in order to assist you.

Have a nice day!

Best Regards,

-Jose.

Reply