Hi travis_l
I have one more question. So I have my master and slave in RTOS setup (already included their modules in my bsp) and I see it is working (thanks a lot for previous help by the way). However, I need some way of synchronization between master and slave transactions.
I see that in master RX some data are being lost as it seems by the time that I go and take slave TX data, in master RX, they are partially lost.
Here is what I experimented:
I assigned two same priority tasks: one for master and the other for slave.
Then I used master/slave receive and send block functions:
#define BLOCK_SIZE 10
UINT32 OutDataSlave[BLOCK_SIZE] = {0x12345678, 0x9080706050};
UINT32 OutDataMaster[BLOCK_SIZE] = {0xaabbccdd, 0xeeff0011};
UINT32 InpDataSlave[BLOCK_SIZE];
UINT32 InpDataMaster[BLOCK_SIZE];
//slave task while loop:
while (TRUE)
{
printf ("\tSLAVE LOOP");
err = SS1_ReceiveBlock(slaveDevData, InpDataSlave, BLOCK_SIZE); /* Request data block reception */
if (err!=ERR_OK) printf("ERROR RX data (slave).\n");
else printf("Slave Receive Block return is %d...OK.\n", err);
err = SS1_SendBlock(slaveDevData, OutDataSlave, BLOCK_SIZE); /* Start transmission */
if (err!=ERR_OK) printf("ERROR TX data (slave).\n");
else printf("Slave Send Block return is %d...OK.\n", err);
printf("Slave Rx is 0x%x'\n", InpDataSlave[0]);
printf("Slave Rx is 0x%x'\n", InpDataSlave[1]);
_time_delay(0.003);
}
//and on master task I have this similar loop:
while (TRUE)
{
printf ("\tMASTER LOOP");
err = SM1_SendBlock(masterDevData, OutDataMaster, BLOCK_SIZE); /* Start transmission/reception */
if (err!=ERR_OK) printf("ERROR TX data (master).\n");
else printf("Master Send Block return is %d...OK.\n", err);
err = SM1_ReceiveBlock(masterDevData, InpDataMaster, BLOCK_SIZE); /* Request data block reception */
if (err!=ERR_OK) printf("ERROR RX data (master).\n");
else printf("Master Receive Block return is %d...OK.\n", err);
printf("Master Rx is 0x%x'\n", InpDataMaster[0]);
printf("Master Rx is 0x%x'\n", InpDataMaster[1]);
printf("\n");
_time_delay(0.003);
}
----
and here is what output looks like:
MASTER LOOP 1 time here.
Master Send Block return is 0...OK.
Master Receive Block return is 0...OK.
Master Rx is 0x0'
Master Rx is 0x0'
SLAVE LOOP 2 time here.
Slave Receive Block return is 0...OK.
Slave Send Block return is 0...OK.
Slave Rx is 0xaabbccdd'
Slave Rx is 0xeeff0011'
MASTER LOOP 2 time here.
Master Send Block return is 0...OK.
Master Receive Block return is 0...OK.
Master Rx is 0x56787800'
Master Rx is 0x60501234'
SLAVE LOOP 3 time here.
Slave Receive Block return is 0...OK.
Slave Send Block return is 0...OK.
Slave Rx is 0xaabbccdd'
Slave Rx is 0xeeff0011'
MASTER LOOP 3 time here.
Master Send Block return is 0...OK.
Master Receive Block return is 0...OK.
Master Rx is 0x78000000'
Master Rx is 0x50123456'
SLAVE LOOP 4 time here.
Slave Receive Block return is 0...OK.
ERROR TX data (slave).
Slave Rx is 0xaabbccdd'
Slave Rx is 0xeeff0011'
MASTER LOOP 4 time here.
Master Send Block return is 0...OK.
Master Receive Block return is 0...OK.
Master Rx is 0x80'
Master Rx is 0x0'
SLAVE LOOP 5 time here.
Slave Receive Block return is 0...OK.
Slave Send Block return is 0...OK.
Slave Rx is 0xaabbccdd'
Slave Rx is 0xeeff0011'
MASTER LOOP 5 time here.
Master Send Block return is 0...OK.
Master Receive Block return is 0...OK.
Master Rx is 0x34565678'
Master Rx is 0x70605012'
SLAVE LOOP 6 time here.
Slave Receive Block return is 0...OK.
Slave Send Block return is 0...OK.
Slave Rx is 0xaabbccdd'
Slave Rx is 0xeeff0011'
MASTER LOOP 6 time here.
Master Send Block return is 0...OK.
Master Receive Block return is 0...OK.
Master Rx is 0x56787800'
Master Rx is 0x60501234'
SLAVE LOOP 7 time here.
Slave Receive Block return is 0...OK.
Slave Send Block return is 0...OK.
Slave Rx is 0xaabbccdd'
Slave Rx is 0xeeff0011'
MASTER LOOP 7 time here.
Master Send Block return is 0...OK.
Master Receive Block return is 0...OK.
Master Rx is 0x78000000'
Master Rx is 0x50123456'
SLAVE LOOP 8 time here.
Slave Receive Block return is 0...OK.
ERROR TX data (slave).
Slave Rx is 0xaabbccdd'
Slave Rx is 0xeeff0011'
MASTER LOOP 8 time here.
Master Send Block return is 0...OK.
Master Receive Block return is 0...OK.
Master Rx is 0x80'
Master Rx is 0x0'
SLAVE LOOP 9 time here.
Slave Receive Block return is 0...OK.
Slave Send Block return is 0...OK.
Slave Rx is 0xaabbccdd'
Slave Rx is 0xeeff0011'
--------------------------------------------------------
data are not seem to be missing on the slave receive side from master, but, obviously, we see that data sent from slave are being lost...
now the question is, how I can come up with a synchronization strategy between my master and slave transactions?
Do you know of any functions that can help me with that?
Thanks
Another thing I need to know is that I see the buffer pointer for both master sendblock and receiveblock are same:
Is this allowed?
#define iteration 3
#define BLOCK_SIZE 10
UINT32 OutDataSlave[BLOCK_SIZE] = {0x12345678, 0x90807060};
UINT32 OutDataMaster[BLOCK_SIZE] = {0xaabbccdd, 0xeeff0011};
UINT32 InpDataSlave[BLOCK_SIZE];
UINT32 InpDataMaster[BLOCK_SIZE];
Here is my log:
SLAVE LOOP 1 time here.
Slave Receive Block return is 0...OK.
Slave Send Block return is 0...OK.
0-Slave Rx is 0x0'
1-Slave Rx is 0x0'
2-Slave Rx is 0x0'
3-Slave Rx is 0x0'
4-Slave Rx is 0x0'
5-Slave Rx is 0x0'
6-Slave Rx is 0x0'
7-Slave Rx is 0x0'
8-Slave Rx is 0x0'
9-Slave Rx is 0x0'
10-Slave Rx is 0x0'
11-Slave Rx is 0x0'
12-Slave Rx is 0x0'
---> MASTER INITIALIZE ---------------------
MASTER LOOP 1 time here.
Master Send Block return is 0...OK.
Master Receive Block return is 0...OK.
0-Master Rx is 0x0'
1-Master Rx is 0x0'
2-Master Rx is 0x0'
3-Master Rx is 0x0'
4-Master Rx is 0x0'
5-Master Rx is 0x0'
6-Master Rx is 0x0'
7-Master Rx is 0x0'
8-Master Rx is 0x0'
9-Master Rx is 0x0'
10-Master Rx is 0xaabbccdd'
11-Master Rx is 0xeeff0011'
12-Master Rx is 0x0'
SLAVE LOOP 2 time here.
Slave Receive Block return is 0...OK.
Slave Send Block return is 0...OK.
0-Slave Rx is 0xaabbccdd'
1-Slave Rx is 0xeeff0011'
2-Slave Rx is 0x0'
3-Slave Rx is 0x0'
4-Slave Rx is 0x0'
5-Slave Rx is 0x0'
6-Slave Rx is 0x0'
7-Slave Rx is 0x0'
8-Slave Rx is 0x0'
9-Slave Rx is 0x0'
10-Slave Rx is 0x0'
11-Slave Rx is 0x0'
12-Slave Rx is 0x0'
MASTER LOOP 2 time here.
Master Send Block return is 0...OK.
Master Receive Block return is 0...OK.
0-Master Rx is 0x56787800'
1-Master Rx is 0x70601234'
2-Master Rx is 0x9080'
3-Master Rx is 0x0'
4-Master Rx is 0x0'
5-Master Rx is 0x0'
6-Master Rx is 0x0'
7-Master Rx is 0x0'
8-Master Rx is 0x0'
9-Master Rx is 0x0'
10-Master Rx is 0xaabbccdd'
11-Master Rx is 0xeeff0011'
12-Master Rx is 0x0'
SLAVE LOOP 3 time here.
Slave Receive Block return is 0...OK.
Slave Send Block return is 0...OK.
0-Slave Rx is 0xaabbccdd'
1-Slave Rx is 0xeeff0011'
2-Slave Rx is 0x0'
3-Slave Rx is 0x0'
4-Slave Rx is 0x0'
5-Slave Rx is 0x0'
6-Slave Rx is 0x0'
7-Slave Rx is 0x0'
8-Slave Rx is 0x0'
9-Slave Rx is 0x0'
10-Slave Rx is 0x0'
11-Slave Rx is 0x0'
12-Slave Rx is 0x0'
MASTER LOOP 3 time here.
Master Send Block return is 0...OK.
Master Receive Block return is 0...OK.
0-Master Rx is 0x78000000'
1-Master Rx is 0x60123456'
2-Master Rx is 0x8070'
3-Master Rx is 0x0'
4-Master Rx is 0x0'
5-Master Rx is 0x0'
6-Master Rx is 0x0'
7-Master Rx is 0x0'
8-Master Rx is 0x0'
9-Master Rx is 0x0'
10-Master Rx is 0xaabbccdd'
11-Master Rx is 0xeeff0011'
12-Master Rx is 0x0'
SLAVE LOOP 4 time here.
Slave Receive Block return is 0...OK.
ERROR TX data (slave).
0-Slave Rx is 0xaabbccdd'
1-Slave Rx is 0xeeff0011'
2-Slave Rx is 0x0'
3-Slave Rx is 0x0'
4-Slave Rx is 0x0'
5-Slave Rx is 0x0'
6-Slave Rx is 0x0'
7-Slave Rx is 0x0'
8-Slave Rx is 0x0'
9-Slave Rx is 0x0'
10-Slave Rx is 0x0'
11-Slave Rx is 0x0'
12-Slave Rx is 0x0'
MASTER LOOP 4 time here.
Master Send Block return is 0...OK.
Master Receive Block return is 0...OK.
0-Master Rx is 0x90'
1-Master Rx is 0x0'
2-Master Rx is 0x0'
3-Master Rx is 0x0'
4-Master Rx is 0x0'
5-Master Rx is 0x0'
6-Master Rx is 0x0'
7-Master Rx is 0x0'
8-Master Rx is 0x0'
9-Master Rx is 0x0'
10-Master Rx is 0xaabbccdd'
11-Master Rx is 0xeeff0011'
12-Master Rx is 0x0'
---------------------------------------------
Mehdi