6 Replies Latest reply on Jan 25, 2017 3:44 PM by J.Pacheco

    Have to get somethings millis function

    estebaan

      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.

        • 1. Re: Have to get somethings millis function
          Tandy

          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 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

          • 2. Re: Have to get somethings millis function
            J.Pacheco

            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 (Re: millis() appears to have been implemented incorrectly ) 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.

            • 3. Re: Have to get somethings millis function
              FelipeDelgado

              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.

              • 4. Re: Have to get somethings millis function
                estebaan

                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;

                }

                • 5. Re: Have to get somethings millis function
                  J.Pacheco

                  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: 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

                  • 6. Re: Have to get somethings millis function
                    J.Pacheco

                    Hi guys,

                     

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

                     

                    Have a nice day!

                     

                    Best Regards,

                    -Jose.