6 Replies Latest reply on Jun 13, 2018 12:13 AM by BoonT_56 Branched from an earlier discussion.

    Re: HW Timer in 2073x (con't)

    mosac_2218871

      Hi,

      Regarding this closed thread here: HW Timer in 2073x

       

      can you explain a little bit that how can we access the register of a timer? I want to start a timer at a specific point and if sth happens later I want to stop the timer and measure the time it took between these two(start and stop). also, this elapsed time is in order of 1-3 milliseconds so the timer resolution must be high I guess. I was thinking of using hw_timer but I didn't find enough resources about its register and how to operate it. if you help me a little I will be thankful forever...(if you have another method of measuring the time between two incidents I  will be thankful to hear it.)

       

      BTW, I'm new to all these and I'm using bcm20737(now cyw20737?)

        • 1. Re: HW Timer in 2073x (con't)
          BoonT_56

          You can try out something similar to the below:

           

          devlpm_registerForLowPowerQueries(app_hw_timer_device_lpm_queriable, 0); /*disable sleep*/

           

          hw_timer_register_timer_expired_callback(app_hw_timer_interrupt_handler);

          hw_timer_start(100000); /*start the timer, expiring in 100ms*/

           

          void app_hw_timer_int_handler(void)

          {

          hw_timer_stop(); /*clears interrupt*/

          ble_trace0("hw timer fire");

          hw_timer_start(100000); /*restart the HW timer to expire in 100ms*/

          }

           

          Remember to declare interrupt handler.

          1 of 1 people found this helpful
          • 2. Re: HW Timer in 2073x (con't)
            mosac_2218871

            Thanks for the answer, I do appreciate it.

            from what I understood, this code sets the timer to 100ms but as I said in my previous post, I want to measure time with .5ms accuracy. from what I know of timers, it's a register that has 32 bits so whenever we set it, it will count from 0 to maximum 2^32-1. so here what I want to do, when a specific line execute in my code, I will set a timer and about 1 to 3 milliseconds later when another line of code happens, I want to stop the timer and measure the time between(perhaps by knowing how much it has counted till that moment). As I said the order of this elapsed time is 1 to 3 milliseconds and I want to be able to measure it with at least .5 millisecond accuracy.

             

            about your code, what does ble_trace0("hw timer fire") do? how can I declare interrupt handler? and how can I know how much the timer has counted when I stop the timer?

             

            any help is highly appreciated.

            • 3. Re: HW Timer in 2073x (con't)
              BoonT_56

              I think there is some discussion on the stability of the FW operation for anything below 3.5ms as the watchdog may be tripped.

               

              ble_trace0 is to display the argument message when triggered, useful for tracing. There are some good threads in the forum like the below:

               

               

              BCM20737S HW timer problem

              1 of 1 people found this helpful
              • 4. Re: HW Timer in 2073x (con't)
                mosac_2218871

                Thanks. I could run the hw_timer and solve a part of the problem. I now need to use two timers simultaneously. is there another timer(instead of the fine timer and hw_timer)? if yes, how can I run that? I've heard about something like bleapptimer, but I don't know if that's the same thing as the fine timer and I don't know how to run that.

                • 5. Re: HW Timer in 2073x (con't)
                  AnjanaM_61

                  Hi,

                   

                  Are you asking about bleapptimer_startTimer in bleapptimer.h ?

                   

                  -Thanks,
                  Anjana

                  • 6. Re: HW Timer in 2073x (con't)
                    BoonT_56

                    You may consider using the SW/app timers:

                     

                    bleprofile_regTimerCb(app_finetimer_callback, app_timer_callback);

                    bleprofile_StartTimer();

                     

                    The app_timer is 1s resolution and the app_finetimer is 12.5ms

                     

                    Check out any app for the full implementation.

                    1 of 1 people found this helpful