ISD4003 & 16F877 Interface


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185

    Default ISD4003 & 16F877 Interface

    I have this code from melabs.

    Referring to this code, can someone please complete the schematic for the correct connection between these two chips, ISD4003 and F877?

    Code:
    ' PicBasic Pro 2.42 or later, LAB-XT Experimenter Board, PIC16F877-20
    
    
    ' 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 A key, speaking into
    ' a headset mic, then pressing the B key to stop recording.  The first
    ' message may be played back by pressing 0, the second by pressing 1, etc.
    
    ' EPIC Programmer should not be connected to the ICSP header
    ' when running this code.  It may interfere with the operation
    ' of the keypad.  
    
    
    DEFINE LOADER_USED	1				' Only required for melabs Loader
    DEFINE OSC 20						' Define for 20MHz crystal on LAB-XT
    
    
    ' Define LCD registers and bits
    DEFINE  LCD_DREG        PORTD
    DEFINE  LCD_DBIT        4
    DEFINE  LCD_RSREG       PORTE
    DEFINE  LCD_RSBIT       0
    DEFINE  LCD_EREG        PORTE
    DEFINE  LCD_EBIT        1
    
    
    select_voice	VAR	PORTD.2			' Chip select for voice recorder
    serial_mcu_out	VAR	PORTC.5			' SPI data output
    serial_clk		VAR	PORTC.3			' SPI clock pin
    voice_int		VAR	PORTA.5			' Interrupt signal from voice device
    
    
    ADCON1 = 7      ' Set PORTA and PORTE to digital
    Pause 200       ' Wait for LCD to start up
    LCDOut $fe,1	' Clear display
    
    ' Define program variables
    col     		VAR BYTE            ' Keypad column
    row     		VAR BYTE            ' Keypad row
    key     		VAR BYTE            ' Key value
    
    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
    High select_voice
    
    ' 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
    TRISC   = %00010100		' Set data-direction to allow SPI on PortC
    
    OPTION_REG.7 = 0        ' Enable PORTB pullups
    
    initialize:
    
    	LCDOut $fe, 1,  "A to record"	' Display intitial prompt
    	LCDOut $fe,$C0, "B to stop"		
    
    loop:
    
    
    	'IF (isd_on = 1) AND (voice_int = 0) Then GoSub finish
    
    	GoSub getkey			' Get a key from the keypad
    	Select Case key			' Take action based on key
    
    		Case 12				' "A" key starts recording
    			LCDOut $fe,1, "recording message: ",DEC i		' Display
    			LCDOut $fe,$c0, "address: ",HEX message_loc[i]	' Display	
    			address = message_loc[i]	' Set address to begin recording
    			GoSub record				' send record command to voice chip
    
    
    		Case 13				' "B" key stops recording
    			LCDOut $fe,1, "stop"		' Display		
    			GoSub finish	' Send stop command and receive end address
    			i = (i + 1) & $0F		' Increment message counter, loop 0 to 15
    			message_loc[i] = (isd_data_in >> 2) + 2	' Remove status bits from end address, add 2 for separation
    			
    
    		Case Is < 10		' Number keys play the corresponding message
    			LCDOut $fe,1, "playing message: ",DEC key			' Display
    			LCDOut $fe,$c0, "address: ", HEX message_loc[key]	' Display
    			address = message_loc[key]	' Set playback address
    			GoSub ply		' Send play command
    wait_for_int:
    			IF voice_int = 1 Then wait_for_int	' Loop here until end of message
    			GoSub finish	' Power down the voice chip
    			GoTo initialize	' Reinitialize the display
    			
    	End Select
    	
           
    GoTo loop               ' Do it forever
    
    
    
    ' Subroutine to get a key from keypad
    getkey:
    	' Check for keypress
    	For row = 0 TO 3        ' Loop for 4 rows in keypad
            PORTB = 0       	' All output pins low
            TRISB = ~(DCD row)  ' Set one row pin to output
            '@ NOP				' Fudge for 18F452
            col = PORTB >> 4	' Read column pins
    
            IF col != $0F Then	' Check if key is pressed
            	HPwm 1,127,7500	' Begin speaker tick
            	GoTo gotkey 	' If any keydown, exit loop and handle it.
            EndIF
    	Next row				' Repeat for the next row
    	
    	key = $FF				' No keys down, set key to $FF
    	Return          		' Return to main loop
    	
    gotkey: 					' Change row and column to key number 0 - 15
    	Pause 15                ' Debounce
    	HPwm 1,0,0				' End speaker tick
    	
    	' Wait for all keys up
    	PORTB = 0               ' All output pins low
    	TRISB = $F0             ' Least significant 4 pins out, top 4 pins in
    	IF ((PORTB >> 4) != $0F) Then gotkey	' If any keys down, loop
    	key = (row * 4) + (NCD (col^$0F)) - 1	' Combine row and column into numeric value
    	
    	
    	' Translate key to display label:
    	' 1  2  3  A
    	' 4  5  6  B
    	' 7  8  9  C
    	' *  0  #  D
    	'LookUp key,["123A456B789C*0#D"],disp_key
    	
    	' Translate key to DTMFOUT tone
    	' 1   2   3   12
    	' 4   5   6   13
    	' 7   8   9   14
    	' 10  0   11  15
    	LookUp key,[1,2,3,12,4,5,6,13,7,8,9,14,10,0,11,15],key
    	
    Return			' Return to main loop
    
    
    
    ' 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


    ----------------------------------------
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1288&stc=1&d=116706621 8 " >
    Attached Images Attached Images  
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Talking

    Hi, Sayzer

    Seems once more Santa has forgotten your boots ...

    http://www.melabs.com/downloads/LABXTSCH.PDF

    just read the scheme !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Thanks Alain.

    My problem is with RAC, INT and SS pins of the voice chip.

    Where do they go on PIC? (with this code).

    P.S. - I don't believe in Santa. He fooled me once when I was 3.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Talking Santa's present ... a pair of Glasses !!!

    Hi, Sayzer

    May be you've noticed there are 2 Sheets in the LabXT Scheme ...

    The 877 is on the first one and the 4003 on the second one.

    All pins are clearly labelled ( Voice int and Select voice ...RAC is left floating )

    A personnal note : If you don't believe in Santa ... no real use to believe in God, Allah, Buddah ... or anyone else ...
    'cause you do not believe in LIFE ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    I did not notice that Alain.

    I must be in a different world when I wake up.

    Now, the schematic has become as this one so far.

    I now need to figure out the code for ISD4004 instead of ISD4003.

    Thanks Alain.


    P.S.- Life should not be as easy as reducing it to a symbol or icon or a concept like Santa. I believe in Allah (the only God in my understanding) and I am a religious person living my life accordingly. I am a happy person!
    Come on Alain, you know much better then I do!
    BTW: Santa was born in Turkey, remember?

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1290&stc=1&d=116714793 4">
    Attached Images Attached Images  
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink No matter his name ...

    Hi,Sayzer

    yes, Santa is a symbol ... but so many things included behind this symbol !!!

    No matter how you call "God", no matter how and when you practise your religion, no matter where Santa was born ...

    the only things that matters is they are here !!!

    Back to ISD Chips ... I did not know about the use of ISD 4k series ( I have an old '1016 Home to play with ... but that's all !!! )

    soooo ... a moment please !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. LCDOUT w/custom interface?
    By Mike, K8LH in forum PBP Extensions
    Replies: 4
    Last Post: - 3rd March 2015, 03:54
  2. Replies: 33
    Last Post: - 19th March 2010, 03:02
  3. 16f877 and ps/2 keyboard error???
    By boraciner in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th July 2009, 08:14
  4. 'SCI' interface
    By ecua64 in forum Off Topic
    Replies: 0
    Last Post: - 29th September 2005, 16:02
  5. User Configuration Interface in PBP
    By Radiance in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th February 2004, 08:00

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