Hi, I've collected a few timer related things from my sources and extracted some useful (at least I hope that they are useful) words for a common library of timers.
They can be found at the subversion repository in the trunk/lib/hardware directory. The timer library is layered: basic routines use the hardware timer 0 (or 1) to generate a millisecond tick. The current settings assume a 16MHz device (e.g. Arduino's). This will need adjustment for other frequencies. Above the hardware layer is a generic timer module that uses the tick information to provide generic timer related tasks: - after (runs a word after a specified amount of ms - every (runs a word every xy ms, a special case is every-second) and a few more words. In the timer-test.frt are some use cases. The routines assume a multitasking environment, esp the "every" part will block any interaction if called in the command line task. pause is called very often (the word passed to every is not executed in background but the whole thing may be used in background tasks) There may be some additional delay (2ms per cycle) as per : test-every-second @tick u. key? ; ' test-every-second every-second 439 1441 2443 3445 4447 5449 6451 7453 8455 9457 10459 ok so the "after" means "at least wait xy milliseconds, maybe more." (serial IO needs its time) I'm currently happy with what the words do (good enough). Next step is to write some recipes on how to use the library. Matthias PS: to find the optimal settings for the TWI/I2C I've written a small web-calculator at http://amforth.sourceforge.net/recipes/twi.html ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel