AIUTO !! voice recorder ISD40XX

Sezione dedicata al sistema di sviluppo BASCOM-AVR per i micro AVR
At90s, Attiny, Atmega e Xmega

AIUTO !! voice recorder ISD40XX

Postby flipper » 07 Mar 2013, 14:13

Buongiorno a tutti,

Qualcuno ha mai usato il registratore di suoni e voce della serie ISD40XX?

http://www.nuvoton.com/hq/enu/ProductAn ... SD4004.pdf

Dovrei interfacciarlo con un micro AVR qualsiasi, attraverso la SPI.

C'è qualcuno così gentile da indicarmi come configurare la SPI Hardware, visto che la configurazione prevede una marea di opzioni?

Buone cose a tutti.
flipper
 
Posts: 20
Joined: 02 Sep 2012, 19:38

Re: AIUTO !! voice recorder ISD40XX

Postby Fagos » 07 Mar 2013, 20:33

flipper, ma perchè proprio questa soluzione?
a me sembra un pò antiquata. o no
ciao
User avatar
Fagos
 
Posts: 100
Joined: 31 Aug 2011, 15:01

Re: AIUTO !! voice recorder ISD40XX

Postby flipper » 09 Mar 2013, 13:17

ciao ragazzi
in questo sito
http://read.pudn.com/downloads180/sourc ... .bas__.htm

ho trovato questo codice scritto in bascom adatto a controllare il chip isd4004.
Code: Select all
$regfile = "m32def.dat"
$crystal = 1000000
Config Pinb.0 = Output
Led_read Alias Portb.0

Config Pinb.1 = Output
D7 Alias Portb.1
 
 Config Pind.0 = Input
S1 Alias Pind.0
 
Ddrd.1 = 0 : Portd.1 = 1
 
S2 Alias Pind.1
'------------------------------------------------------------------------------- 
 Config Pinb.4 = Input
 Config Pinb.2 = Output
 Config Pinb.3 = Output
 Config Pinb.5 = Output
 
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 64 , Noss = 0
 
 Spiinit
 Enable Interrupts
 Enable Spi
'-------------------------------------------------------------------------------
Dim Lsb As Byte
Dim Msb As Byte
 
Dim Setplay As Byte
Dim Play As Byte
Dim _stop As Byte
Dim Setrec As Byte
Dim Rec As Byte
Dim Powerup As Byte
Dim Setmc As Byte
Dim Mc As Byte
Dim Stoppwrdn As Byte
Dim Rint As Byte
 
  Powerup = &B00100000
  Setplay = &B00000111
     Play = &B00001111
   Setrec = &B00000101
      Rec = &B00001101
    Setmc = &B00010111
       Mc = &B00011111
    _stop = &B00001100
Stoppwrdn = &B00001000
     Rint = &B00011000
 
 '------------------------------------------------------------------------------
 Config Debounce = 30
 
 D7 = 1
 Led_read = 1
 Wait 2
 D7 = 0
 Led_read = 0
 Wait 1
'-------------------------------------------------------------------------------
Chek_pin:
Do
 
If S1 = 1 Then
Goto Khandan
Else
Goto Neveshtan
End If
 
Loop

'-------------------------------------------------------------------------------
Khandan:
Spiout _stop , 1
Led_read = 1
D7 = 0
Do
 
If S1 = 0 Then Goto Neveshtan
Debounce S2 , 1 , Play_music , Sub
 
Loop
'===============================================================================
Play_music:
D7 = 1
 
Lsb = 200
Msb = 0
 
Spiout Powerup , 1
Waitms 35
 
Spiout Lsb , 1
Spiout Msb , 1
Spiout Setplay , 1
 
Spiout Play , 1
Waitms 30
Do
Debounce S2 , 1 , Stop_play_music
Loop
Stop_play_music:
D7 = 0
Spiout _stop , 1
Waitms 50
Wait 1
 
