Help with SPI Legacy

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Roberto Serra
Flowcode V4 User
Posts: 7
Joined: Thu Nov 19, 2009 2:48 pm

Help with SPI Legacy

Post by Roberto Serra »

Hello,
I'm working with a PIC18F2520 and a ISD4002(Single-Chip Voice Record/Playback Device);
they use the SPI protocol (MISO, MOSI, SCLK, SS, INT, RAC) for ISD and (SDA, SDO, SCK/SCL, SS, INT0, RC0) for PIC.

At the moment my test program is simple, press a button, PIC send 2 byte for the REC, Press a second button and the PIC send 2 byte for the PLAY.

The program work (I think) but I can't verify the real comunication.....

I try to send a request of answare, but I don't know how to recive this answare and verify if is correct....

If the ISD don't answare to my message, can the problem be in the timing of the comunication???

Can Someone Help me???

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Help with SPI Legacy

Post by Benj »

Hello

The SPI legacy currently works to control the SDO, SDI and SCK pins. If you are using the generic send and receive functions then you will also have to manually control the SS, INT and RAC pins in your program. In the device datasheet there should be a waveform showing you the communication protocol to use. Eg what to do with the other pins while sending or receiving information.

Roberto Serra
Flowcode V4 User
Posts: 7
Joined: Thu Nov 19, 2009 2:48 pm

Re: Help with SPI Legacy

Post by Roberto Serra »

SS it must be set to zero and it's ok;
RAC it's a pin for complex operation that I don't use;
INT is a pin for the interrupt.... and is used for the answare of the request sent, but it doesn't change state, so I think that the requests are not recived.....
can the problem be in the timing of the comunication??? a delay between the request and the answer???

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Help with SPI Legacy

Post by Benj »

Hello Roberto

You will probably need to refer to the timing diagram supplied in the device datasheet and adjust your SPI component properties accordingly to create the correct bus speed and correct i/o timings.

The SS line will probably have to be set to 1 between communications as a lot of SPI devices use the high to low edge to activate or wakeup the device.

When I am communicating via SPI I create software macros to handle a read and a write transaction. This way I can then simply call the macros either passing a parameter to be written or with a return value of the read.

If you cannot get the device working then I suggest that you post up a link to the device datasheet and also post up your program so far. I cant promise that we will do all the work but we may be able to spot something your doing incorrectly etc.

Roberto Serra
Flowcode V4 User
Posts: 7
Joined: Thu Nov 19, 2009 2:48 pm

Re: Help with SPI Legacy

Post by Roberto Serra »

Thanks for your answare, I search somethink about bus seep on the datasheet but I don find anythink...

ISD4002 datasheet is here:
http://pdf1.alldatasheet.com/datasheet- ... D4002.html
PIC18F2520 datasheet is here:
http://pdf1.alldatasheet.com/datasheet- ... F2520.html

Now I will have a new quest, when I use SPI Legacy element on the panel of the program, doing Right click-> Connection, it send me a message like
"this component do not have external connection"
why?
the component must have external connection to comunicate with the otrer component or not?

at this moment the program is simple:
PIC send 2 byte to the ISD to start the recording session wait 1 minute and send 2 byte to stop.
o send 2 byte to play the recorded sound, and wait the interrupt (on the int0 pin of the PIC) of the end....
tu send the byte I use the standard Macro of SPI component (SPI_Send_Char).

But I don't know is it really work or not, because the led tha I use to verify the state of the operation didn't turn of, so the operation crash during the transmission.....

I create a test program with only a led to light on/off, if I add the istruction to sand the byte the program crash...
I really don't understand......

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Help with SPI Legacy

Post by Benj »

Hello

Pages 5 and 6 of the ISD4002 device datasheet has some good information. Using it I created this simple test file that should work correctly.

I have created the LED to drive the Slave Select (SS) output .

The SPI component has no connections because it is a hardware peripheral. Eg it uses the SDI, SDO and SCK pins. These pins can be found labelled on the chip diagram in Flowcode.

uc Pin - ISD4002 device pin
SDI - MISO
SDO - MOSI
SCK - SCLK
C0 or the LED pin connection - SS

You will also need to assign the correct chip configuration for your setup. I have guessed these values for use with our EB006 but you may need to change the oscillator settings if you are using your own hardware or the internal oscillator etc.

As the device can only run at 3V you will either have to run your PIC at 3V if it is capable of this or you will have to use some circuitry to switch the SPI levels from 5V to 3V. You can do this using a logic level converter or just by simply using a potential divider circuit on the PIC outputs.
Attachments
SPI_Example.fcf
(7 KiB) Downloaded 312 times

Roberto Serra
Flowcode V4 User
Posts: 7
Joined: Thu Nov 19, 2009 2:48 pm

Re: Help with SPI Legacy

Post by Roberto Serra »

ok, understand.... but ......

why my do not work??

I don't see the characters transit from PIC to ISD....

I attached my last file.....
Attachments
sinvoc1.5_3.fcf
(25.53 KiB) Downloaded 275 times

Roberto Serra
Flowcode V4 User
Posts: 7
Joined: Thu Nov 19, 2009 2:48 pm

Re: Help with SPI Legacy

Post by Roberto Serra »

I think there was a miss-undertanding, the program work only in simulation, the real problem is when I program the PIC;

in this case it don't work.

can someone sugest me hypothesis?

Post Reply