Suppose I have three CAN nodes: A, B and C. We know that when two nodes transmit at the same time, the node that has the least SID will prevail over the bus and the other node will have to give the bus to the first node. What I would want to do is that node B and C will continually send CAN frame to node A in succession (e.g. node B -> node A, node C -> node A, node B -> node A). Can I just assign a lower SID to B than C and just do the following code snippet?
Node B
while(1) sendCANmsg(data, NODE_A, sizeof(data), RTR_OFF);
Node C
while(1) sendCANmsg(data, NODE_A, sizeof(data), RTR_OFF);
Inside of the sendCANmsg, here is the snippet:
TXB0CONbits.TXREQ = 1; // Request Message Transmission
while (TXB0CONbits.TXREQ); // Wait until message is sent.
By the way, I'm using PIC18F25k80 in implementing this. I was just thinking that after node B sent the message, when node C is about to send its message. Node B will again win the bus arbitration thus giving node C no chance of transmission. So I remedy that I can only think of is to insert a small delay like:
while(1) {
sendCANmsg(data, NODE_A, sizeof(data), RTR_OFF);
delay_us(10);
}
Or am I wrong? :)