Page 1 of 1

SPI on Flowcode

Posted: Thu Dec 10, 2009 7:46 am
by Adrien DG
Good Morning !!
First Excuse me for my english.

I'm working on a project, and I have to realize a communication between a PIC 16F877A and a CPLD in SPI transmission.
The problem is :
The CPLD send a binary code in 32 bits, but the PIC is a 8bits one.
How can I do to cut the 32 bits word in 4 8bits words with flowcode ?

I've already tried to do a "getchar" with the SPI block, but a char is not a word.
Help Me please, it's very important.

Regards
Adrien

Re: SPI on Flowcode

Posted: Thu Dec 10, 2009 9:47 am
by Benj
Hello Adrien

A byte or char is 8-bits whereas a word is 4-bytes or 32-bits.

The GetChar macro will allow you to receive bytes so you could receive a byte at a time from the 32-bit source.

You could then keep all bytes seperate in Flowcode or you could use C to recombine them into a 32-bit number. Note that if you do this you will need to always reference the 32-bit number in C as Flowcode is unable to handle 32-bit numbers.

Here is the example C code to recombine the bytes stored in Flowcode variables byte0 - byte3.

unsigned long var32;
var32 = FCV_BYTE0;
var32 = var32 | (FCV_BYTE1 << 8);
var32 = var32 | (FCV_BYTE2 << 16);
var32 = var32 | (FCV_BYTE3 << 24);

Re: SPI on Flowcode

Posted: Thu Dec 10, 2009 11:40 am
by Adrien DG
Oh, thank you,
I will try that !
I have to do an Ethernet communication, for the same project,
Can I do this with Flowcode ?

Regards,
Adrien
France

Re: SPI on Flowcode

Posted: Thu Dec 10, 2009 1:24 pm
by Benj
Hello

Yes Flowcode supports Ethernet via an I2C Wiznet module. This can be done using our EB023 Internet E-Block or using your own Wiznet module.

Re: SPI on Flowcode

Posted: Fri Dec 11, 2009 1:05 pm
by Adrien DG
The SPI communication runs as we expect !!
I can send and receive 32 bits words !!!
Thank you very much one more time !!!

Regards,
Adrien DG