-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter Example that Works #90
Comments
Hello, how is the code to read the FIFO message? Thank you |
Hi burger1473 - I don't understand your FIFO question... -Tony |
Thank you. Your code sampe is help to me. :D |
I will share also code snipped for extended id:
|
I've come across a solution for utilizing the Masks and Filters in the MCP2515 Library. This was through the help of Dr. Dogan Ibahim as I have his book on CAN bus projects. It appears that all the Masks and Filters have to be configured or other CAN ID's that were not specifically filtered will pass though. Here is an example that works.
This example will only Filter on CAN ID 0x1AD. Notice that both Masks and all 6 filters have to be configured. I am setting both Masks to 0x7FF as to check each bit. You can adjust as needed to allow sequential ID's.
This is the snippet that would be in the Arduino setup() function.
`mcp2515.reset();
mcp2515.setBitrate(CAN_250KBPS, MCP_8MHZ);
mcp2515.setConfigMode();
//Set Mask 0 to Check All Bits (0x7FF)
mcp2515.setFilterMask(MCP2515::MASK0, false, 0x7FF);
//Set Filters 0 and 1 to Filter Only CAN ID on 0x1AD
mcp2515.setFilter(MCP2515::RXF0, false, 0x1AD);
mcp2515.setFilter(MCP2515::RXF1, false, 0x1AD);
//Set Mask 1 to Check All Bits (0x7FF)
mcp2515.setFilterMask(MCP2515::MASK1, false, 0x7FF);
//Set Filters 2 to 5 to Filter Only CAN ID on 0x1AD
mcp2515.setFilter(MCP2515::RXF2, false, 0x1AD);
mcp2515.setFilter(MCP2515::RXF3, false, 0x1AD);
mcp2515.setFilter(MCP2515::RXF4, false, 0x1AD);
mcp2515.setFilter(MCP2515::RXF5, false, 0x1AD);
mcp2515.setNormalMode();
}`
To check other ID's simply add them to any of the 6 filters.
Hope this helps!!
-Tony
The text was updated successfully, but these errors were encountered: