NRF_TIMER4->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled PRESCALER = 0 NRF_TIMER4->MODE = TIMER_MODE_MODE_Timer In my example in this article, the function to be interrupted will be passed in as a parameter #define SAMPLES_PER_SECOND (2000000) I have seen similar codes with Timer4 settingsīut I don't know how he calls PPI to work This is related to the accuracy of the sampled data In small systems like this, with contrained memory, I like keeping things as bare bones as possible.What I need is a "fixed cycle" to read the data In this project, there’s a well known list of actions, and there’s no need for any dynamic allocation. And needless to say, if an action never returns, then nothing else will run! This is totally fine for this design where precision timing is not required (and ticks are measured in minutes which is almost eternal time for a microprocessor).Īn application like mine doesn’t really require the sophistication of an OS like task scheduler.Īlso, notice the use of fixed arrays (e.g. The end result is that it is possible that some functions will not run exactly at the time you scheduled them. And because they all run in the main thread (if we can call it that way), you are free to use any time limiting/manipulation function (e.g. All actions run sequentially one after the other. Notice that this scheduler has no notion of precise time. sendStatsAction, 480 ) // Every 8 hours Features and limitations synchClockAction, 1440 ) // Once a day for a 1 min / tick frequency dispatcher. saveStatsAction, 120 ) // Every 120 dispatcher. showQuoteAction, 5 ) // Every 5 ticks dispatcher. Setup is trivial (usually in the setup function of the sketch):ĭispatcher. The other methods are various getters and setters to the ACTIONS data structure.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |