isd4002 problems help required please


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2005
    Location
    Cambridge UK
    Posts
    45

    Default isd4002 problems help required please

    Hi,
    I have down loaded and modified the following code from MELABS samples so I can understand the coding.
    I have changed the code so that I have three push buttons record, finish and play. The binary switch on porta selects the address to start playing the message . The problem is I can only play from address zero, if some one would be kind enough to check the code and point me in the right direction it would be a great help. I have spent four weeks on this with out progression.
    Here is the code in full.




    ' Program to record and play multiple voice messages.
    ' Uses hardware SPI for 2-way communication to the voice device.
    ' Record messages in sequence by pressing the REC button.
    ' Then pressing the FINISH button to stop recording. The messages
    ' may be played back by selecting the address on the deciaml to binary
    ' switch and pressing the PLAY button.


    @ DEVICE PIC16F819, INTRC_OSC_NOCLKOUT
    ' System Clock Options (Internal)
    @ DEVICE PIC16F819, WDT_ON
    ' Watchdog Timer
    @ DEVICE PIC16F819, PWRT_ON
    ' Power-On Timer
    @ DEVICE PIC16F819, MCLR_OFF
    ' Master Clear Options (Internal)
    @ DEVICE PIC16F819, BOD_OFF
    ' Brown-Out Detect
    @ DEVICE PIC16F819, CPD_OFF
    ' Data Memory Code Protect
    @ DEVICE PIC16F819, PROTECT_OFF





    DEFINE OSC 8 ' Define for 8MHz crystal internal

    OSCCON = $70 'set the clock to 8 Mhz, 60 for 4MHz


    select_voice VAR PORTB.3 ' Chip select for voice recorder
    serial_mcu_out VAR PORTB.2 ' SPI data output
    serial_clk VAR PORTB.4 ' SPI clock pin
    voice_int VAR PORTB.5 ' Interrupt signal from voice device


    ADCON1 = 7 ' Set PORTA and PORTB to digital


    ' Define program variables


    control VAR BYTE
    address VAR WORD
    isd_data_in VAR WORD
    isd_data_out VAR WORD
    message_loc VAR WORD[16]
    i VAR BYTE

    i = 0
    message_loc[0]=0


    ' set up SPI port
    BF VAR SSPSTAT.0 ' Alias Buffer Full flag
    SSPSTAT = %01000000 ' Set SMP=0, CKE=1
    SSPCON = %00100010 ' Set CKP=0, SPI master, clock = Fosc/64, Enable the port
    TRISB = %11100011 ' Set data-direction to allow SPI on PortB

    High select_voice

    'portb.0 is Play
    'portb.1 is MCU IN (SDI)
    'portb.2 is MCU OUT (SDO)
    'portb.3 is Select voice
    'portb.4 is Serial clock (SCK)
    'portb.5 is Voice int (SS)
    'portb.6 is Record start
    'portb.7 is Record Finish

    TRISA = %00001111 'Bits 0-3 address select





    Pause 1000 ' allows power to settle


    loop:
    IF PORTB.6 = 0 Then
    address = message_loc[i] 'Sets address to begin recording
    GoSub record
    EndIF

    IF PORTB.7 = 0 Then
    GoSub finish
    i = (i+1) & $0F
    message_loc[i] = (isd_data_in >> 2) + 2 ' remove status bit
    EndIF

    IF PORTB.0 = 0 Then
    Pause 500 'allow key to release
    i = PORTA ' number selected plays corresponding message
    i = i+$0F
    address = message_loc[i] 'sets playback address
    GoSub ply
    EndIF

    wait_for_int:

    IF voice_int = 1 Then
    GoTo wait_for_int 'loop here till finished
    GoSub finish 'power down chip
    EndIF




    GoTo loop ' Do it forever









    ' ISD4003 Control Values:
    power_up CON %00100000 ' Power up the device
    set_play CON %11100000 ' Set the playback address
    play CON %11110000 ' Start playback
    set_rec CON %10100000 ' Set the record address
    rec CON %10110000 ' Start recording
    power_dwn CON %00010000 ' Stop playback or record and power down the device


    record: 'Record a message
    control = power_up ' Set control byte to power up
    GoSub spi_send ' Send to device

    Pause 100 ' Pause to let the device come up

    control = set_rec ' Set control byte to set record address
    GoSub spi_send ' Send to device
    Return ' Return to main loop


    ply:
    control = power_up ' Set control byte to power up
    GoSub spi_send ' Send to device

    Pause 50 ' Pause to let the device come up

    control = set_play ' Set control byte to set play address
    GoSub spi_send ' Send to device
    Return

    finish:
    control = power_dwn ' Set control byte to power down
    GoSub spi_send ' Send to device
    Return ' Return to main loop


    spi_send: ' Use hardware SPI port to send and receive simultaneously


    Low select_voice ' Select voice chip

    address.highbyte = (address.highbyte & %00000111) | control ' Combine address and control data
    isd_data_out = address REV 16 ' Reverse the bits for LSB first

    SSPBUF = isd_data_out.highbyte ' Write the first byte to SSPBUF to initiate trasfer

    GoSub spi_wait ' Wait for transfer to finish

    isd_data_in.highbyte = SSPBUF ' Read the incoming data from SSPBUF

    SSPBUF = isd_data_out.lowbyte ' Write the second byte to SSPBUF to initiate transfer

    GoSub spi_wait ' Wait for transfer to finish

    isd_data_in.lowbyte = SSPBUF ' Read the incoming data from SSPBUF

    isd_data_in = isd_data_in REV 16 ' Reverse the bits of incoming data (received LSB first)

    High select_voice ' Deselect voice chip

    Return


    spi_wait: ' Wait for transfer to finish
    IF BF = 0 Then spi_wait ' If the flag is still zero, keep waiting
    BF = 0 ' Reset the flag
    Return


    End


    Thanks for your help and time

    Kind regards

    Nick

  2. #2
    Join Date
    Dec 2004
    Location
    USA
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    Hi Nick,

    I used the SETPLAY command (%11100000) instead of PLAY (%11110000). It went something like this:

    CmdPlay VAR WORD
    CmdPwrUp CON %0010000

    SHIFTOUT MOSI, SCLK, 0, [CmdPwrUp\8]
    HIGH SS
    PAUSE 20
    LOW SS

    CmdPlay = %111000010001011 'SETPLAY + address
    SHIFTOUT MOSI, SCLK, 0, [CmdPlay\16]
    HIGH SS

    Klaus

  3. #3
    Join Date
    Nov 2005
    Location
    Cambridge UK
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    Hi Klaus,

    Thanks for the code example, I have checked the code and I am using set_play (11100000). The problem I have is reading in the play address using 4 bits on porta and then looking it up in the array. I have included the full code in notepad if you want to look at it. I dont think my 1st post was very clear.

    I am going to keep your code sample and play with it once I get this working

    thanks again
    Nick
    Attached Files Attached Files

  4. #4
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Can you share the Code !

    Hi Nick,

    Can you share the code once done. I have a similar chip APR6016 to play with.

    Thanks for the start code.

    regards

  5. #5
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Nick,

    I haven't used a PIC in this manner but I think the line:
    "TRISA = %00001111 'Bits 0-3 address select"
    is wrong. TRISA sets the data direction for PortA.

    Now if you had "TRISA = %00000000" then all of the lines of PortA are set as outputs. The next line should then be "PortA = %00001111".

    This would then turn PortA 0 - 3 on and 4 - 7 off.

    BobK

    Sorry, I didn't look at the date of the original post!

  6. #6
    Join Date
    Nov 2005
    Location
    Cambridge UK
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    Hi BobK,

    PortA bits 0-3 are for a binary switch; they set the play address for the isd4002.

    charudatt,
    I have worked out all the problems myself, now it stores the address to eeprom and can be selected via the binary switch using a lookup table. Is this what you are after? Contact me via email in my personal info and I will send you the completed code.

    Regards
    Nick

  7. #7
    Join Date
    Nov 2005
    Location
    Cambridge UK
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    Hi BobK,

    PortA bits 0-3 are for a binary switch; they set the play address for the isd4002.

    charudatt,
    I have worked out all the problems myself, now it stores the address to eeprom and can be selected via the binary switch using a lookup table. Is this what you are after? Contact me via email in my personal info and I will send you the completed code.

    Regards
    Nick

  8. #8
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Sent A Pm!

    Hi Nick,

    Sent You A Pm Some Days Back. Don't Know If You Got It.

    Regards
    Charudatt

  9. #9
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Fyi - Apr6016 Design

    JUST IN CASE IF SOME ONE WAS INTERESTED, I HAVE A SIMILAR PROJECT USING APR6016 IC.

    THIS CONNECTS TO A DEVELOPMENT BOARD FOR CONTROL.

    APR6016 IS MANUFACTURED BY APLUS AND THE DATASHEET CAN BE FOUND AT http://www.aplusinc.com.tw/data/reco...et/apr6016.zip

    REGARDS
    Attached Images Attached Images

  10. #10
    sathyakiruba's Avatar
    sathyakiruba Guest


    Did you find this post helpful? Yes | No

    Default Re: Fyi - Apr6016 Design

    dear sir,

    i need apr 6016 code for pic 16f877a

Similar Threads

  1. Problems with U2 programmer C30 compiled code
    By minimii in forum Off Topic
    Replies: 0
    Last Post: - 5th November 2009, 10:43
  2. 2.60 + MCSP problems
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 27th September 2009, 16:42
  3. ISD4002 Address Question
    By Atom058 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th August 2009, 00:42
  4. Input problems
    By ALFRED in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd July 2006, 22:02
  5. Problems with 16F876 on interrupts an WRITE / READ
    By BigWumpus in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th December 2005, 15:38

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