I am working on a project to integrate mcp2515 library on a nordic nrf52 development board and I used the coryjfowlers library for CAN bus communication found here: GitHub - coryjfowler/MCP_CAN_lib: MCP_CAN Library as the base. I also referred this library for editing according to the processor - GitHub - DejanBukovec/NRF5-SDK-MCP2515: NRF5 SDK 17.0.2 MCP2515 Driver (it looks like this library used the coryjfowler library as the base)
After some edits with regards to the nordic processor, I was able to get the SPI working and the CAN initialization working. I am using just one sender node in this now (a mcp2515 with TJA1050 CAN board connected to nrf52 dev kit as the sender and either nothing connected to CAN-H/CAN-L or connected vector canoe hardware to it).
To test the sending feature of the CAN_bus, I tried to send a message with 8 bytes of data, ID 300 (standard frame) which is done with the MCP_CAN::sendMsgBuf() function.
The error I am having is that after it does the board init successfully, it doesn’t send a message and gives error code 7 (CAN_SENDMSGTIMEOUT), three times, and then sends error 6 (CAN_GETTXBFTIMEOUT) for the rest of the time, which seems to indicate an error that the buffers are full.
I’ve checked with an oscilloscope and found the TxCAN line on the mcp2515 CAN controller always high, but the SPI pins on the CAN controller looks good. In the below image, I am sending a CAN message every 500 ms and the SPI lines shows the same.
I am using SES as the IDE and when I single stepped through the code, I found the following:
- The error CAN_GETTXBFTIMEOUT occurs when mcp2515_getNextFreeTXBuf() returns MCP_ALLTXBUSY.
- mcp2515_readRegister(txbuf_n-1) inside MCP_CAN::sendMsg() returns the response of 0x08 and thus results in the error CAN_SENDMSGTIMEOUT.
What could be the reason for this and what does 0x08 mean here? Please give me insights to solve this issue. I am happy to give more information if you want to help me with the issue.