fl hex { Modified Digital Tester P-10 for RS232(2400bps,8bit,NoParity,1StopBit) 2012/12/11 22:01:35 PropForth5.2/5.0 Propeller 3.3V(Prop) Vcc(P-10) | | 1ohm 750ohm | PC621(P-10) | | --------- | P2 ------------|4 1|------- Tx(P-10) | | GND(Prop)---- -|3 2|---GND(P-10) --------- } \ allocate string \ ( -- ) : s, parsenw dup C@ 1+ bounds dup rot2 do C@++ c, loop drop ; \ datas transmitted from P-10 wvariable P10_array d12 allot \ LCD-display-number-font wvariable LCD_number -2 allot h00 c, h7D c, h05 c, h5B c, h1F c, h27 c, h3E c, h7E c, h15 c, h7F c, h3F c, h68 c, \ units string wvariable unit1 -2 allot s, diode s, k s, n s, u wvariable unit2 -2 allot s, speaker s, M s, % s, m wvariable unit3 -2 allot s, HOLD s, delta s, ohm s, F wvariable unit4 -2 allot s, Battery s, Hz s, V s, A lockdict create hdserialRx forthentry $C_a_lxasm w, h124 h113 1- tuck - h9 lshift or here W@ alignl h10 lshift or l, z8iQ3B l, z20yPO8 l, z2WyPj8 l, z8iQBB l, z2WyPO0 l, z2WiPuG l, zbyPr2 l, z20iPuG l, z3jFQBH l, z3nFQBH l, z20iPyk l, z3riPuG l, z1YFQFl l, zbyPO1 l, z1vyPQ0 l, z3[yPnU l, z1SV01X l, freedict { half duplex serial structure 00 - 04 -- rx bitticks 04 - 08 -- tx bitticks 08 - 0C -- rx pin mask 0C - 10 -- tx pin mask } \ hdserialStruct ( rxbaud txbaud rxpin txpin -- ) : hdserialStruct lockdict variable hC allot lastnfa nfa>pfa 2+ alignl freedict tuck swap >m swap hC + L! tuck swap >m swap h8 + L! tuck swap clkfreq swap u/ swap h4 + L! swap clkfreq swap u/ swap L! ; \ HalfDuplex [Receive 2400bps P2 Transmitt 2400bps P2 (Not Used)] d_2400 d_2400 d_2 d_2 hdserialStruct ser \ Display string \ ( n1 n2 -- ) n1:string index n2:string's top address : dispStr swap dup 0 <> if 0 do dup C@ + 1+ loop else drop then .cstr ; \ Get number from display-data-font on LCD \ ( n1 -- n2 ) n1:byte-number(1,3,5,7) n2:number \ d10 express character"L". : getNumber \ Get display-data-font on LCD) P10_array swap 2dup + C@ 7 and 4 lshift rot2 1+ + C@ hF and or \ Get number ftom display-data-font LCD_number d12 0 do 2dup i + C@ = if i rot2 d11 seti 2drop then loop \ dup 0 <> if 1- then 1- ; : test begin ser hdserialRx dup hF0 and h10 = if P10_array C! d13 0 do ser hdserialRx i 1+ P10_array + C! loop d14 0 do i P10_array + C@ . loop cr else drop then fkey? swap drop until ; \ Display receiving datas to TeraTerm : test1 begin ser hdserialRx dup hF0 and h10 = if P10_array C! d13 0 do ser hdserialRx i 1+ P10_array + C! loop \ d14 0 do i P10_array + C@ . loop cr \ AC/DC P10_array C@ dup 8 and if drop ." AC " else 4 and if ." DC " then then \ Sign P10_array 1+ C@ 8 and if ." - " then \ 4-digits 4 0 do i 2 u* 1+ dup \ dp i 0 <> if P10_array + C@ h8 and if ." ." then else drop then \ number getNumber dup 0< if drop space else dup d10 = if drop ." L" else . then then loop \ u n K diode 9 P10_array + C@ hF and dup 0 <> if 4 0 do dup 1 i lshift and if drop i 5 seti then loop unit1 dispStr else drop then \ n % M speaker d10 P10_array + C@ hF and dup 0 <> if 4 0 do dup 1 i lshift and if drop i 5 seti then loop unit2 dispStr else drop then \ F ohm delta hold d11 P10_array + C@ hF and dup 0 <> if 4 0 do dup 1 i lshift and if drop i 5 seti then loop unit3 dispStr else drop then \ A V Hz battery d12 P10_array + C@ hF and dup 0 <> if 4 0 do dup 1 i lshift and if drop i 5 seti then loop unit4 dispStr else drop then cr else drop then fkey? swap drop until ; decimal { fl build_BootOpt :rasm \ treg6 - serpin mask \ treg5 - bitticks \ treg4 - cnt nextbit \ treg1 - serialStruct \ stTOS - data rdlong $C_treg5 , $C_stTOS add $C_stTOS , # h8 \ \ receive bit counter \ mov $C_treg3 , # d_8 \ rdlong $C_treg6 , $C_stTOS \ \ serpin as input \ \ andn dira , $C_treg6 \ \ data byte \ mov $C_stTOS , # 0 \ \ first loop tick count, 1.25 bit times so we sample closer to the middle \ necessary in the assembler routine, in the forth routine, the delays of the loop setup \ make this unecessary so we only use 1 bit time \ mov $C_treg4 , $C_treg5 shr $C_treg4 , # 2 add $C_treg4 , $C_treg5 \ \ wait for a hi to lo transition \ waitpeq $C_treg6 , $C_treg6 waitpne $C_treg6 , $C_treg6 \ \ first loop tick count \ add $C_treg4 , cnt __rxloop waitcnt $C_treg4 , $C_treg5 test $C_treg6 , ina wz \ shr $C_stTOS , # 1 muxnz $C_stTOS , # h_80 \ djnz $C_treg3 , # __rxloop \ jexit ;asm hdserialRx }