I am planning to use the Seeed CAN shield for the UNO and have ordered it. I have a requirement to filter out message from a CAN bus that has both 11bit and 29 bit ID . There is an example code for this ( set_mask_filter_recv.ino) and the setup for it is as below which is set for one type only .... I am not how to modify this for only receiving data from both type of IDs 0x73E and 0x18FF0108 ?
( Tried to read the chapter 4.5 in the MCP2515 data sheet. Then immediately decided to ask here
)
void setup() {
SERIAL_PORT_MONITOR.begin(115200);
while(!Serial){};
attachInterrupt(digitalPinToInterrupt(CAN_INT_PIN), MCP2515_ISR, FALLING); // start interrupt
while (CAN_OK != CAN.begin(CAN_250KBPS)) { // init can bus : baudrate = 500k
SERIAL_PORT_MONITOR.println("CAN init fail, retry...");
delay(100);
}
SERIAL_PORT_MONITOR.println("CAN init ok!");
/*
set mask, set both the mask to 0x3ff
*/
CAN.init_Mask(0, 0, 0x3ff); // there are 2 mask in mcp2515, you need to set both of them
CAN.init_Mask(1, 0, 0x3ff);
/*
set filter, we can receive id from 0x04 ~ 0x09
*/
CAN.init_Filt(0, 0, 0x04); // there are 6 filter in mcp2515
CAN.init_Filt(1, 0, 0x05); // there are 6 filter in mcp2515
CAN.init_Filt(2, 0, 0x06); // there are 6 filter in mcp2515
CAN.init_Filt(3, 0, 0x07); // there are 6 filter in mcp2515
CAN.init_Filt(4, 0, 0x08); // there are 6 filter in mcp2515
CAN.init_Filt(5, 0, 0x09); // there are 6 filter in mcp2515
}