Return

'-------------------------------------------------------------------------------
Neveshtan:
Spiout _stop , 1
Led_read = 0
D7 = 0
Do
If S1 = 1 Then Goto Khandan
Debounce S2 , 1 , Record_music , Sub
Loop
'-------------------------------------------------------------------------------
Record_music:
D7 = 1
 
Lsb = 200
Msb = 0
 
Spiout Powerup , 1
Waitms 35
Spiout Powerup , 1
 Waitms 65
 
 Spiout Lsb , 1
 Spiout Msb , 1
Spiout Setrec , 1
 
Spiout Rec , 1
Waitms 30
Do
 Debounce S2 , 1 , Stop_record_music
Loop
Stop_record_music:
D7 = 0
Spiout _stop , 1
Waitms 50
Wait 1
 
Return


con qualche aggiustamento sono riuscito a farlo funzionare, ma a me serve registrare vari messaggi e non solo uno.
questo codice va bene per uno solo e posso solo registrare e riprodurre.

come dovrei fare, magari usando il programma che ho mostrato, per registrare messaggi multipli?
vi ringrazio
flipper
 
Posts: 20
Joined: 02 Sep 2012, 19:38

Re: AIUTO !! voice recorder ISD40XX

Postby deluca » 25 Mar 2013, 09:21

Salve flipper,
tra i miei sorgenti bascom mi sono ricordato di un codice che avevo scritto qualche anno fa che potrebbe essere di tuo interesse.
Il firmware è sviluppato x atmega8515 ma facendo qualche piccola modifica potresti utilizzarlo anche per versioni avr più recenti.
C'è una parte scritta in assembly per la gestione della interfaccia seriale in modalità software,
poichè nelle versioni di Bascom precedenti (1.11.9.3) la gestione della SPI-HW dava qualche problema e non risultava essere compatibile
al 100% con gli ISD.
Code: Select all
'*******************************************************************************
'  PROGRAMMA PER REGISTRARE MESSAGGI SU ISD4004-08 MINUTI 2400 ROW
'  REALIZZATO DA GIOVANNI DE LUCA  15-12-2008, (aggionato x forum: 22-13-2013)
'  VERSIONE BASCOM_AVR 1.11.9.3,                         
'*******************************************************************************

'  - DECREMENT ADDRESS
'  + INCREMENTA ADDRESS
' ST STOP
' RC RECORD
' PL PLAY
' S:ADDR = INDIRIZZO START MESSAGGIO
' E:ADDR = indirizzo fine messaggio

'utilizza scheda prototipo "REC ISD4004"
'$prog &HFF , &HFF , &HD9 , &H00
$regfile = "m8515.dat"
$crystal = 11059200

Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Porta.0 , Db5 = Porta.1 , Db6 = Porta.2 , _
                 Db7 = Porta.3 , E = Porta.5 , Rs = Porta.4
Cursor Off
Cls
Locate 1 , 1 : Lcd "Rec ISD4004"
Locate 2 , 1 : Lcd "by G.De Luca"

  Pin_ss Alias Portb.0
Pin_mosi Alias Portb.1
Pin_sclk Alias Portb.2
 Pin_rac Alias Pinb.3
Pin_test Alias Portb.4

Pul_down Alias Pind.0
  Pul_up Alias Pind.1
Pul_stop Alias Pind.4
 Pul_rec Alias Pind.5
Pul_play Alias Pind.6

Config Pinb.0 = Output : Portb.0 = 1                        'pin_ss=1
Config Pinb.1 = Output
Config Pinb.2 = Output
Config Pinb.3 = Input
Config Pinb.4 = Output
'                         pull up resistor port_d
Config Pind.0 = Input : Portd.0 = 1                         'pulsante down
Config Pind.1 = Input : Portd.1 = 1                         'pulsante up
Config Pind.4 = Input : Portd.4 = 1                         'pulsante stop
Config Pind.5 = Input : Portd.5 = 1                         'pulsante record
Config Pind.6 = Input : Portd.6 = 1                         'pulsante play

