\ delays.fs

\ 300 I/O
\ $e1 constant XBR0   \ port I/O crossbar Rigister 0
\ $e2 constant XBR1   \ port I/O croosbar Register 1
\ $e3 constant XBR2   \ port I/O crossbar Register 2

$a4 constant P0MDOUT

] \ Target Forth

:m push-pull  $FF # P0MDOUT ior! m;

:m pin3  3 .P0 m;
:m high  [ pin3 set ] m;
:m low   [ pin3 clr ] m;

:m 7loop  7 #for 7 #next m;
:m 6loop  6 #for 6 #next m;
:m 5loop  5 #for 5 #next m;
 
: us  ( n - )   7 #for  6 # 6loop  7 #next ;

: ms  ( n - )   
   7 #for 
      100 # 6 #for 
         81 # 5loop 
      6 #next 
   7 #next ;

: init   push-pull ;

\ measured 9.632 us high, 9.756 low (51.58 kHz) on a scope
: test1  begin  high 10 # us low 10 # us  again ;

\ measured 9.642 us high, 45.36 us low
: test2  begin  high 10 # us low 50 # us  again ;

\ measured 10.00 ms high, 10.00 ms low
: test3  begin  10 # ms high 10 # ms low  again ;

