KDS 3.2.0 project built by ProcessorExpert. When initializing CANBus I install a mask and a filter:
void InitCAN()
{
MyCANPtr = CAN1_Init(NULL);
CAN1_Disable(MyCANPtr);
Error = CAN1_SetAcceptanceMaskTable(MyCANPtr, 0U, 0xFFFF0000 );
Error = CAN1_SetRxIDFilterTable(MyCANPtr, 0U, 0xFFFFF102); // not work with ID: 0x18DAF102
Error = CAN1_SetRxIDFilterTable(MyCANPtr, 0U, 0xFFFFE204); // that's how it works, but why?
CAN1_Enable(MyCANPtr);
}
Does not work. I found a solution, but it only works on the last two bytes. In the debate registers, I see the correct values I set.
This seems to be a microcontroller problem. But I haven't found any errata on this topic anywhere.
Perhaps the specialists from Freescale can clarify something?
Hello Vladimir,
Bellow I will try to explain how the filters work.
If you check the table in the 32-77 it explains how to use the 32 bit mode filtering:
So if you want to filter 0x18DAF102 you will need to write the register IDAR with the following values:
IDAR0 | IDAR1 | IDAR2 | IDAR3 | |||||||||||||||||||||||||||||||
28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | SRR | IDE | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | RTR | |||
1 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | |||
C6 | DD | E2 | 4 |
The IDMR register is to select which bits of the IDARx filter will be marked as "don't care". So for example if you want to allow more than 1 ID with a single filter, for example, 0x18DAF103 and 0x18DAF102, you will need to write the IDMrx registers with the following values.
IDMR0 | IDMR1 | IDMR2 | IDMR3 | |||||||||||||||||||||||||||||||
28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | SRR | IDE | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | RTR | |||
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | |||
0 | 0 | 0 | 2 |
Let me know if this helps you..
Best Regards,
Alexis Andalon
Hello Alexis,
Thank you so much!
You helped me a lot. I get it now.
Best Regards,
Vladimir Medvedev