' {$STAMP BS2} ' {$PBASIC 2.0} ' DTMF Decode ' with mt8880 chip ' ' rs CON 4 rw CON 5 cs CON 6 dtmf VAR Byte ' received dtmf digit dt_flag VAR Bit ' dtmf received flag dt_det VAR INL.BIT2 ' dtmf detected status bit polls VAR Word ' # of unsuccessful polls of dtmf sp_time CON 1500 ' print this # of polls w/o dtmf n24n CON $418d ' serout constant: 2400 baud inverted ' initialise the mt8880 for receive OUTL=%0111111 ' pin 7 (LCD) low,pins 0 to 6 high DIRL=%1111111 ' set up to write to mt8880 (all outputs) OUTL=%00011000 ' set up reg A, next write to reg b HIGH cs OUTL=%00010000 ' clear reg B,ready to send dtmf HIGH cs DIRL=%11110000 ' now set the 4-bit bus to input HIGH rw ' and set rw to "read" again: PAUSE 100 HIGH rs ' read status reg LOW cs ' activate the mt8880 dt_flag=dt_det ' store dtmf-detected bit into flag HIGH cs ' end the read IF dt_flag=1 THEN skip1 ' if tone detected then continue polls=polls+1 ' another poll without dtmf tone IF polls