[Haskell-cafe] Timing in atom -- how consistent?

Tom Hawkins tomahawkins at gmail.com
Fri Jan 1 10:32:23 EST 2010

On Fri, Jan 1, 2010 at 4:43 AM, Jason Dusek <jason.dusek at gmail.com> wrote:
>  I'm working with Atom to program an ATtiny25. I am curious
>  about how consistent the timings actually are.

The function returned by Atom is intended to be called periodically,
preferably using some hardware timer, like this:

while (1) {

This provides consistent cycle-to-cycle timing.  However, the events
that occur within the Atom function will most likely vary in time from
call to call, due to rules being scheduled at different periods.

>  Also, I am a little puzzled by the `__coverage` variable. What
>  does it do?

__coverage keeps track of which rules have fired during the execution
of a program to provide some measure of code coverage.  The compiler
returns RuleCoverage[1], which is a list of rule names with associated
indices bit positions to the __coverage array.  Inside an Atom
program, you can access this array with nextCoverage[2], which
provides the current index and value of __coverage[index].  Repeated
calls to nextCoverage would loop through the __coverage array.  This
feature was added before Atom had support for arrays, so it should
probably be rewritten as some point in the future.

[1] type RuleCoverage = [(Name, Int, Int)]
[2] nextCoverage :: Atom (E Word32, E Word32)

>  As for my project/motivation -- I'm just trying to blink a
>  little LED on much less robust/rich kit -- the Trippy RGB
>  Waves kit from Lady Ada. I am (gratuitously) exploring ways to
>  program it with Haskell.
> --
> Jason Dusek
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list