SPI special commands

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

User avatar
achillis1
Posts: 347
Joined: Thu Oct 09, 2008 9:19 am
Has thanked: 92 times
Been thanked: 8 times
Contact:

SPI special commands

Postby achillis1 » Thu Nov 12, 2015 3:08 pm

Hello,


I have posted already for this issue I am having with SPI communication but the manufacturing company sent me the following procedure. My concern is: based on how flowcode is configured, should I change any settings or have special code in my routine or the normal SPI macros can handle the bellow procedure?

I know that it requires special action from my behalf connecting the appropriate inputs to trigger "data ready" pins but I am concerning about the "SPI NULL" ,, "SPI ESCAPE" e.t.c

<WizFi250 Data Ready> Signal Handling
<WizFi250 Data Ready> signal is ACTIVE HIGH signal. Host controller must give the SPI clock,
as long as <WizFi250 Data Ready> signal is HIGH.
Whenever WizFi250 wants to transfer the data it asserts (HIGH) <WizFi250 Data Ready> signal.
Once all the data transferred from WizFi250 it again de-asserts (LOW) the signal.
Host controller will detect the <WizFi250 Data Ready> signal transition (LOW to HIGH) as edge
triggered interrupt and process the incoming data.

* SPI Transmit data handling
The SPI data transfer layer makes use of an octet (or byte) stuffing procedure. The Control
Escape octet is defined as binary 11110001 (hexadecimal 0xF1), most significant bit first.
Each special control pattern is replaced by a two octet sequence consisting of the SPI Escape
octet followed by the original octet.
Receiving implementations must correctly process all Control Escape sequences.
Escaped data is transmitted on the link as follows:

#define SPI_NULL (uint8_t) 0xF0 //SPI NULL
#define SPI_ESC (uint8_t) 0xF1 //SPI ESCAPE
#define SPI_F0 (uint8_t) 0x00 //F0 is Data
#define SPI_F1 (uint8_t) 0x01 //F1 is Data
#define SPI_SYNC (uint8_t) 0x02 //SPI Flow control SYNC
#define SPI_XON (uint8_t) 0x03 //SPI Flow control XON
#define SPI_XOFF (uint8_t) 0x04 //SPI Flow control XOFF
#define SPI_ERR (uint8_t) 0x05 //SPI Flow control ERROR

One dedicated GPIO signal known as <WizFi250 Data Ready> is available for data ready
indication from Slave WizFi250 to Master Host controller. Master host controller must provide
clock as long as <WizFi250 Data Ready> signal is active. Host controller can make use of GPIO
interrupt (edge triggered low-to-high transition) to receive the data from WizFi250.
Since SPI data transfer works in full duplex mode, special fill character (SPI NULL) will be
transmitted during idle period (if there is no more data to transmit). These idle fill pattern shall be
dropped at receiving end.

* SPI Receive data handling
Since byte stuffing is used, each Control Escape octet must be removed, and the next
immediate octet is SPI control signal. ( 0xF1 0x00 or 0xF1 0x01 are exception. In this case,
0xF1 0x00 is real data of 0xF0 and 0xF1 0x01 is real data of 0xF1 )
If receive buffer is reached upper water mark, then SPI XOFF(0xF1 0x04) character will be sent
out informing the host to stop transmitting actual data. After receiving SPI XOFF character, host
must stop transmitting actual data. Once the application starts processing received data and
enough space available for further reception (reached lower water mark), SPI XON will be
transmitted. Once host receives SPI XON, then it can resume the valid data transmission.
Special control byte SPI IDLE will be dropped at receiver.


Thank you,

Best Regards,

Andreas Achilleos

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

Re: SPI special commands

Postby Benj » Thu Nov 12, 2015 3:35 pm

Hello Andreas,

If you use the search option on the component tool bar and type in SPI then you should get the CAL SPI component appearing.

This is the low level SPI functionality and can be used instead of the more standard SPI_Master component.

The CAL SPI component has a function named Master_Byte.

This function allow you to simultaneously read and write which should allow you to send the SPI_Null byte when reading data.

If your struggling then attach what you have so far and we will try and help.
These users thanked the author Benj for the post:
achillis1 (Thu Nov 12, 2015 4:36 pm)
Rating: 5.56%
 

User avatar
achillis1
Posts: 347
Joined: Thu Oct 09, 2008 9:19 am
Has thanked: 92 times
Been thanked: 8 times
Contact:

Re: SPI special commands

Postby achillis1 » Thu Nov 12, 2015 4:43 pm

Thanks!

Ben, just have in mind that I use FV4!

Since SPI data transfer works in full duplex mode, special fill character (SPI NULL) will be
transmitted during idle period (if there is no more data to transmit). These idle fill pattern shall be
dropped at receiving end.


How will flowcode know to inject the NULL character when the period is idle?

When we say NULL 0xF0 it means : send byte value 240?

Thank you

User avatar
achillis1
Posts: 347
Joined: Thu Oct 09, 2008 9:19 am
Has thanked: 92 times
Been thanked: 8 times
Contact:

Re: SPI special commands

Postby achillis1 » Sun Nov 22, 2015 9:45 am

Hello Ben ,

I cannot find the search function! :shock:


Thank you
Attachments
flow.png
(85 KiB) Downloaded 7468 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8334
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2382 times
Been thanked: 3393 times
Contact:

Re: SPI special commands

Postby medelec35 » Sun Nov 22, 2015 11:53 am

Hi Andreas,
The search function was introduced in Flowcode V6:
Search.png
Search.png (47.31 KiB) Viewed 10324 times

Since you are talking about V4,I have moved this topic to V4 section

Martin
These users thanked the author medelec35 for the post:
achillis1 (Sun Nov 22, 2015 6:22 pm)
Rating: 5.56%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
achillis1
Posts: 347
Joined: Thu Oct 09, 2008 9:19 am
Has thanked: 92 times
Been thanked: 8 times
Contact:

Re: SPI special commands

Postby achillis1 » Sun Nov 22, 2015 6:25 pm

Thanks Martin!


By the way...

1. As Ben suggested; can I still set SPI master in Flowcode 4?
This is the low level SPI functionality and can be used instead of the more standard SPI_Master component.

The CAL SPI component has a function named Master_Byte.

This function allow you to simultaneously read and write which should allow you to send the SPI_Null byte when reading data.


2. Is there a way to add C code intended for Arduino SPI into flowcode for PIC?

Thank you

Best Regards,

Andreas Achilleos