CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

HELP WITH PIC16F887 AND ISD1700 SPI PLEASE!!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
huytle1



Joined: 11 Apr 2008
Posts: 2

View user's profile Send private message Send e-mail AIM Address

HELP WITH PIC16F887 AND ISD1700 SPI PLEASE!!
PostPosted: Mon Apr 14, 2008 12:29 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 14, 2008 2:40 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 14, 2008 5:37 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 14, 2008 6:03 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 14, 2008 6:34 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 14, 2008 6:47 pm     Reply with quote

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

View user's profile Send private message Send e-mail AIM Address

PostPosted: Mon Apr 14, 2008 9:16 pm     Reply with quote

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

View user's profile Send private message

a code revert routine....
PostPosted: Thu Apr 17, 2008 6:40 am     Reply with quote

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

View user's profile Send private message

mode 4?
PostPosted: Thu Apr 17, 2008 6:51 am     Reply with quote

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

View user's profile Send private message

Re: a code revert routine....
PostPosted: Thu Apr 17, 2008 3:43 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group