1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-17 08:08:07 +11:00
collapseos/blk/321
Virgil Dupras 8bf6258673 Add word TICKS
Adding a delay such as the 20ms one we have in AVR programmer's
initialization routine is tricky without a word like TICKS.

This implementation is highly inaccurate, but more accurate and
reliable than a "ballpark" DO..LOOP...
2020-09-25 17:31:06 -04:00

14 lines
527 B
Plaintext

( The word below is designed to wait the proper 100us per tick
at 500kHz when tickfactor is 1. If the CPU runs faster,
tickfactor has to be adjusted accordingly. "t" in comments
below means "T-cycle", which at 500kHz is worth 2us. )
CODE TICKS
HL POP, chkPS,
( we pre-dec to compensate for initialization )
BEGIN,
HL DECd, ( 6t )
IFZ, ( 12t ) JPNEXT, THEN,
A tickfactor @ LDri, ( 7t )
BEGIN, A DECr, ( 4t ) JRNZ, ( 12t ) AGAIN,
JR, ( 12t ) AGAIN, ( outer: 37t inner: 16t )