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




Bookmarks