ISD4002 Address Question


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    88

    Default ISD4002 Address Question

    Hello - I have started playing with an ISD4002 and have a working circuit and program. If I just want to record a message using the REC command and then play it back using the PLAY command, everything works fine. However, when trying to specify the address to start recording and playback (using SETREC and SETPLAY), I get nothing. I have poured through the forum and the spec sheet, but I can't seem to find out what I'm doing wrong. I would like to be able to record 2 different messages on the ISD chip and be able to chose which one to play back. I am using a PIC16LF628A chip and V2.5 PBP. Any insight would be appreciated. Thanks! Here is my code:
    Code:
    @ DEVICE HS_OSC              ; Hi Speed Osc  
    @ DEVICE WDT_ON              ; Enable Watch dog timer
    @ DEVICE PWRT_ON             ; Disable MCLR pin 
    @ DEVICE MCLR_OFF            ; Enable Power-up timer
    @ DEVICE BOD_OFF             ; Enable Brown-out detect
    @ DEVICE CPD_OFF             ; Code Protect Off
    @ DEVICE PROTECT_OFF         ; EEPROM Protect Off
        
        include "ModeDefs.bas"
        DEFINE OSC 20
        
        ' I/O Definition
        ' ===============
        '
        TRISA = %00001100    ' PORTA Output on :
                             '         PORTA.0 : Record LED 
                             '         PORTA.1 : Play Led
                             '
                             ' PORTA Input on :
                             '         PORTA.2 : "ALT PLAY" Button
                             '         PORTA.3 : "PLAY" button    
                             '
        TRISB = %01111001    ' PORTB Output on : 
                             '         PORTB.1 : ISD4002 SS pin 
                             '         PORTB.2 : ISD4002 SCLK pin 
                             '         PORTB.7 : ISD4002 MOSI pin
                             '
                             ' PORTB Input on :
                             '         PORTB.0 : ISD4002 INT pin
                             '         PORTB.5 : ISD4002 MISO pin
                             '         PORTB.6 : ISD4002 RAC pin
                             '         PORTB.3 : "SETUP" button
                             '         PORTB.4 : "RECORD" button
                             
        OPTION_REG.7 = 0     ' enable pull-up on PORTB
        CMCON = 7            ' disable analog comparator
        
        ' Variable definition
        ' ===================
        '
        RecordLED       var PORTA.0
        PlayLED         var PORTA.1
        AltPlayBtn      var PORTA.2 ' "ALT PLAY" button
        PlayBtn         var PORTA.3 ' "PLAY" button
        StopBtn         var PORTB.3 ' "STOP" button
        RecordBtn       var PORTB.4 ' "RECORD" button
        INT             var PORTB.0 ' ISD4002 INT pin
        SS              var PORTB.1 ' ISD4002 SS pin
        SCLK            var PORTB.2 ' ISD4002 SCLK pin
        MOSI            var PORTB.7 ' ISD4002 MOSI pin
        MISO            var PORTB.5 ' ISD4002 MISO pin
        RAC             var PORTB.6 ' ISD4002 RAC pin
    
        ' ISD4002 Control Values:
        ' bits 0, 1 & 2 are actually bits 9, 10 & 11 of address
        CmdPwrUp        con $20   '%00100000  Power up the device 
        CmdPlay         con $F0   '%11110000  Start playback
        CmdRec          con $B0   '%10110000  Start recording
        CmdStop         con $30   '%00110000  Stop current operation
        CmdStopPwrDn    con $10   '%00010000  Stop playback or record and power down
        CmdSetPlay      CON $70   '%11100000  Set the playback address
        CmdSetRec       CON $A0   '%10100000  Set the record address
        
        ISDAddress      var word
     
    '****************************************************************
        Pause 1000
        high PlayLed
        HIgh RecordLED
        pause 500
        low PlayLed
        Low recordled
    
    Start: 'scan buttons
        if Recordbtn = 1 then
            high recordLED
            pause 250
            gosub RecordAudio
            low RecordLED
        endif
        
        if PlayBtn = 1 then
            high PlayLED
            pause 250
            gosub PlayBack
            low PlayLED
        endif
        goto Start
    
    '****************************************************************
    RecordAudio: ' Record message
        LOW SS 'Select isd4002 
        SHIFTOUT MOSI,SCLK,LSBFIRST,[CmdPwrUp\8]
        HIGH SS 'De-Select isd4002
        PAUSE 25
        
        LOW SS 
        SHIFTOUT MOSI,SCLK,LSBFIRST,[CmdPwrUp\8]
        HIGH SS 
        PAUSE 50     
    
        'start recording at address 0
        ISDAddress.lowbyte = %00000001
        ISDAddress.Highbyte = CmdsetRec
        'ISDAddress = 10100000 00000001
    
        LOW SS 
        SHIFTOUT MOSI,SCLK,LSBFIRST,[ISDAddress\16]
        HIGH SS 
    
    Wait4Stop:
        if StopBtn = 0 then goto Wait4Stop
        gosub StopOp 'Issue Stop Operation cmd 
        return
        
    '****************************************************************    
    PlayBack: ' Play Audio 
        LOW SS
        SHIFTOUT MOSI,SCLK,LSBFIRST,[CmdPwrUp\8]
        HIGH SS 
        PAUSE 25
         
        'start playback from address 0
        ISDAddress.lowbyte = %00000001
        ISDAddress.Highbyte = CmdsetPlay
        
        LOW SS 
        SHIFTOUT MOSI,SCLK,LSBFIRST,[ISDAddress\16] 'Start Playback
        HIGH SS 
        pause 25
    
    Wait4Done:
        if int = 1 or StopBtn = 1 then goto wait4done
        gosub StopPwrDn
        return 
           
    '****************************************************************    
    StopPwrDn: ' Reset ISDInt and power down cmd 
        LOW SS 
        SHIFTOUT MOSI,SCLK,LSBFIRST,[CmdStopPwrDn\8]
        HIGH SS 
        pause 20
        return
         
    '****************************************************************    
    StopOp: ' Stop Operation 
        LOW SS 
        SHIFTOUT MOSI,SCLK,LSBFIRST,[CmdStop\8]
        HIGH SS
        pause 20
        return 
    
    '****************************************************************
    end

  2. #2
    Join Date
    Sep 2006
    Location
    Florida, USA
    Posts
    88


    Did you find this post helpful? Yes | No

    Default Problem Solved!

    Well, I figured out my problem. I had the wrong value for SetPlay. Once I found that, everything worked fine. Here is the updated code:
    Code:
    @ DEVICE HS_OSC              ; Hi Speed Osc  
    @ DEVICE WDT_ON              ; Enable Watch dog timer
    @ DEVICE PWRT_ON             ; Disable MCLR pin 
    @ DEVICE MCLR_OFF            ; Enable Power-up timer
    @ DEVICE BOD_OFF             ; Enable Brown-out detect
    @ DEVICE CPD_OFF             ; Code Protect Off
    @ DEVICE PROTECT_OFF         ; EEPROM Protect Off
        
        include "ModeDefs.bas"
        DEFINE OSC 20
        
        ' I/O Definition
        ' ===============
        '
        TRISA = %00001100    ' PORTA Output on :
                             '         PORTA.0 : Record LED 
                             '         PORTA.1 : Play Led
                             '
                             ' PORTA Input on :
                             '         PORTA.2 : "ALT PLAY" Button
                             '         PORTA.3 : "PLAY" button    
                             '
        TRISB = %01111001    ' PORTB Output on : 
                             '         PORTB.1 : ISD4002 SS pin 
                             '         PORTB.2 : ISD4002 SCLK pin 
                             '         PORTB.7 : ISD4002 MOSI pin
                             '
                             ' PORTB Input on :
                             '         PORTB.0 : ISD4002 INT pin
                             '         PORTB.5 : ISD4002 MISO pin
                             '         PORTB.6 : ISD4002 RAC pin
                             '         PORTB.3 : "SETUP" button
                             '         PORTB.4 : "RECORD" button
                             
        OPTION_REG.7 = 0     ' enable pull-up on PORTB
        CMCON = 7            ' disable analog comparator
        
        ' Variable definition
        ' ===================
        '
        RecordLED       var PORTA.0
        PlayLED         var PORTA.1
        AltPlayBtn      var PORTA.2 ' "ALT PLAY" button
        PlayBtn         var PORTA.3 ' "PLAY" button
        StopBtn         var PORTB.3 ' "STOP" button
        RecordBtn       var PORTB.4 ' "RECORD" button
        INT             var PORTB.0 ' ISD4002 INT pin
        SS              var PORTB.1 ' ISD4002 SS pin
        SCLK            var PORTB.2 ' ISD4002 SCLK pin
        MOSI            var PORTB.7 ' ISD4002 MOSI pin
        MISO            var PORTB.5 ' ISD4002 MISO pin
        RAC             var PORTB.6 ' ISD4002 RAC pin
    
        ' ISD4002 Control Values:
        ' bits 0, 1 & 2 are actually bits 9, 10 & 11 of address
        '                           CCCCCAAA
        '                           43210119
        '                                10
        CmdPwrUp        con $20   '%00100000  Power up the device 
        CmdPlay         con $F0   '%11110000  Start playback
        CmdRec          con $B0   '%10110000  Start recording
        CmdStop         con $30   '%00110000  Stop current operation
        CmdStopPwrDn    con $10   '%00010000  Stop playback or record and power down
        CmdSetPlay      CON $E0   '%11100000  Set the playback address
        CmdSetRec       CON $A0   '%10100000  Set the record address
        
        ISDAddress      var word
     
    '****************************************************************
        Pause 500
        high PlayLed
        HIgh RecordLED
        pause 500
        low PlayLed
        Low recordled
    
    Start: 'scan buttons
        if Recordbtn = 1 then
            high recordLED
            pause 250
            gosub RecordAudio
            low RecordLED
        endif
        
        if PlayBtn = 1 then
            high PlayLED
            pause 250
            gosub PlayBack
            low PlayLED
        endif
        goto Start
    
    '****************************************************************
    RecordAudio: ' Record message
        LOW SS 'Select isd4002 
        SHIFTOUT MOSI,SCLK,LSBFIRST,[CmdPwrUp\8]
        HIGH SS 'De-Select isd4002
        PAUSE 25
        
        LOW SS 
        SHIFTOUT MOSI,SCLK,LSBFIRST,[CmdPwrUp\8]
        HIGH SS 
        PAUSE 50     
    
        'There are 600 memory blocks in the 4002.  Each block is 200 mS long.
        'start recording at address 16 (= $10, %00010000)
        ' this is 3.2 seconds in (200 mS/address)  16*0.200 = 3.2 
        ISDAddress.lowbyte = $10
        ISDAddress.Highbyte = CmdsetRec '(= $A0, %10100000)
        'ISDAddress = $A010, %10100000 00010000
    
        LOW SS 
        SHIFTOUT MOSI,SCLK,LSBFIRST,[ISDAddress\16]
        HIGH SS 
    
    Wait4Stop:
        if StopBtn = 0 then goto Wait4Stop
        gosub StopOp 'Issue Stop Operation cmd 
        return
        
    '****************************************************************    
    PlayBack: ' Play Audio 
        LOW SS
        SHIFTOUT MOSI,SCLK,LSBFIRST,[CmdPwrUp\8]
        HIGH SS 
        PAUSE 25
         
        'start playback from address 16 (=$10)
        ISDAddress.lowbyte = $10
        ISDAddress.Highbyte = CmdsetPlay '(=$E0)
        
        LOW SS 
        SHIFTOUT MOSI,SCLK,LSBFIRST,[isdaddress\16] 'Start Playback
        HIGH SS 
        pause 25
    
    Wait4Done:
        if int = 1 and StopBtn = 0 then goto wait4done    
        gosub StopPwrDn
        return 
           
    '****************************************************************    
    StopPwrDn: ' Reset ISDInt and power down cmd 
        LOW SS 
        SHIFTOUT MOSI,SCLK,LSBFIRST,[CmdStopPwrDn\8]
        HIGH SS 
        pause 20
        return
         
    '****************************************************************    
    StopOp: ' Stop Operation 
        LOW SS 
        SHIFTOUT MOSI,SCLK,LSBFIRST,[CmdStop\8]
        HIGH SS
        pause 20
        return 
    
    '****************************************************************
    end

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. isd4002 problems help required please
    By Agent36 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2012, 06:57
  3. Bit/Byte array for Hserin/Hserout
    By mrx23 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st September 2006, 23:07
  4. RF Transmitter
    By et_Fong in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th October 2005, 16:34
  5. 18f452 internal eprom help
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 13th July 2004, 15:50

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts