From: pito <pi...@vo...> - 2010-09-03 21:13:56
|
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. |