fl { PropForth 5.5 2015/07/12 10:33:36 P0 ----- 220ohm -- SinglePhaseSteppMotor Coil -- P1 } \ =========================================================================== \ Constants \ =========================================================================== 0 wconstant out1 1 wconstant out2 clkfreq constant 1second d220 wconstant cw_pulse \ =========================================================================== \ Constants \ =========================================================================== variable flag \ =========================================================================== \ Main \ =========================================================================== lockdict create a_delay100us forthentry $C_a_lxasm w, h11C h113 1- tuck - h9 lshift or here W@ alignl h10 lshift or l, z1SyZKN l, z3[yPSJ l, z1SyLI[ l, z1SV01X l, z2WiP[R l, z20iPak l, z3ryPW0 l, z1SV000 l, z1vi l, freedict \ Initial setting \ ( -- ) : init out1 pinout out2 pinout -1 flag L! ; \ Check flag \ ( -- ) : check flag L@ invert flag L! flag L@ ; \ Rotate to cw \ ( -- ) : cw check if out1 pinhi d220 a_delay100us out1 pinlo else out2 pinhi d220 a_delay100us out2 pinlo then ; \ Rotate to ccw \ ( n1 -- ) n1:delay time[msec] : ccw check if out1 pinhi d70 a_delay100us out1 pinlo out2 pinhi d140 a_delay100us out2 pinlo else out2 pinhi d70 a_delay100us out2 pinlo out1 pinhi d140 a_delay100us out1 pinlo then ; \ Moving clock needle to cw/ccw \ ( -- ) : demo init d60 0 do cw d200 delms loop d60 0 do ccw d200 delms loop d10 0 do cw d1000 i d100 * - delms loop d10 0 do ccw d1000 i d100 * - delms loop ; { \ Delay word for unit 100usec \ ( n1 -- ) Delay time = n1 x 100usec \ $C_stTOS:n1 \ $C_treg1: fl build_BootOpt :rasm __1 jmpret __100usret , # __100us djnz $C_stTOS , # __1 spop jexit __100us mov $C_treg1 , __100usec add $C_treg1 , cnt waitcnt $C_treg1 , # 0 __100usret ret \ 5+(7996-18)=7983 __100usec d7983 ;asm a_delay100us }