Voice Playback CHIP SD20


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Jul 2006
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Hello Darrel

    Have you a code example how to do that with the For / Loop
    For beginners it helps a lot

    Regards
    Pedro

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Sure, maybe something like this...
    Code:
    @ DEVICE XT_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
    
    DEFINE LOADER_USED 1
    
    ' ** Setup the Resonator Frequency, in Mhz **
    Define OSC 4 
    
    Baud con 84 ' 9600 baud rate
    
    ' ** Port configurations **
    TX    VAR PORTB.5
    RX    VAR PORTB.2
    CLK   VAR PORTA.4
    DI    Var PORTA.0
    RESET VAR PORTB.6
    PIEZO VAR PORTB.7
    
    DAT VAR WORD
    Idx VAR BYTE
    
    ;---------------------------------------------------------------------------
    Init:
      ANSEL = 0 'Configure all pins to digital operation since not using ADC
      CMCON = 7 ' disable comparators
    
    begin:
      low piezo
    
      dat = $FFF7 
      serout2 tx,baud,["1st Data = ",bin16 dat,13,10]
      GOSUB SendDat
    
      dat = $3
      serout2 tx,baud,["2nd Data = ",bin16 dat,13,10] 
      GOSUB SendDat
    
      dat = $fffe
      serout2 tx,baud,["3rd Data = ",bin16 dat,13,10]
      GOSUB SendDat
    
    STOP
    
    ;---------------------------------------------------------------------------
    SendDAT:
      LOW RESET                    ; 5ms reset pulse
      PAUSE 5
      INPUT RESET
      PAUSE 300                    ; 300ms before data
    
      For Idx = 15 to 0 STEP -1    ; loop thru the bits
        LOW CLK                    ;   set CLK LOW
        IF dat.0(Idx) THEN         
          INPUT DI                 ;   if bit = 1 then INPUT, not HIGH
        ELSE
          LOW DI                   ;   if bit = 0 then LOW
        ENDIF
        PAUSE 1                    ;   data settle time
        INPUT CLK                  ;   clks data on rising edge
        PAUSE 1                    ;   data read time
      NEXT Idx                     ; do rest of the bits
      INPUT DI                     ; leave data line tri-stated
    RETURN
    DT

  3. #3
    Join Date
    Jul 2006
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Hello Darrel
    Thank you for the sample

    Can you explain this?
    For Idx = 15 to 0 STEP -1 ; loop thru the bits

    is this correct?
    IF dat.0(Idx) THEN

    why not
    IF dat(Idx) THEN

    dat is a word variavel, so if
    in the loop at the moment
    idx is say 1 then it's the same like
    dat.1, that is the second bit of the word, or not

    NEXT Idx

    Thanks and best regards
    Pedro
    Last edited by Pedro Santos; - 27th December 2008 at 00:04.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pedro Santos View Post
    Can you explain this? ...
    IF dat.0(Idx) THEN ...
    I can.

    But since Melanie's already covered the subject, I'll let her.

    Bits, Bytes Words and Arrays
    http://www.picbasic.co.uk/forum/showthread.php?t=544
    <br>
    DT

  5. #5
    Join Date
    Jul 2006
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Thanks again Darrel

    Regards

    Pedro

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    You're Welcome Pedro,

    Hope you (and everyone else) had a Happy "Boxing Day"!
    <br>
    DT

  7. #7
    Join Date
    Dec 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Thumbs up SD20 Voice Chip

    Hi Darrel

    Thanks for help of this. I finally got it working, the engineer from the manufacturer found a small bug in their chip firmware. So anyone interested in using this chip should increase the reset time and increase the time for playback also.


    See the amended code here :

    @ DEVICE XT_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF

    DEFINE LOADER_USED 1

    ' ** Setup the Resonator Frequency, in Mhz **
    Define OSC 4

    Baud con 84 ' 9600 baud rate

    ' ** Port configurations **
    TX VAR PORTB.5
    RX VAR PORTB.2
    CLK VAR PORTA.4
    DI Var PORTA.0
    RESET VAR PORTB.6
    PIEZO VAR PORTB.7

    DAT VAR WORD
    Idx VAR BYTE

    counter var byte
    volume var word

    volume = 65527

    '---------------------------------------------------------------------------

    Init:
    ANSEL = 0 'Configure all pins to digital operation since not using ADC
    CMCON = 7 ' disable comparators

    begin:
    low piezo

    dat = $FFF7
    serout2 tx,baud,["Voice Volume - 1st Data = ",bin16 dat,13,10]
    GOSUB SendDat

    dat = $4
    ' set counter to file no. 4
    counter = 4
    serout2 tx,baud,["Address 4 of voice file - 2nd Data = ",bin16 dat,13,10]
    GOSUB SendDat

    playaddr:
    dat = $fffe
    serout2 tx,baud,["Play/Pause - 3rd Data = ",bin16 dat,13,10]
    ' GOSUB SendDat
    GOSUB Playdata

    ' --------------------------------------------------------------------------
    switch:

    'if porta.2=0 then
    ' counter = counter - 1
    ' if counter<=1 then counter = 2
    ' dat = counter
    '
    ' serout2 tx,baud,["Address of voice file - 2nd Data = ",bin16 dat,13,10]
    ' GOSUB SendDat
    ' goto playaddr
    'endif

    if porta.1=0 then
    counter = counter + 1
    if counter>=7 then counter = 6
    dat = counter

    serout2 tx,baud,["Address of voice file - 2nd Data = ",bin16 dat,13,10]
    GOSUB SendDat
    goto playaddr
    endif

    ' Reduce Volume
    if porta.2=0 then
    volume = volume - 1
    if volume<=65520 then volume = 65527
    dat = volume

    serout2 tx,baud,["Address of voice volume = ",bin16 dat,13,10]
    GOSUB SendDat
    'goto playaddr
    endif

    goto switch

    STOP

    '---------------------------------------------------------------------------

    SendDAT:
    LOW RESET ; 5ms reset pulse
    PAUSE 5
    INPUT RESET
    PAUSE 300 ; 300ms before data

    For Idx = 15 to 0 STEP -1 ; loop thru the bits
    LOW CLK ; set CLK LOW
    IF dat.0(Idx) THEN
    INPUT DI ; if bit = 1 then INPUT, not HIGH
    ELSE
    LOW DI ; if bit = 0 then LOW
    ENDIF
    PAUSE 1 ; data settle time
    INPUT CLK ; clks data on rising edge
    PAUSE 1 ; data read time
    NEXT Idx ; do rest of the bits
    INPUT DI ; leave data line tri-stated
    RETURN


    ' --------------------------------------------------------------------------

    Playdata:

    LOW RESET ; 5ms reset pulse
    PAUSE 5
    INPUT RESET
    PAUSE 1250 ; 300ms before data


    For Idx = 15 to 0 STEP -1 ; loop thru the bits
    LOW CLK ; set CLK LOW
    IF dat.0(Idx) THEN
    INPUT DI ; if bit = 1 then INPUT, not HIGH
    ELSE
    LOW DI ; if bit = 0 then LOW
    ENDIF
    PAUSE 1 ; data settle time
    INPUT CLK ; clks data on rising edge
    PAUSE 1 ; data read time
    NEXT Idx ; do rest of the bits
    INPUT DI ; leave data line tri-stated
    RETURN

    ' --------------------------------------------------------------------------

    All the best; Happy NEW Year !!!

Similar Threads

  1. isd4002 problems help required please
    By Agent36 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2012, 07:57
  2. Trouble with PIC16F88 (chip hangs up)
    By nobner in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th January 2009, 10:23
  3. TV Display Chip
    By zadok in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 17th April 2008, 23:17
  4. ISD4003 & 16F877 Interface
    By sayzer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th December 2006, 18:50
  5. chip selection aid
    By PICMAN in forum General
    Replies: 4
    Last Post: - 21st February 2005, 19:33

Members who have read this thread : 0

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