' **** "BASIC STAMP' demo for the ROHM BU8874 touch tone DTMF decoder **** ' **** (C) 3/18/93 Jim Gillespie Version 1.5 *** ' **** 1061 Elizabeth St. #207 ' **** Denver, Co 80206 ' ** port direction definitions input 0 ' tone present true high ( ROHM chip ESt pin 7 ) output 1 ' data clock true high ( ROHM chip ACK pin 6 ) input 2 ' touch tone data ( ROHM chip SD pin 5 ) output 3 ' relay and lamp driver true high ( BS170 TMOS transistor ) ' ** output port initialization ** low 1 ' clock low low 3 ' relay and lamp off ' ** register file variable initialization W4=0 ' 4 DTMF values assembled here bas ackwards w5=$21CB ' DTMF * # 1 2 match values bas ackwards ( saves time ) ' ** somewhat of a software state machine follows state1: if pin0=1 then state1 ' if tone still present, wait ( ESt ) state2: if pin0=0 then state2 ' hang here while no tone ( ESt ) present state3: if pin0=0 then state1 ' if a fairly quick 1 to 0, its a "glitch" w3=w4 ' save old value in case of a BCD "glitch" for b3=1 to 4 ' 4 bits to assemble W4=W4 / 2 ' shift last BCD value right 1 bit high 1 ' clock high ( ACK. SD data will appear ) if pin2 = 0 then state4 ' read SD bit. if 0 is read, do nothing b9 = b9 | $80 ' SD a 1. put in the msb of BCD word state4: low 1 ' clock low ( ACK ) next b3 ' loop til 4 bits assembled if pin0=0 then statex ' tone detect gone. probably a "glitch" if w4 <> w5 then state1 ' did 4 BCD digits match? toggle 3 ' YES! toggle relay and LED TMOS transistor goto state1 ' we got a BCD match & no "glitch". loop. statex: w4=w3 ' probably a "glitch". restore previous goto state1 ' BCD value and try again. end