Go Down

Topic: Library for Nuvoton ISD1700 chipcorder family (Read 13 times) previous topic - next topic

neuron_upheaval

#5
Feb 21, 2009, 04:53 pm Last Edit: Feb 21, 2009, 05:07 pm by neuron_upheaval Reason: 1
Hello cincailo,

The example sketch above worked well!

The chipcorder and Arduino transfer data between each other through SPI.

You have to attach Arduino digital pins 13, 12, and 11 to the chipcorder pins SCK, MISO, and MOSI, respectively.

In addition, Arduino's and chipcorder's ground should be connected to a common point.

The chipcorder's SS pin is defined inside your sketch when instantiating the library, i.e.

Code: [Select]

#include <ISD1700.h>       // include library into the sketch

ISD1700 chip(10);    // Arduino's digital pin 10 is attached to chipcorder's SS pin

/* ... your own code follows below... */


This was made on purpose because you can control more than one device through SPI. For example, you could have two chipcorders being controlled by Arduino,

Code: [Select]

#include <ISD1700.h>

ISD1700 chipOne(10); // chip 1 has SS pin attached to Arduino digital pin 10
ISD1700 chipTwo(9);  // chip 2 has SS pin attached to Arduino digital pin 9

/* ... code goes on... */


There are many opcodes you can send to the chipcorder in order to let it perform some task. For example, to play the current pointed recording, you can send a PLAY opcode. Using the library above, you do this simply by including the following code into your sketch:

Code: [Select]

/* ... */

   chip.play();

/* ... */


Refer to the chipcorder's Design Guide (http://adsorcao.locaweb.com.br/ISD1700/Design_Guide.pdf) for an overview and to find a feature list.

cincailo

Hey, Thanks for your explanation. But how if i'm not using Arduino instead I use PIC from Microchip with C programming? Is there any problem? Which part should I edit? Your this library for ISD1700 family is function as to record multiple sound and randomly playback it when it is selected?


Thanks again.


From,

cincailo

neuron_upheaval

#7
Feb 22, 2009, 03:28 pm Last Edit: Feb 22, 2009, 05:15 pm by neuron_upheaval Reason: 1
Hi there cincailo,

I'm afraid I cannot be much of help porting the library code to the Microchip PIC platform, since there is a lot of Arduino language embedded into it.

However, I can help you a bit with the differences between platforms.

According to some references I've found hanging low on the internet, PIC's SSPCONx, SSPSTAT and SSPBUF registers correspond to ATmega's SPCR, SPSR and SPDR registers, respectively, which hold all bits that deal with the SPI communication.

This is what your SPI initialization code would look like:
Code: [Select]

/**
* void spi_init(void)
*
* Initializes SPI communication in a Microchip PICmicro
* This is a Hi-tech PICC compiler compliant code
*
* @author Marcelo Shiniti Uchimura
*/
void spi_init(void)
{
   SSPCON = 0x32;  /* set up SSP to clock data out on falling edge
                      whilst clock data in on rising edge, clock idle high */
   TRISC = 0x10;   /* RC4 and SDI (or MISO) are the same pin in Microchip PIC16F87x uC family */

   PORTC |= 0x04;  /* de-selecting chipcorder (RC2 is attached to chipcorder's SS pin) */
}

/**
* char spi_transfer(char)
*
* Send/get data to/from an SPI peripheral device
* This is a Hi-tech PICC compiler compliant code
*
* @author Marcelo Shiniti Uchimura
*/
char spi_transfer(char data)
{
   PORTC &= ~(0x04);    /* selecting chipcorder */
   SSPBUF = data;
   while(!(SSPSTAT & 0x01))
   {
       /* wait for transfer complete */
   }
   return SSPBUF;
}

cincailo

Hi,


Really thanks so much. Ya, I will look at it and try to figure it out the way to do it. Perhaps I can send a copy to you once I settle it. Hopefully...


Thanks again.


From,

cincailo

eforman

great library, thank you for contributing this.  

however, having some problems - with your example code, i'm getting Not_RDY for every command.  ID returns 0.  my wiring is:
Code: [Select]

/*
SCLK_PIN  13         to ISD1700 pin 6
MISO_PIN  12         to ISD1700 pin 4
MOSI_PIN  11         to ISD1700 pin 5
*/
ISD1700 chip(10); // to ISD1700 pin 7 - Initialize chipcorder with SS at Arduino's digital pin 10


i thought for a second i had switched MISO/MOSI, and when i do
Code: [Select]

/*
SCLK_PIN  13         to ISD1700 pin 6
MISO_PIN  12         to ISD1700 pin 5 [MOSI]
MOSI_PIN  11         to ISD1700 pin 4 [MISO]
*/

...i get CMD_ERR PU RDY for every command, and ID returns 11111111.  confused about that.

the ISD1700 plays/records in pushbutton mode, so i know it works.  

any ideas on what might be the problem?  

by the way, the only reason i'm using the SPI library is because Winbond/Nuvoton made the aggravating decision to route ANA-IN by default so you can't record from it.  or, i can, but it sounds terrible.  (i need to record from an 1/8" computer sound-out.)  am i correct that i need to use an SPI command to change routing?

from the datasheet it looks i need to change APC register to 0100 0000 1000, or 0x408 (record ANA-IN, with monitoring).  so in this library - once i get it working - is the following correct?
Code: [Select]

// change routing to record ANA-IN, with monitoring:
chip.wr_apc1(0x408); // but don't change volume
// or...
chip.wr_apc2(0x408); // set volume to max (000)


thanks in advance,

e

Go Up