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.
If either the CANBUS is saturated or the MCU is busy for some time, both RX buffers of the MCP2515 may be in use. If the MCU does not catch up in processing the incoming messages, the second message received just adds another reason for the IRQ.
Thus reading a single message does not clear the IRQ conditon of the MCP2515 leading to a permanent lock up of the receiver program.
Signed-off-by: Ralf Edmund Stranzenbach <ralf@reswi.de>
not clearing m_nRtr until next data frame without request bit is
received. This lead to sending out all frames in between with
request bit set aswell. Fixed by extending sendMsgBuf to
INT8U sendMsgBuf(INT32U id, INT8U ext, INT8U rtr, INT8U len, INT8U *buf)
and setMsg to
INT8U setMsg(INT32U id, INT8U ext, INT8U len, INT8U rtr, INT8U *pData)
giving the possibillity to specify if request bit is set or not when
sending a message.
Feature: New function INT8U MCP_CAN::isRemoteRequest(void) added
to make it possible to check if the remote request bit was set on
the last received message.
- Added: buffer limit in mcp2515_readRegisterS
- Added: return code check in readMsgBuf
- Added: function readMsgBufID to read message and object id in a single phase
There was an error in the bit arithmatic for the can id.
Basically, if the 15th bit of the id was set, then the upper 16bits were 1 less than they should be.
e.g. 0x0001(8-F)XXX -> 0x0000(8-F)XXX
e.g. 0x0000(8-F)XXX -> 0xFFFF(8-F)XXX
The offending operation is (tbufdata[MCP_EID8]<<8). This promotes an unsigned char to a signed int, which results in the corrupted ids. The fix is to cast it to an unsigned int. Note that int's are 16 bit on avr.