mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-06 02:31:01 +11:00
8bf6258673
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...
14 lines
527 B
Plaintext
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 )
|