FlexCAN_T4 - FlexCAN for Teensy 4

For J1939 the don't care would be the SA and the rest would need to go the the necessary MB.

For setMBUserFilter, if I only set one ID then should the mask just be all F's? because I only want to capture the one ID for one MB.

Anyways I will try to understand what the mask is come from setMBFilter as to what the filter should be.

Thanks

Bruce
 
print the one from the setmbfilter function

Serial.println(mask)
Better yet, you can print it from setMBFilterProcessing section before the function exits
Serial.println(mask)
this way all the filter functions get printed and you will see all the bits they use
what happens if you try 0xFFF for the mask in userfilter?
 
Well I replaced the user filter for the setmbfilter for the standard frames.

Nothing.

So then I bypassed all the filter setting and put setmbfilter accept all and still nothing. I can't understand why I can't get the interrupt to fire. I do don't get it. Could it be something to do with the mycan-> instead of can0.?

Should I try pollingto see if the messages are received?

Other thoughts?

I have 40 is mailboxes set to std receive and accept all and I don't get an idea interrupt to fire...😲

Thanks

Bruce
 
what happens if you put events() in the loop? does the frames show up in callback? something wrong in your code if it wont receive frames
 
No callback

what happens if you put events() in the loop? does the frames show up in callback? something wrong in your code if it wont receive frames

That is the problem.

I am setting up the MB correctly because it shows up in MBStatus.

I am accepting all frames but I get no call back...makes no sense.

I thought events() was for FIFO? FIFO is disabled. You can see that in the MBStatus.

I also disabled in the sample code.

Thanks

Bruce
 
Of all the things that could be messed up, you can not cast the baud rate calc as an uint16_t.

That certainly is a "smack your forehead against a brick wall moment.

