The timer routine with automated tck_ms (float) calculation (I had
to test the tck_ms calculation a little bit..):
...
\ MEASURE TIME IN SECONDS (FLOAT)
decimal
2variable elapsed_ticks
\ tck_ms = 1 / f_cpu / timer2_overflow_count /
timer2_prescaler_ratio
\ tck_ms = 1 / f_cpu / 256 / 1024
f_cpu d>f 256 s>f f/ 1024 s>f f/ _1 fswap f/  fconstant tck_ms
: timer-start ( -- ) timer 2@ elapsed_ticks 2! ;
: timer-stop (  -- f ) timer 2@ d>f elapsed_ticks 2@ d>f f- tck_ms
f* ;
\ print elapsed time in ms e.g. 1234567 ms 
: prnt_elapsed_ms ( f -- ) _1e3 f* f>d d. ;

P.


------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Amforth-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to