View previous topic :: View next topic |
Author |
Message |
huytle1
Joined: 11 Apr 2008 Posts: 2
|
HELP WITH PIC16F887 AND ISD1700 SPI PLEASE!! |
Posted: Mon Apr 14, 2008 12:29 pm |
|
|
I am new to CCS and have looked through all the posts on SPI communication with the ISD4003 chip. All that information has helped me a great deal. However, I am trying to communicate with the ISD1700 and have no luck.
I am currently connecting the voice chip to a microchip serial analyzer and reading the spi ports with a logic analyzer. The pic serial analyzer is set up as the master and the voice a slave. I am putting in commands to see if the voice chip will communicate properly but get nothing!! I am following the datasheet by selecting CS low during data transfer and sending data but the chip doesn't record when I tell it to record.
If any one can help me or point me in the right direction of communicating through SPI that would be much appreciated. It is also my first time using SPI so I am pretty lost. hahaha.
If anyone can provide a step through of how to they connected there SPI and tested it that would be awesome. Thanks!
Current connection setup:
CS to CS
MISO to MOSI
MOSI to MISO
CLK to CLK |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 14, 2008 2:40 pm |
|
|
Have you looked at the isd1700 design guide ? Here is the link:
http://www.atvoc.com/bbs/UploadFile/2007-7/20077259194287954.pdf
Based on the timing diagrams of the SPI interface on page 34, I would
say it uses SPI Mode 0. It's a little ambiguous, but Mode 0 is the best bet.
On page 71, it shows the maximum SCLK frequency is 1 MHz.
So, if you have found my previous posts on how to setup the SPI,
you should be able to set the mode and the SCLK divisor to meet
the requirements given above. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Apr 14, 2008 5:37 pm |
|
|
Quote: | Based on the timing diagrams of the SPI interface on page 34, I would
say it uses SPI Mode 0. It's a little ambiguous, but Mode 0 is the best bet. | In inactive state the clock polarity is high, so it is either Mode 2 or 3. Data is clocked in at the rising edge, that makes it Mode 3.
One problem is that the PIC hardware starts transmitting the MSB while the ISD1700 expects (and sends) LSB first. There are three solutions to this:
Option 1) In the v4 compiler you can specify which bit to send first using the new '#use SPI' directive instead of calling setup_spi(). As the hardware doesn't support LSB first this will automatically create a software driver for you.
Option 2) Revert the bytes before transmission and after receiving (see: http://www.ccsinfo.com/forum/viewtopic.php?p=76547 )
Option 3) Write your own software SPI driver.
Edit 17-Apr-2008: Fixed mode numbers to start counting at 0 and not at 1 (numbers were 1 too high). Thanks Altipatlar006 for pointing out the mistake.
Last edited by ckielstra on Thu Apr 17, 2008 3:52 pm; edited 1 time in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 14, 2008 6:03 pm |
|
|
But on page 34 of the Design Guide, it shows SCLK starting high, but
it ends low. That's why I said its ambiguous. (also, mode 4 ?) |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Apr 14, 2008 6:34 pm |
|
|
PCM programmer wrote: | But on page 34 of the Design Guide, it shows SCLK starting high, but
it ends low. That's why I said its ambiguous. (also, mode 3 ?) | Now I see the clock signal ending low I'm not so sure anymore about the SPI mode. It is either Mode 0 or 3.
Page 42 shows different SPI sequences but again the right side of these drawings are ambiguous.
My guess is the drawings are not very accurate but everybody starts reading at the left side and that side of the drawings is very specific to be Mode 3.
Edit 17-Apr-2008: Fixed mode numbers to start counting at 0 and not at 1 (numbers were 1 too high). Thanks Altipatlar006 for pointing out the mistake.
Last edited by ckielstra on Thu Apr 17, 2008 3:53 pm; edited 1 time in total |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Apr 14, 2008 6:47 pm |
|
|
For the SPI mode it would be worth a try to use the functions from the CCS supplied driver file ISD4003.c:
- init_isd
- write_isd
- read_isd
These functions implement a software based SPI driver sending the LSB first. |
|
|
huytle1
Joined: 11 Apr 2008 Posts: 2
|
|
Posted: Mon Apr 14, 2008 9:16 pm |
|
|
THANKS FOR YOUR HELP EVERYONE!!!! i don't know what i would've done without everyones advice. it helped a ton!! thanks again. |
|
|
altipatlar006
Joined: 08 Mar 2008 Posts: 2
|
a code revert routine.... |
Posted: Thu Apr 17, 2008 6:40 am |
|
|
hi;
i am also interested in ISD1700 series and I want to share a working '8 bit code reverter' routine:
.
.
.
int8 received_data1,received_data2,reverted_data;
int8 buffer;
int flag,i;
void main()
{
while(1)
{
output_low(SS);
received_data1=spi_read(0x80);//reverted PU command-0x01-00000001
received_data2=spi_read(0x00);
output_high(SS);
for(flag=0;flag<8;flag++)
{
i=bit_test(received_data1,flag);
if (i==1)
bit_set(buffer,7-flag);
else
bit_clear(buffer,7-flag);
}
reverted_data=buffer;
//reverted_data[A2,A1,A0,INT,EOM,PU,FULL,CMD_ERR]
}
}
this routine will give you 0x04 which means PU is set 1 that device is powered and ready for SPI.
note:not the first loop but the second loop will give 0x04,this is -for my opinion-first status read operation returns wrong status info.
if you use a display with 1000 ms delay,you can monitor the outputs of the routine
Last edited by altipatlar006 on Thu Apr 17, 2008 9:09 am; edited 2 times in total |
|
|
altipatlar006
Joined: 08 Mar 2008 Posts: 2
|
mode 4? |
Posted: Thu Apr 17, 2008 6:51 am |
|
|
ckielstra said that:
In inactive state the clock polarity is high, so it is either Mode 3 or 4. Data is clocked in at the rising edge, that makes it Mode 4.
I think ckielstra mean mode 3 by Mode 4 and mode 2 by Mode 3.
and he/she is right because I used setup_spi(SPI_MASTER |SPI_H_TO_L | SPI_XMIT_L_TO_H|SPI_CLK_DIV_16 ) configuration and resulted code is given above. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
Re: a code revert routine.... |
Posted: Thu Apr 17, 2008 3:43 pm |
|
|
altipatlar006 wrote: | I want to share a working '8 bit code reverter' routine: | Thanks for sharing the code, but if you look a bit higher in this topic you will see I posted a link to a thread where 6 different revert routines are compared. Your function is there too, named Reverse_0, it is easy to understand but very slow and the second largest routine.
altipatlar006 wrote: | I think ckielstra mean mode 3 by Mode 4 and mode 2 by Mode 3. | Thanks for catching this error. Somehow I always start counting the modes from 1 instead of 0. I've edited my posts above to fix this error. |
|
|
|