2015-07-14 02:53 PM
Is the filter for the CAN ''Networking'' demo configured to accept all CAN frames?
#stm32 #can #example #code2015-07-14 03:16 PM
Yes
CAN_FilterInitStructure.CAN_FilterIdHigh=0x0000;
CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
if ((X & 0) == 0) // Always Taken
2015-07-15 09:25 AM
Thanks again, clive. Mind explaining how the filter works? I can't find much about the specifics online.
2015-07-15 10:12 AM
I don't use CAN much, there's a lot of confusing examples on the internet, and a bunch can't possibly be right.
My inferred understanding is that the message ID is the top 11-bits of the filter. If I wanted one specific message I think this is the way to do it/* CAN filter init */
CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
CAN_FilterInitStructure.CAN_FilterIdHigh = (ID << 5); // ID 11-bit in top bits
CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0xFFE0;// ID 11-bit in top bits, mask for comparison
CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;
// if ((bitstream & CAN_FilterMaskId) == CAN_FilterId)
To be less selective you'd open up the mask, and mask the id too.
If you have a bus with an interesting selection of messages, shouldn't be more that a 10 minute task to nail this down.
A 16-bit mode should permit id/mask to appear in both High and Low fields.