Master program – Echelon I/O Model Reference for Smart Transceivers and Neuron Chips User Manual

Page 71

Advertising
background image

I/O Model Reference

61

input buffer of the slave (because the master owns the token after reset and has

the first option to write on the bus) and the slave then outputs data to the input
buffer of the master. You can view the buffers using the NodeBuilder debugger

to verify that the transfer was completed.
The master transmits the pattern [5,1,1,1,1,1] to the slave and the slave
transmits the pattern [7,1,2,3,4,5,6,7,0,0,0,0,0,0] to the master. The first byte

indicates the number of bytes being passed; the following non-zero valued bytes
in this example are the actual data bytes transferred. The remaining length of

the array, if any, is filled with zeroes.
The master program writes once to the slave and reads once from the slave. To
implement continuous writes and reads, add an io_out_request()

function call

after the io_in()

function call in the master program.

If a watchdog timeout occurs for either device, simultaneously reset the two
devices.

Master Program

/*
* This is the master program. After reset, the buffer is
* filled with 1s and then the buffer is written to the
* slave. The master then reads the slave’s buffer. The
* master’s output buffer should contain [5,1,1,1,1,1]; the
* input buffer should contain
* [7,1,2,3,4,5,6,7,0,0,0,0,0,0].
*/

IO_0 parallel master parallelBus;

// data to be written in output buffer
#define TEST_DATA 1

// maximum length of input data expected
#define MAX_IN 13

// output length can be equal to or less than the max
#define OUT_LEN 5

// maximum array length
#define MAX_OUT 5

// output structure
struct parallel_out {
// actual length of data to be output
unsigned int length;
// array setup for max length of data to be output
unsigned int buffer[MAX_OUT];
} outData;

// input structure
struct parallel_in {
// actual buffer length to be input
unsigned int length;
// maximum input array
unsigned int buffer[MAX_IN];
} inData;

Advertising