Skip to content
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

Issue with mailbox interrupts #58

Open
samprt-heracles opened this issue Dec 9, 2022 · 7 comments
Open

Issue with mailbox interrupts #58

samprt-heracles opened this issue Dec 9, 2022 · 7 comments

Comments

@samprt-heracles
Copy link

Hello,

I am trying to listen to 3 different extended CAN frames with IDs 0x0CF02984, 0x0CF02983 and 0x0CF02985.

Here is the code I am using in setup() :

    can1.setBaudRate(250000);
    can1.setMaxMB(3);
    can1.setMB(MB0, RX, EXT); 
    can1.setMB(MB1, RX, EXT); 
    can1.setMB(MB2, RX, EXT);
    can1.enableMBInterrupts();
    can1.onReceive(MB0, interrupt_1);
    can1.onReceive(MB1, interrupt_2);
    can1.onReceive(MB2, interrupt_3);
    can1.setMBFilter(MB0, 0x0CF02984, EXT);
    can1.setMBFilter(MB1, 0x0CF02983, EXT);
    can1.setMBFilter(MB2, 0x0CF02985, EXT);
    can1.enhanceFilter(MB0);
    can1.enhanceFilter(MB1);
    can1.enhanceFilter(MB2);
    can1.mailboxStatus();

Here is the result of mailboxStatus() :

FIFO Disabled
	Mailboxes:
		MB0 code: RX_EMPTY	(Extended Frame)
		MB1 code: RX_EMPTY	(Extended Frame)
		MB2 code: RX_EMPTY	(Extended Frame)

The interrupt_1 and interrupt_2 are triggered as expected when a message is sent but the interrupt_3 function is not triggered using this code.
If I comment out everything related to Mailbox 1 and Mailbox 2 however, interrupt_3 is triggered.

Any help understanding what I am doing wrong would be much appreciated !

@tonton81
Copy link
Owner

tonton81 commented Dec 9, 2022

try setting enableMBInterrupts last, after the mailbox configurations (including filters)

@samprt-heracles
Copy link
Author

samprt-heracles commented Dec 13, 2022

Sorry, that did not solve the problem.

Here are the frames that are sent on the bus if it can help :