Declare Sub Power_up
Declare Sub Stop_operation
Declare Sub Set_record
Declare Sub Record
Declare Sub Set_play
Declare Sub Playing

  Const Isd_powerup = &B00100000
  Const Isd_setplay = &B11100000
     Const Isd_play = &B11110000
   Const Isd_setrec = &B10100000
      Const Isd_rec = &B10110000
    Const Isd_setmc = &B11101000
       Const Isd_mc = &B11111000
     Const Isd_stop = &B00110000
Const Isd_stoppwrdn = &B00010000
     Const Isd_rint = &B00110000

Dim Addr_end As Word
Dim Addr_act As Word
Dim Addr As Word
Dim X As Byte
Dim Cmd(5) As Byte
Dim Cm As Byte
Dim Var As Long
Dim S As String * 5
Dim Tempo_puls As Byte

Gosub _sini

'-- esegui power_up 2 volte --
Power_up
   Waitms 100
Power_up
   Waitms 100

'ADDR=0         0
'1400 / 200 + ADDR - 1 = 6  sull'analizzatore vedro' 00-0110.0000-0000.0000
'-------------------------------------------------------------------------------
'ADDR=2
'     7    +    2  - 1 = 8  ADDRESS OCCUPATO
'se registro un messaggio della durata di 1400 msec a partire da addr=0
'avro' occupato gli indirizzi da 0 a 6
'-------------------------------------------------------------------------------

'2400 * 200 = 480.000 mSec = 480 Sec / 60 = 8 Minuti
'ADDR MAX=2400 ULTIMA ROW
'UN SECONDO EQUIVALE A 5 ROW ; 1 ROW =200mSEC
'CON ADDR=2394 E TEMPO DI REC = 1 SEC SI VA IN OVERFLOW

Wait 1
Cls
Locate 1 , 1 : Lcd "S:    E:    "
Locate 2 , 1 : Lcd "- + St Rc Pl"

Addr = 0
Addr_end = 0
Addr_act = 0
Tempo_puls = 200

Config Int0 = Falling
Config Int1 = Falling

Enable Interrupts
Enable Int0
Disable Int1
On Int0 Int_0
On Int1 Int_rac
'-------------------------------[ Main ]----------------------------------------
Locate 1 , 3 : Lcd Addr
Locate 1 , 9 : Lcd Addr_end
'===============================================================================
Do
  If Pul_down = 0 Then
     If Tempo_puls < 100 Then Tempo_puls = 50
         Tempo_puls = Tempo_puls - 10
         Waitms Tempo_puls
         Decr Addr
         If Addr = 65535 Then Addr = 0
         Locate 1 , 3 : Lcd Addr ; " "

  Elseif Pul_up = 0 Then
     If Tempo_puls < 100 Then Tempo_puls = 50
         Tempo_puls = Tempo_puls - 10
         Waitms Tempo_puls
         Incr Addr
         If Addr > 2400 Then Addr = 0
         Locate 1 , 3 : Lcd Addr ; " "

  Elseif Pul_rec = 0 Then
         Locate 1 , 9 : Lcd "    "
         Enable Int1
         Stop_operation
         Waitms 50
         Set_record
         Record
         Addr_act = 0

  Elseif Pul_stop = 0 Then
         Disable Int1
         Stop_operation
         Waitms 50
         Addr_act = 0

  Elseif Pul_play = 0 Then
         Locate 1 , 9 : Lcd "    "
         Enable Int1
         Stop_operation
         Waitms 50
         Set_play
         Playing
         Addr_act = 0
  Else
         Tempo_puls = 200
  End If

Loop
'===============================================================================
End
'---------------------------------[ Stop ]--------------------------------------
Int_0:
   Waitms 1
   Stop_operation
