Im trying to make my own CAN shield and eventually an complete unit with atmega mcu and can controller and tranceiver.
I have a working beta version of the hardware, and got the canbus working with the library from: kreatives-chaos.com » Universelle CAN Bibliothek
But as soon as i try to add a filter it all goes badly. either no message gets through or all messages gets through.
This is my filter code:
// create a new filter for receiving messages
can_filter_t filter = {
.id = 0x1ff,
.mask = 0x7ff,
.flags = {
.rtr = 0,
.extended = 0
}
};
can_set_filter(0, &filter);
can_init(BITRATE_1_MBPS);
This is done in the init part of the program,
Is anything else needed to activate the filters ?
the sending-part of my program that sends the message looks like this:
can_t msg;
msg.id = 0x7FF;
msg.flags.rtr = 0;
msg.flags.extended = 0;
msg.length = 4;
msg.data[0] = 0xde;
msg.data[1] = 0xad;
msg.data[2] = 0xbe;
msg.data[3] = 0xef;
can_send_message(&msg);
This message is still received, even though the id = 0x1ff should ignore it in the filter as i understand it.