00008 | 08F02D82 | D5 7C 04 7D 2D 79 C0 00 .|.}-y..
00009 | 08F02D83 | 1A 7D D5 79 1C 7F C0 00 .}.y....
00009 | 08F02D84 | 27 7D 85 7E 8F 80 C0 00 '}.~....
00010 | 0CF02982 | 7F E5 D6 04 BC 7B 00 14 .....{..
00009 | 0CF02983 | 24 C8 60 13 BC 7D 00 14 $.`..}..
00009 | 0CF02984 | 76 8E 88 86 1F 7E 00 14 v....~..
00019 | 0CF02985 | 9E 4F 74 D9 8E 7D 00 FF .Ot..}..
00008 | 0CF02A82 | FC 7C 03 7D DE 7C 00 14 .|.}.|..
00010 | 0CF02A83 | E5 7C 26 7D D2 7C 00 14 .|&}.|..
00009 | 0CF02A84 | DA 7C 24 7D AD 7C 00 14 .|$}.|..
00019 | 0CF02A85 | 31 7D EA 7C DF 7C C0 FF 1}.|.|..
00019 | 0CFFD185 | 7B 9B 0F 7F FA B9 64 42 {.....dB
99999 | 18FFD6F6 | 01 51 5F 76 63 A3 02 00 .Q_vc...

@samprt-heracles
Copy link
Author

Filtering the frame with ID 0x0CF02985 (previously filtered in MB2) on a different mailbox seems to fix the issue.
I have reordered the filters to use different mailboxes than in my previous code and now I have the expected behavior.

I still wonder what could be causing this issue though.

@samprt-heracles
Copy link
Author

I have had the same issue with the CAN2 interface. I had to filter out 3 different frames on 3 different mailboxes which called 3 different interrupts . The interrupts only worked when the frame IDs where placed in the mailboxes in decreasing order:

  • MB0 -> 0x18FFE122
  • MB1 -> 0x18FEF200
  • MB2 -> 0x18EFF922

Has anyone experienced the same behavior ? It is not really a problem as long as it is written somewhere I guess.

@tonton81
Copy link
Owner

I ran code from your first post, and it works fine (at least on the github version tested today). The only thing is the filter for the MB, you don't designate EXT for it. The mailbox setMB is already set as EXT(ended), the Filter is implied to be extended and the EXT you put in the filter counts as a secondary ID (as if you did a dual ID filter). So simply remove EXT when setting a mailbox filter, a filter is automatically set based on the mailbox's EXT/STD state from setMB.

the only time EXT/STD is used in a filter is only when using the FIFO filter system.

@tonton81
Copy link
Owner

tonton81 commented Apr 14, 2023

Output from code in first post with EXT removed from setMBFilter using github's current release.

MB 0  OVERRUN: 0  LEN: 8 EXT: 1 TS: 18148 ID: CF02984 Buffer: 4 4 4 4 4 4 4 4 

MB 1  OVERRUN: 0  LEN: 8 EXT: 1 TS: 18289 ID: CF02983 Buffer: 5 5 5 5 5 5 5 5 

MB 2  OVERRUN: 0  LEN: 8 EXT: 1 TS: 18430 ID: CF02985 Buffer: 6 6 6 6 6 6 6 6 

MB 0  OVERRUN: 0  LEN: 8 EXT: 1 TS: 53406 ID: CF02984 Buffer: 4 4 4 4 4 4 4 4 

MB 1  OVERRUN: 0  LEN: 8 EXT: 1 TS: 53548 ID: CF02983 Buffer: 5 5 5 5 5 5 5 5 

MB 2  OVERRUN: 0  LEN: 8 EXT: 1 TS: 53689 ID: CF02985 Buffer: 6 6 6 6 6 6 6 6 

MB 0  OVERRUN: 0  LEN: 8 EXT: 1 TS: 23170 ID: CF02984 Buffer: 4 4 4 4 4 4 4 4 

MB 1  OVERRUN: 0  LEN: 8 EXT: 1 TS: 23311 ID: CF02983 Buffer: 5 5 5 5 5 5 5 5 

MB 2  OVERRUN: 0  LEN: 8 EXT: 1 TS: 23451 ID: CF02985 Buffer: 6 6 6 6 6 6 6 6 

MB 0  OVERRUN: 0  LEN: 8 EXT: 1 TS: 58464 ID: CF02984 Buffer: 4 4 4 4 4 4 4 4 

MB 1  OVERRUN: 0  LEN: 8 EXT: 1 TS: 58606 ID: CF02983 Buffer: 5 5 5 5 5 5 5 5 

MB 2  OVERRUN: 0  LEN: 8 EXT: 1 TS: 58746 ID: CF02985 Buffer: 6 6 6 6 6 6 6 6 

MB 0  OVERRUN: 0  LEN: 8 EXT: 1 TS: 28648 ID: CF02984 Buffer: 4 4 4 4 4 4 4 4 

MB 1  OVERRUN: 0  LEN: 8 EXT: 1 TS: 28789 ID: CF02983 Buffer: 5 5 5 5 5 5 5 5 

MB 2  OVERRUN: 0  LEN: 8 EXT: 1 TS: 28929 ID: CF02985 Buffer: 6 6 6 6 6 6 6 6 

MB 0  OVERRUN: 0  LEN: 8 EXT: 1 TS: 63905 ID: CF02984 Buffer: 4 4 4 4 4 4 4 4 

MB 1  OVERRUN: 0  LEN: 8 EXT: 1 TS: 64046 ID: CF02983 Buffer: 5 5 5 5 5 5 5 5 

MB 2  OVERRUN: 0  LEN: 8 EXT: 1 TS: 64186 ID: CF02985 Buffer: 6 6 6 6 6 6 6 6 

MB 0  OVERRUN: 0  LEN: 8 EXT: 1 TS: 33669 ID: CF02984 Buffer: 4 4 4 4 4 4 4 4 

MB 1  OVERRUN: 0  LEN: 8 EXT: 1 TS: 33811 ID: CF02983 Buffer: 5 5 5 5 5 5 5 5 

MB 2  OVERRUN: 0  LEN: 8 EXT: 1 TS: 33952 ID: CF02985 Buffer: 6 6 6 6 6 6 6 6 

@tonton81
Copy link
Owner

Also the ENUM value for EXT is 1, so essentially you were doing dual filter for example:
IDs: 0xCF02983 and 0x1
without the EXT in filter, it only allows 0xCF02983

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants