\ Scope.fs Stand 2010-04-14 \ Scope mit R8C/13 rs ram : Doit ; \ for MARKER %00000010 constant PD0 \ PRC2-bit $0A constant PREG \ Protect Register %00000001 constant TxD1 \ bit 0 is Output, bits 1..7 are ADC-Inputs $E2 constant PDIR \ Direction Register port0 $E5 constant port3 \ P30..P33 Input (not yet used) variable Chan variable Flucht create AdBuf &500 chars allot rom : AdcInit ( -- ) \ override lcdinit PD0 PREG bset \ enable PD0 in Protect Register TxD1 PDIR c! \ bit 0 is TxD1 Output, &20 ms \ bit 1..7 is Input Channel 6..0, settle ; : Channel ( -- ) begin key dup Chan c! dup \ Kanal 0..6 erlaubt $20 = if $20 Flucht ! \ space from HyperTerminal aborts then 6 > while repeat ; : Val@ ( chan -- val ) $80 + $D6 c! \ fAD/2 selected (adcon0) $20 $D7 c! \ Vref connected, 8 bit (adcon1) 6 $D6 bset \ start begin 6 $D6 btst 0= \ still converting? until \ no, ready $C0 c@ \ get value ; : Sample ( chan -- ) &500 0 do dup \ Kanal duplizieren Val@ AdBuf i + c! \ fill buffer loop drop \ letztes Duplikat entfernen &500 0 do AdBuf i + c@ emit \ send buffer loop ; : Blink port1 c@ $0F and 1 xor led! ; : Scope ( -- ) AdcInit 0 Flucht ! 0 led! \ AD initialisieren, keine Flucht begin Channel Chan c@ \ Kanal bestimmen, an Sample geben Sample Blink \ messen, zeigen und blinken $20 Flucht @ = \ bis Abbruch, dann ^C und Space im HT until begin key? until ; ' Scope is bootmessage \ laufe los nach Reset bis Leertaste ram savesystem \ "empty" vorher nicht vergessen?