SUB_20 to SUB_20 through SPI interface transfer issue
Posted: Sun Apr 26, 2015 8:44 am
Hello.
I'm trying to transfer one Byte data from SUB_20 Master to SUB_20 Slave through SPI interface.
I plugged it in the next way: https://www.dropbox.com/s/g0thfwj46nvxs ... 8.jpg?dl=0
The master sends a number (1-to 255 ) to slave each cycle. The number is increased by one at end of each cycle. The slave receives a number and sends it back to a master.
I.e it must be in this way:
Cycle 0: _MASTER: writing to slave 0 ----> _SLAVE: reading from master 0 ----> _SLAVE: writing to master 0 ----> _MASTER: reading from input buffer 0
Cycle 1: _MASTER: writing to slave 1 ----> _SLAVE: reading from master 1 ----> _SLAVE: writing to master 1 ----> _MASTER: reading from input buffer 1
Cycle 2: _MASTER: writing to slave 2 ----> _SLAVE: reading from master 2 ----> _SLAVE: writing to master 2 ----> _MASTER: reading from input buffer 2
e.t.c.
The one direction (master to slave) transfer is perfect. BUT an issue is in the second direction.
Three first cycles a master receives back form slave a number 0. On fourth cycle a master receives back form slave a number 1, and after it continues to receive the numbers with "skip" of 3 numbers, i.e.:
Cycle 0: _MASTER: writing to slave 0 ----> _SLAVE: reading from master 0 ----> _SLAVE: writing to master 0 ----> _MASTER: reading from input buffer 0
Cycle 1: _MASTER: writing to slave 1 ----> _SLAVE: reading from master 1 ----> _SLAVE: writing to master 1 ----> _MASTER: reading from input buffer 0
Cycle 2: _MASTER: writing to slave 2 ----> _SLAVE: reading from master 2 ----> _SLAVE: writing to master 2 ----> _MASTER: reading from input buffer 0
Cycle 3: _MASTER: writing to slave 3 ----> _SLAVE: reading from master 3 ----> _SLAVE: writing to master 3 ----> _MASTER: reading from input buffer 0
Cycle 4: _MASTER: writing to slave 4 ----> _SLAVE: reading from master 4 ----> _SLAVE: writing to master 4 ----> _MASTER: reading from input buffer 1
Cycle 5: _MASTER: writing to slave 5 ----> _SLAVE: reading from master 5 ----> _SLAVE: writing to master 5 ----> _MASTER: reading from input buffer 2
Cycle 6: _MASTER: writing to slave 6 ----> _SLAVE: reading from master 6 ----> _SLAVE: writing to master 6 ----> _MASTER: reading from input buffer 3
e.t.c...
The sources of my code for master and slave are attached to the post.
Please help me to solve the problem.
Thank you in advance.
Alexander.
I'm trying to transfer one Byte data from SUB_20 Master to SUB_20 Slave through SPI interface.
I plugged it in the next way: https://www.dropbox.com/s/g0thfwj46nvxs ... 8.jpg?dl=0
The master sends a number (1-to 255 ) to slave each cycle. The number is increased by one at end of each cycle. The slave receives a number and sends it back to a master.
I.e it must be in this way:
Cycle 0: _MASTER: writing to slave 0 ----> _SLAVE: reading from master 0 ----> _SLAVE: writing to master 0 ----> _MASTER: reading from input buffer 0
Cycle 1: _MASTER: writing to slave 1 ----> _SLAVE: reading from master 1 ----> _SLAVE: writing to master 1 ----> _MASTER: reading from input buffer 1
Cycle 2: _MASTER: writing to slave 2 ----> _SLAVE: reading from master 2 ----> _SLAVE: writing to master 2 ----> _MASTER: reading from input buffer 2
e.t.c.
The one direction (master to slave) transfer is perfect. BUT an issue is in the second direction.
Three first cycles a master receives back form slave a number 0. On fourth cycle a master receives back form slave a number 1, and after it continues to receive the numbers with "skip" of 3 numbers, i.e.:
Cycle 0: _MASTER: writing to slave 0 ----> _SLAVE: reading from master 0 ----> _SLAVE: writing to master 0 ----> _MASTER: reading from input buffer 0
Cycle 1: _MASTER: writing to slave 1 ----> _SLAVE: reading from master 1 ----> _SLAVE: writing to master 1 ----> _MASTER: reading from input buffer 0
Cycle 2: _MASTER: writing to slave 2 ----> _SLAVE: reading from master 2 ----> _SLAVE: writing to master 2 ----> _MASTER: reading from input buffer 0
Cycle 3: _MASTER: writing to slave 3 ----> _SLAVE: reading from master 3 ----> _SLAVE: writing to master 3 ----> _MASTER: reading from input buffer 0
Cycle 4: _MASTER: writing to slave 4 ----> _SLAVE: reading from master 4 ----> _SLAVE: writing to master 4 ----> _MASTER: reading from input buffer 1
Cycle 5: _MASTER: writing to slave 5 ----> _SLAVE: reading from master 5 ----> _SLAVE: writing to master 5 ----> _MASTER: reading from input buffer 2
Cycle 6: _MASTER: writing to slave 6 ----> _SLAVE: reading from master 6 ----> _SLAVE: writing to master 6 ----> _MASTER: reading from input buffer 3
e.t.c...
The sources of my code for master and slave are attached to the post.
Please help me to solve the problem.
Thank you in advance.
Alexander.