Return
'--------------------------[ Conta gli indirizzi ]------------------------------
Int_rac:
      Waitms 1
      Incr Addr_act
      Addr_end = Addr + Addr_act
      Locate 1 , 9 : Lcd Addr_end ; " "
Return
End
'------------------------[ Setta addr Recording msg ]---------------------------
Sub Set_record
      Cmd(3) = Isd_setrec
      Cmd(2) = High(addr)
      Cmd(1) = Low(addr)
      cbi portb,0
      For X = 1 To 3
          Cm = Cmd(x)
          Gosub _sout1
      Next X
      sbi portb,0
End Sub
'----------------------------[ Recording msg ]----------------------------------
Sub Record
      Cm = Isd_rec
      cbi portb,0
      Gosub _sout1
      sbi portb,0
End Sub
'------------------------[ Setta addr Playing msg ]-----------------------------
Sub Set_play
  Cmd(3) = Isd_setplay
  Cmd(2) = High(addr)
  Cmd(1) = Low(addr)
      cbi portb,0
      For X = 1 To 3
           Cm = Cmd(x)
           Gosub _sout1
      Next X
      sbi portb,0
End Sub
'-----------------------------[ Playing msg ]-----------------------------------
Sub Playing
      Cm = Isd_play
      cbi portb,0
      Gosub _sout1
      sbi portb,0
End Sub
'----------------------------[ Stop operation ]---------------------------------
Sub Stop_operation
      Cmd(3) = Isd_stop
      Cmd(2) = 0
      Cmd(1) = 0
      cbi portb,0
      For X = 1 To 3
           Cm = Cmd(x)
           Gosub _sout1
      Next X
      sbi portb,0
End Sub
'------------------------------[ Power up ]-------------------------------------
Sub Power_up
      Cm = Isd_powerup
      cbi portb,0
       Gosub _sout1
      sbi portb,0
End Sub
'------------------------[ Codice assembly gestione SPI SW ]--------------------
$asm
_sini:
    Sbi ddrb , 1
    cbi portb,1
    sbi ddrb,2
    cbi portb,2
    ret

_sout1:
    push r24
    push zl
    lds zl,{cm}                                             'load dalla mem che
                                                            'contiene il valore di (cm) in zl
_sout:
    ldi r24,8
_so2:
    ror zl                                                  'ruota a destra
    brcc _so1
    sbi portb,1                                             'set data
    rjmp _so3
_so1:
    cbi portb,1                                             'clear data
_so3:
    sbi portb,2                                             'set clock
     nop
     nop
     nop
     nop
    cbi portb,2                                             'clear clock

    dec r24
    brne  _so2
    cbi portb,1                                             'clear data

    pop zl
    pop r24
    ret
$end Asm
'-- dopo il fronte di discesa del clock leggi il MISO
'-- se a uno setta il bit del registro
'-------------------------------------------------------------------------------
Ciao
Il mio sito: http://www.delucagiovanni.com ......e la chat: chat/
User avatar
deluca
Site Admin
 
Posts: 1104
Joined: 19 Jun 2011, 10:44
Location: 95123 - Catania (Italy)

Re: AIUTO !! voice recorder ISD40XX

Postby flipper » 28 Mar 2013, 15:26

deluca non ho parole, :) funziona !!!!! il tuo codice funziona perfettamente.
posso adesso decidere dove voglio registrare il messaggio così da averne disponibili svariati fino ad un complessivo di molti minuti.
mi è bastato cambiare il micro e aggiustare la pinnatura e tutto ha funzionato alla grande. sei un mito, grazie tante ;)

spero un giorno di poter ricambiare l'aiuto :D

ti faccio gli auguri di Pasqua
a presto, ciao
flipper
 
Posts: 20
Joined: 02 Sep 2012, 19:38


Return to BASCOM-AVR

Who is online

Users browsing this forum: No registered users and 9 guests