So this is what the captured frames look like now:
8.95,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
8.96,Bus:1,ID:1b5,Overun:0,MB:38,Len:8,cc,1,5,90,22,20,22,20
8.96,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
8.96,Bus:1,ID:4bc,Overun:0,MB:17,Len:8,0,0,fd,ea,27,10,0,0
8.96,Bus:1,ID:2b6,Overun:0,MB:27,Len:8,28,7d,4,df,28,7d,4,e0
8.96,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
8.96,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
8.96,Bus:1,ID:1b7,Overun:0,MB:37,Len:8,0,0,0,ff,ff,0,ff,ff
8.97,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
8.97,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
8.97,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
8.97,Bus:1,ID:4be,Overun:0,MB:16,Len:8,0,0,0,0,0,0,0,0
8.97,Bus:1,ID:2a8,Overun:0,MB:32,Len:8,0,0,0,0,0,0,0,ff
8.97,Bus:1,ID:4b6,Overun:0,MB:19,Len:8,3a,39,29,95,30,39,0,0
8.97,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
8.97,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
8.98,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
8.98,Bus:1,ID:2b0,Overun:0,MB:30,Len:8,e5,39,3a,10,24,40,24,60
8.98,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
8.98,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
8.99,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
8.99,Bus:1,ID:2b2,Overun:0,MB:29,Len:8,ff,ff,ff,ff,ff,7f,1f,1f
8.99,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
8.99,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
8.99,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
8.99,Bus:1,ID:250,Overun:0,MB:33,Len:8,0,0,30,17,1,16,b,5d
8.99,Bus:1,ID:249,Overun:0,MB:36,Len:8,9e,30,6,0,0,0,4,0
9.00,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.00,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.00,Bus:1,ID:2b4,Overun:0,MB:28,Len:8,ff,ff,ff,ff,ff,7f,1f,1f
9.00,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
9.00,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
9.01,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.01,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
9.01,Bus:1,ID:1b5,Overun:0,MB:38,Len:8,cc,1,5,90,22,20,22,20
9.01,Bus:1,ID:2b6,Overun:0,MB:27,Len:8,28,7d,4,df,28,7d,4,e0
9.01,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.01,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
9.01,Bus:1,ID:1b7,Overun:0,MB:37,Len:8,0,0,0,ff,ff,0,ff,ff
9.01,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.02,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.02,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
9.02,Bus:1,ID:2a8,Overun:0,MB:32,Len:8,0,0,0,0,0,0,0,ff
9.02,Bus:1,ID:4a4,Overun:0,MB:22,Len:8,0,2,39,2,0,0,0,0
9.02,Bus:1,ID:4b6,Overun:0,MB:19,Len:8,3a,39,29,95,30,39,0,0
9.02,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
9.03,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.03,Bus:1,ID:2b0,Overun:0,MB:30,Len:8,e5,39,3a,10,24,40,24,60
9.03,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
9.03,Bus:1,ID:4a6,Overun:0,MB:21,Len:8,3a,30,f,a0,0,fa,f,a0
9.03,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.03,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
9.04,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.04,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.04,Bus:1,ID:2b2,Overun:0,MB:29,Len:8,ff,ff,ff,ff,ff,7f,1f,1f
9.04,Bus:1,ID:4b0,Overun:0,MB:20,Len:8,0,0,0,0,7d,7c,0,6
9.04,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
9.04,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
9.04,Bus:1,ID:150,Overun:0,MB:43,Len:8,fc,f8,ff,ff,ff,ff,ff,ff
9.05,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.05,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
9.05,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.05,Bus:1,ID:2b4,Overun:0,MB:28,Len:8,ff,ff,ff,ff,ff,7f,1f,1f
9.05,Bus:1,ID:4ba,Overun:0,MB:18,Len:8,0,0,0,0,0,0,7,d0
9.05,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
9.05,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.06,Bus:1,ID:1b5,Overun:0,MB:38,Len:8,cc,1,5,90,22,20,22,20
9.06,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.06,Bus:1,ID:4bc,Overun:0,MB:17,Len:8,0,0,fd,ea,27,10,0,0
9.06,Bus:1,ID:2b6,Overun:0,MB:27,Len:8,28,7d,4,df,28,7d,4,e0
9.06,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
9.06,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
9.06,Bus:1,ID:1b7,Overun:0,MB:37,Len:8,0,0,0,ff,ff,0,ff,ff
9.07,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.07,Bus:1,ID:4be,Overun:0,MB:16,Len:8,0,0,0,0,0,0,0,0
9.07,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
9.07,Bus:1,ID:2a8,Overun:0,MB:32,Len:8,0,0,0,0,0,0,0,ff
9.07,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.07,Bus:1,ID:4b6,Overun:0,MB:19,Len:8,3a,39,29,95,30,39,0,0
9.07,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
9.08,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.08,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.08,Bus:1,ID:2b0,Overun:0,MB:30,Len:8,e5,39,3a,10,24,40,24,a0
9.08,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
9.08,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
9.09,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.09,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
9.09,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.09,Bus:1,ID:2b2,Overun:0,MB:29,Len:8,ff,ff,ff,ff,ff,7f,1f,1f
9.09,Bus:1,ID:250,Overun:0,MB:33,Len:8,0,0,30,17,1,16,b,5d
9.09,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5e,0,0,0,0,fa,0
9.09,Bus:1,ID:249,Overun:0,MB:36,Len:8,9f,38,7,0,0,0,4,0
9.09,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.10,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.10,Bus:1,ID:2b4,Overun:0,MB:28,Len:8,ff,ff,ff,ff,ff,7f,1f,1f
9.10,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
9.10,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0
9.11,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.11,Bus:1,ID:2b6,Overun:0,MB:27,Len:8,28,7d,4,df,28,7d,4,e0
9.11,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
9.11,Bus:1,ID:1b5,Overun:0,MB:38,Len:8,cc,1,5,90,22,20,22,20
9.11,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.11,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0
9.11,Bus:1,ID:1b7,Overun:0,MB:37,Len:8,0,0,0,ff,ff,0,ff,ff
9.12,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.12,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.12,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
9.12,Bus:1,ID:2a8,Overun:0,MB:32,Len:8,0,0,0,0,0,0,0,ff
9.12,Bus:1,ID:4a4,Overun:0,MB:22,Len:8,0,2,39,2,0,0,0,0
9.12,Bus:1,ID:4b6,Overun:0,MB:19,Len:8,3a,39,29,95,30,39,0,0
9.12,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0
9.13,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.13,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
9.13,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.13,Bus:1,ID:2b0,Overun:0,MB:30,Len:8,e5,39,3a,10,24,40,24,60
9.13,Bus:1,ID:4a6,Overun:0,MB:21,Len:8,3a,30,f,a0,0,fa,f,a0
9.13,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0
9.14,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.14,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.14,Bus:1,ID:2b2,Overun:0,MB:29,Len:8,ff,ff,ff,ff,ff,7f,1f,1f
9.14,Bus:1,ID:4b0,Overun:0,MB:20,Len:8,0,0,0,0,7d,7c,0,6
9.14,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
9.14,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0
9.14,Bus:1,ID:150,Overun:0,MB:43,Len:8,fc,f8,ff,ff,ff,ff,ff,ff
9.15,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.15,Bus:1,ID:2b4,Overun:0,MB:28,Len:8,ff,ff,ff,ff,ff,7f,1f,1f
9.15,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
9.15,Bus:1,ID:4ba,Overun:0,MB:18,Len:8,0,0,0,0,0,0,7,d0
9.15,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.15,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0
9.16,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.16,Bus:1,ID:1b5,Overun:0,MB:38,Len:8,cc,1,5,90,22,20,22,20
9.16,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.16,Bus:1,ID:4bc,Overun:0,MB:17,Len:8,0,0,fd,ea,27,10,0,0
9.16,Bus:1,ID:2b6,Overun:0,MB:27,Len:8,28,7d,4,df,28,7d,4,e0
9.16,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
9.16,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0
9.16,Bus:1,ID:1b7,Overun:0,MB:37,Len:8,0,0,0,ff,ff,0,ff,ff
9.17,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.17,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
9.17,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.17,Bus:1,ID:4be,Overun:0,MB:16,Len:8,0,0,0,0,0,0,0,0
9.17,Bus:1,ID:2a8,Overun:0,MB:32,Len:8,0,0,0,0,0,0,0,ff
9.17,Bus:1,ID:4b6,Overun:0,MB:19,Len:8,3a,39,29,95,30,39,0,0
9.17,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0
9.18,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.18,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.18,Bus:1,ID:2b0,Overun:0,MB:30,Len:8,e5,39,3a,10,24,40,24,60
9.18,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
9.18,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0
9.19,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.19,Bus:1,ID:2b2,Overun:0,MB:29,Len:8,ff,ff,ff,ff,ff,7f,1f,1f
9.19,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
9.19,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.19,Bus:1,ID:250,Overun:0,MB:33,Len:8,0,0,30,17,1,16,b,5e
9.19,Bus:1,ID:249,Overun:0,MB:36,Len:8,80,50,0,0,0,0,4,0
9.19,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0
9.20,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.20,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.20,Bus:1,ID:2b4,Overun:0,MB:28,Len:8,ff,ff,ff,ff,ff,7f,1f,1f
9.20,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
9.20,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0
9.21,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.21,Bus:1,ID:1b3,Overun:0,MB:39,Len:8,c6,32,0,0,7d,0,0,fc
9.21,Bus:1,ID:1b5,Overun:0,MB:38,Len:8,cc,1,5,90,22,20,22,20
9.21,Bus:1,ID:2b6,Overun:0,MB:27,Len:8,28,7d,4,df,28,7d,4,e0
9.21,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.21,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0
9.21,Bus:1,ID:1b7,Overun:0,MB:37,Len:8,0,0,0,ff,ff,0,ff,ff
9.22,Bus:1,ID:1a0,Overun:0,MB:42,Len:8,f9,0,0,0,0,0,0,0
9.22,Bus:1,ID:378,Overun:0,MB:26,Len:8,10,ff,ff,ff,ff,c1,ff,ff
9.22,Bus:1,ID:379,Overun:0,MB:25,Len:8,10,0,0,fc,0,1e,3a,ff
9.22,Bus:1,ID:2a8,Overun:0,MB:32,Len:8,0,0,0,0,0,0,0,ff
9.22,Bus:1,ID:4a4,Overun:0,MB:22,Len:8,ff,f2,39,2,0,0,0,0
9.22,Bus:1,ID:4b6,Overun:0,MB:19,Len:8,3a,39,29,95,30,39,0,0
9.22,Bus:1,ID:1a2,Overun:0,MB:41,Len:8,13,5d,0,0,0,0,fa,0

