Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

How to Implement the HW Timer

lock attach
Attachments are accessible only for community members.

How to Implement the HW Timer

JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

The attached sample app implements the HW timer. Run traces on the app to see the HW timer callback fire once every 100ms--10 times for every SW timeout loop.

The necessary components to get the HW timer working are (see attached .c file for full implementation):

     -Disable sleep:   

          1.  #include "devicelpm.h"

          2.  devlpm_registerForLowPowerQueries(hello_hw_timer_device_lpm_queriable, 0);

          3.  UINT32 hello_hw_timer_device_lpm_queriable(LowPowerModePollType type, UINT32 context) { return 0; }

     -Import patch and declaration:

          1.  #include "hw_timer.h"

          2.  In your make target add:

                    APP_PATCHES_AND_LIBS += hw_timer.a

          3.  declare in your .c :

                    extern void hw_timer_int_handler(void);

     -Define callback (must call stop, only call start is you want a loop):

          void hw_timer_int_handler(void)

          {

               hw_timer_stop();

               //do something

               hw_timer_start(10000);

          }

     -Initialize:

          1.  hw_timer_register_timer_expired_callback(hw_timer_int_handler);

          2.  hw_timer_start(100000);

    See Sleep Deep_Sleep Explanation and Techniques for alternate methods of disabling sleep.

Jacob

Attachments
741 Views
Comments
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

This iKBA is valid for CYW2073x devices 

Contributors