Added an offset to the txbuf_n pointer so that the actual ctrl reg value is read.

The original code reads address 0x31, 0x41, or 0x51 "TXBnSIDH – TRANSMIT
BUFFER n STANDARD IDENTIFIER HIGH".  Because that location points to a
constant value, some of the msg ids cause the program to loop 50 times
and then report a timeout error.  After changing the address to point to
0x30, 0x40, or 0x50 "TXBnCTRL – TRANSMIT BUFFER n CONTROL REGISTER", all
of the messages send out properally with no timeout errors.
This commit is contained in:
btetz
2015-08-25 14:15:59 +09:00
parent 8cdb31b161
commit cf0a689dd9
+1 -1
View File
@@ -769,7 +769,7 @@ INT8U MCP_CAN::sendMsg()
do
{
uiTimeOut++;
res1= mcp2515_readRegister(txbuf_n); /* read send buff ctrl reg */
res1= mcp2515_readRegister(txbuf_n-1 /* the ctrl reg is located at txbuf_n-1 */); /* read send buff ctrl reg */
res1 = res1 & 0x08;
}while(res1 && (uiTimeOut < TIMEOUTVALUE));
if(uiTimeOut == TIMEOUTVALUE) /* send msg timeout */