I still do not quite understand the mask calculation as the mask being calculated for each of the 42 receive mailboxes (for this sample DBC file) that I am setting up is "1FFC0000" which would infer that I "do not care" about the bits I am trying to filter.

For the standard frames to mask does not matter so much but for the extended frame with possible J1939 traffic, I need to understand how the masking work and that seems counter intuitive to me based on the results of this DBC file.

Any insights into the mask calculation?

Anyways thanks for handing in their with me but now seems all systems are go, except understanding the mask calcualtion.

Thanks

Bruce
 
Hi tonton81,
solved my problem by using a different sample point which I took from an Example of a Peak interface: Sample point 83,333 works well for 2MBit, no loss of Messages anymore.

Thanks for always having an open ear for someone elses problems!

Ralph
 
Bruce, the masking is quite complex in FlexCAN, and it is way worse in FIFO mode as the bits are offset. Working on automated masking capability and testing it was quite a bit of work.

What you can try to do is take one standard ID and print out it's mask when you use setmbfilter. once you get that mask, try adding dual ID and you may get an idea of how the bit's are compared

2 IDs for example are 1a0 and 1a2 you have on your bus

setMBFilter(0, 1A0); //check printed mask
setMBFilter(0, 1A0, 1A2); // check printed mask
then see how the bits look like

