Shop OBEX P1 Docs P2 Docs Learn Events
BS2 Code for an 8870 DTMF Decoder — Parallax Forums

BS2 Code for an 8870 DTMF Decoder

Brian RileyBrian Riley Posts: 626
edited 2005-04-29 00:57 in BASIC Stamp
I have a bunch of 8870 DTMF decoders I want to use for some projects. Its a little brother to the 8880 for which there is a lot of code.

The 8870, since it only neds to decode doesn't seem to need much of the code commanding read or write etc. I did some quick breadbaording and coding yesterday but had no luck ... essentially I looped reading the 'Data valid' pin, then when it asserted, I read the four data pins. I know I am doing something wrong so .... I thought I would ask around.

Anybody got some 8870 code to share? TNX.


cheers ... 73 de brian, n1bq, underhill center, vermont

Comments

  • edited 2005-04-27 22:07
    Hello,
    ··········· You should be able to just use· the old docs we had on the 8880 and just remove the transmit part, but if not I did a quick search and found this site http://www.bobblick.com/techref/projects/tonedec/tonedec.html
    I have also attached our old docs to the post.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Stephen Swanson

    Technical Support
    Parallax, Inc.
    sswanson@parallax.com

  • Brian RileyBrian Riley Posts: 626
    edited 2005-04-28 00:30
    I am sorry but that wasn't much help .... I did some Googling and did find something. I need to sort it out but it looks like it contains what I want.

    I used the string "8870 dtmf decode bs2" in Google and I got this:

    <http://pages.infinit.net/cyrberg/files/Phone_V1.pdf&gt;

    Thanks, I will get back at you with a cleaned up version of the 8870 part of this code as soon as I get it working
  • Brian RileyBrian Riley Posts: 626
    edited 2005-04-29 00:57
    I went through the code it showed in the above article and then reread the docs (sound of hand slapping forehead). It is trivially easy. Since the 8870 only decodes you don't get caught up in having to write to a command register or anything. The only trick is that once you detect data valid you have to assert the Tri-State Output Enable, then go read the data and, of course, remember to lower the TOE when you are done. Here is the code snippet I slapped together this afternoon and it works just fine.

    cheers ... 73 de brian, n1bq, underhill center, vermont

    '----------------------
    ' M8870 Code Snippet
    '----------------------
    
    '----[noparse][[/noparse] Constants ]-------------------------------------------------------
    Q0        PIN    0    ' data bit 0
    Q1        PIN    1    ' data bit 1
    Q2        PIN    2    ' data bit 2
    Q3        PIN    3    ' data bit 3
    '-----
    StD        PIN    4    ' delayed steering - i.e. valid data
    TOE        PIN    5    ' Tri-state output enable raise logic high
                    ' to get data from chip
    TIMEOUT        CON    5000    ' some value for timeout so loop ends
    '-------------------------------------------------------------------------
    Tone_val    VAR    Byte
    index    VAR    Word
    '-------------------------------------------------------------------------
    ' Get_DTMF - returns  0-15 for valid DTMF, 99 for timeout
    '--------------------------------------------------------
    Get_DTMF:
       Tone_val =99
       FOR index=0 to TIMEOUT STEP 1  
          IF IN4 = 1 THEN
             HIGH    TOE
             Tone_val = INA
             LOW    TOE
             EXIT
          ENDIF
       NEXT
    RETURN
    
    
Sign In or Register to comment.