16 bit baudrate? yeah that can fail miserably, at 1mbps, your baudrate would be 576 :)
 
Bruce, the masking is quite complex in FlexCAN, and it is way worse in FIFO mode as the bits are offset. Working on automated masking capability and testing it was quite a bit of work.

What you can try to do is take one standard ID and print out it's mask when you use setmbfilter. once you get that mask, try adding dual ID and you may get an idea of how the bit's are compared

2 IDs for example are 1a0 and 1a2 you have on your bus

setMBFilter(0, 1A0); //check printed mask
setMBFilter(0, 1A0, 1A2); // check printed mask
then see how the bits look like

Right now I do not plan on masking 11 bit ID only 29 bit/J1939 ID's so that is where I will starts.

Thanks for the patience.

Bruce
 
29 bit mask

So the 29 bit mask looks like

3C0FF
3E315
3FEFC
3FAF4
3FEFF
3FFFF
3FFFF
3FFFF

For the following MB a

CAN 1 RX MB Assignement(#:ID)
RX MB 4 EXT ID: 0:9CFEF803/1:9CFEC703
RX MB 5 EXT ID: 2:98FFFAF9/3:98FFE613
RX MB 6 EXT ID: 4:98FF5903/5:98FF5800
RX MB 7 EXT ID: 6:98FF550B/7:98FF5000
RX MB 8 EXT ID: 8:98FF4F00/9:98FF4E00
RX MB 9 EXT ID: 10:98FF4D00
RX MB 10 EXT ID: 11:98FF3F00
RX MB 11 EXT ID: 12:98FF3D00

So if I have the same source ID I get and "FF" as my low byte of the mask.

So if I want to ignore the SA would the last byte be set to "00"?

Any thoughts?

Thanks

Bruce
 
the SA? last bytes? 00 would let anything in last 8 bits pass, yes, while the upper bits if kept would be checked
 
the SA? last bytes? 00 would let anything in last 8 bits pass, yes, while the upper bits if kept would be checked

SA is source address. Sometimes when just monitoring J1939 you do not care about the source of the message just the PGN of the message.

The last 8 bits of the identifier contain the address of the device transmitting the message. The address is the label or “handle” which is assigned to provide a way to uniquely access a given device on the network. For a given network, every address must be unique (254 available). This means that two different devices (ECUs) cannot use the same address.

Thanks

Bruce
 
Hi tonton81,
if a message is being sent and no partner Acks the message (i.E. you send a FD - Message and the partner doesn't speak FD or vice versa), the message loops forever.
Is there an easy way to reset the MB or tell the transmitter only to try it for a short time and come back with an error?

Thanks

Ralph
 
well yes if they are mis-communicating because of different standards a CRC fail will issue a resend, that is hardware controlled though. You could abort the message but in your loop if you send again you'll just be going around in a rollercoaster. do you control your sends and are they one shot or do you consistantly send frames from your loop?
 
It's just one shot, if there is a timeout because a reply of the ECU is missing, I don't try it over and over again. In the meantime I found out that the .write() comes back with a '0' and I count those negative returns and when it reaches 2 I initialize the MB again. Then the sending loop stops. The message has been sent a hundred times or more, though. Is this the correct way to handle such an issue?

Thanks

Ralph
 
the hardware itself does the resending on CRC fails (like cross-CAN2.0/FD you said you use). Software has no control over resending, this is by hardware design, if it doesn't get an ACK either, it'll keep sending as well. 2 ways to cancel the mailbox sending is to reinit it as TX or abort (not implemented as of yet). However I find the re-init is cleaner and puts it in a known state.

do not forget your transmits are queued and offloaded by isr for performance, so when your count to 2 it means the queue is probably full and when you reset the mailbox an entry is dequeued if isr fires to send next in queue.
 
Last edited:
Hello,
I am trying to receive can messages with a J1939 like protocol. My Ids are 0x10EBFE-SA with SA the source adress.
I would like to receive all messages from 0x10EBFE00 to 0x10EBFEFF in a unique mailbox.
I tryied using setMBUserFilter(MB1, 0x10EBFE00, 0xFFFFFF00) but it seams nothing bleed through filtering.
i also made a few test with in mask 0xF000000, 0xF000F00, 0xF000FF00 and the filtering do what it is supposed to do but with 0x1F000000, 0xFFFF00, 0xFF0000, 0xF0000 I can't receive anything.
Did you have some explanations about how work filtering and masks are some ideas I can try?
 
yet another n00b question.. on IFCT examples there is a sniffer, but filter is available on FlexCAN_T4. i am completely beginner, which one should i use? as from my understanding FlexCAN_T4 is the successor of IFCT and looks highly automated with lot of autodetection (which is very cool btw).

i am looking for a very beginners friendly example code (i have nothing to show)

What i have:
- Teensy 3.2
- VP230 pin 3+4
- CAN-B Baud Rate 83300
- CAN ID 0x0030

What i don't know:
- which example code should i use as base (ino)
- should i apply filter on FIFO or MB
- STD or EXT message

What i want:
I believe it is EXT because the value i want to read seems to be in CAN Message Line 22 offset 24. The desired value is KOMP_STELL according to this text file (if i got this all right)

The project remain read-only as all i need is a watchdog to this single value (which is used as input for output PWM signal on pin6). I am not even sure if MB is a bit overloaded for such task?
 
most people will pick FIFO for simplicity and ordered receptions, the FIFO example with interrupts is a good base to start with. MB is fine if you don't cared about ordered frames on the bus, mostly they will be ordered because they are read pretty fast by interrupt, FlexCAN_T4 is the successor of IFCT and supports all 3.x and 4.x teensies. the IFCT examples should work on FlexCAN_T4 as well, provided you change the header include in the sketch, and initiate the FlexCAN_T4 constructor first, along with begin() :)

You should be fine though as in my car i run all 3 busses without filters using FIFO with interrupts, I doubt your handling more traffic than I am and it runs 24/7
 
Thx tonton81 what's the purpose of MB is this required for sending, didn't get the benefit compared to FIFO? By any chance MB is collection for multi frame message or is there some ready to use library/struct for reading such that can handle ISO 15675-2
 
FIFO is RX only, the mailboxes can be used for either transmit or receive. FIFO has ordered frames while mailboxes can receive in any order. If you are looking for consistancy, use FIFO. The FIFO with interrupt example shows you how to send/receive on CAN, you mean isotp? it's part of the library now and example is there too
 
Having enhancedfilter problems on random extended ID's only.

So first question is does enhanced filtering make since for a MB filter with one ID? I think the answer is it does not matter because it should not bleed through,

But for MB filter with multiple ID it should stop any bleed through frames correct?

So as I explained before I am reading in a DBC file and parting out the messages and signals.

From there, based on the DBC file messages ID's I am either setting up STD and/or EXT receive mail boxes (up to 60 based on the # of messages).
If there are more than 60 ID's then I double up the highest value (lowest priority ID's) in the MB filtering.
When I assign the ID(s) to the MB I store what message index(es) are applied to the filter for each of the RX mailboxes.
So when I receive message and the interrupt fires I copy the important frame data to a structure, set a received flag for that structure and clear interrupt. Each controller has it own receive structure. I process the received frame in the loop and clear the flag.
To process the received from I use the receiving MB (tracked for each controller MD filter ID assignment) to find the ID index based on the previous stored information from when the MB filter was set up.
This could be 1 or 2 ID's but the list to search is short.
Then I have a back up binary sort if something fall through the cracks and if the index of the ID applied the filter to not line up with the MB filter.
Based on the received message ID I process the signals in the based on the signal indexes associated with the message ID(or search for the PID and based on the PID process the signals assigned to the PID).

Sorry that was a lot but I wanted you to understand the basic structure of what I was trying to do as I do not want the micro the spend all its time searching for message ID's to find the correct signals/PID to process.

So what I ran the above code with and 500K standard ID's, with 1 traffic source feeding into all the controller on the Teensy it all worked great.

I was playing back more than 600 frames/second of recorded real vehicle data which means the micro was receiving the exact same frames at the same time so the interrupt setting all 3 at the same time. I figured this was a worst case scenario because in reality the incoming frames on each of the CAN controllers would be random.

So I was doing all the above to > 1800 frames per second. I was keeping each time a frame was processed and was outputting a count every 5000 (all 3 can controllers combined.

I was watching SavvyCAN frame send count and every 1600 ish frames I would see another 5000 count output. So after feeding individual frame and verifying the signal calculations against SavvyCAN and running the full bore recorded bus content I felt pretty good.

So then I ventured into confirming the calculations for individual J1939 extended ID's (still using the standard MB filter not user).

Then I lost all confidence. It seems that I am getting random hit and miss with the enhanced filtering. I randomly grabbed some high and low priority ID's and tried but it I can not see any rhyme or reason.

As soon as I comment out the myCAN[channel]->enhanceFilter((FLEXCAN_MAILBOX)i) it goes is received and process correctly.

I double checked the DBC vs what SavvyCAN was sending out by bypassing all the filter and letting binary search find the ID and sure enough as soon as I did that all the ID's were received as expected and processed.

But the whole point of the above I do not want to have the micro spend its' time searing for and ID match in a 60+ ID's every time a message is received. I thought that is was the filtering was meant to avoid. To not have the micro do frivolous clock cycles.

Why do you think the enhanced filtering is hit and miss for extended frames?

Thanks

Bruce
 
enhancedfilter was not meant for custom user filters, only the automatic filtering as it's ID based masking based off ANDing the calculated mask, a custom mask on the other hand, ANDing the mask with the ID might allow it to pass or fail, it wasn't designed for user masking

ex:

a stored id & *same_mask* must == a received id & *same_mask*
 
As I said, I am not using userfilter .

I am uisng
Code:
myCAN[channel]->setMBFilter((FLEXCAN_MAILBOX)i, id1, id2);
myCAN[channel]->setMBFilter((FLEXCAN_MAILBOX)i, id1)
 
Back
Top