filter_match(FLEXCAN_MAILBOX mb_num, uint32_t id)
mb_filter_table[mb_num][i+1]
id == mb_filter_table[mb_num][i+1]
CF00400/CF00400
Got Frame CAN2
18.309938,Bus:2,ID:CF00400,Overun:false,MB:56,Len:8,30,0,0,0,1C,0,0,0
Engine_Demand_Percent_Torque: UINT32_T 0 -, Source_Address_of_Controller_Dev: UINT32_T 0 -, Engine_speed:896.0000 rpm, Actual_Engine_Percent_Torque:-125.0000 %, Drivers_Demand_Engine_Percent_To:-125.0000 %, Engine_and_Retarder_Torque_Mode: UINT32_T 0 -,
18FEFB03/18FED900
CAN 2 RX MB Assignement(MB Type|MB#:ID)
4 : FF | 0 : 1CFEF803,1CFEF803/1 : 1CFEBE00,1CFEBE00
5 : FF | 2 : 1CECFF0B,1CECFF0B/3 : 1CECFF00,1CECFF00
6 : FF | 4 : 1CEBFF0B,1CEBFF0B/5 : 1CEBFF03,1CEBFF03
7 : FF | 6 : 1CEBFF00,1CEBFF00/7 : 18FF5800,18FF5800
8 : FF | 8 : 18FF5000,18FF5000/9 : 18FF4F00,18FF4F00
9 : FF | 10 : 18FF4E00,18FF4E00/11 : 18FF4D00,18FF4D00
10 : FF | 12 : 18FF3F00,18FF3F00/13 : 18FF3D00,18FF3D00
11 : FF | 14 : 18FF3C00,18FF3C00/15 : 18FF3B00,18FF3B00
12 : FF | 16 : 18FF3A00,18FF3A00/17 : 18FF3900,18FF3900
13 : FF | 18 : 18FF3800,18FF3800/19 : 18FF3700,18FF3700
14 : FF | 20 : 18FF3600,18FF3600/21 : 18FF3300,18FF3300
15 : FF | 22 : 18FF3018,18FF3018/23 : 18FF2A17,18FF2A17
16 : FF | 24 : 18FF2517,18FF2517/25 : 18FF2300,18FF2300
17 : FF | 26 : 18FF1702,18FF1702/27 : 18FF1002,18FF1002
18 : FF | 28 : 18FF1000,18FF1000/29 : 18FF0B00,18FF0B00
19 : FF | 30 : 18FF0A00,18FF0A00/31 : 18FF0900,18FF0900
20 : FF | 32 : 18FF0800,18FF0800/33 : 18FF0700,18FF0700
21 : FF | 34 : 18FF0300,18FF0300/35 : 18FF0200,18FF0200
22 : FF | 36 : 18FF0000,18FF0000/37 : 18FEFB03,18FEFB03
23 : FF | 38 : 18FEF117,18FEF117/39 : 18FEF10B,18FEF10B
24 : FF | 40 : 18FEF100,18FEF100/41 : 18FEEE00,18FEEE00
25 : FF | 42 : 18FEEB0B,18FEEB0B/43 : 18FEEB03,18FEEB03
26 : F0 | 44 : 18FEE518,18FEE518
27 : F0 | 45 : 18FEE203,18FEE203
28 : F0 | 46 : 18FEDF00,18FEDF00
29 : F0 | 47 : 18FEDA0B,18FEDA0B
30 : F0 | 48 : 18FEDA03,18FEDA03
31 : F0 | 49 : 18FED900,18FED900
32 : F0 | 50 : 18FECA0B,18FECA0B
33 : F0 | 51 : 18FECA03,18FECA03
34 : F0 | 52 : 18FEBF0B,18FEBF0B
35 : F0 | 53 : 18FEAE17,18FEAE17
36 : F0 | 54 : 18FE4B03,18FE4B03
37 : F0 | 55 : 18FE4A03,18FE4A03
38 : F0 | 56 : 18FDA403,18FDA403
39 : F0 | 57 : 18FDA400,18FDA400
40 : F0 | 58 : 18FD9503,18FD9503
41 : F0 | 59 : 18FD7C00,18FD7C00
42 : F0 | 60 : 18F00C03,18F00C03
43 : F0 | 61 : 18F00503,18F00503
44 : F0 | 62 : 18F0010B,18F0010B
45 : F0 | 63 : 18F00029,18F00029
46 : F0 | 64 : 18EF1817,18EF1817
47 : F0 | 65 : 18EF1718,18EF1718
48 : F0 | 66 : 18EF1700,18EF1700
49 : F0 | 67 : 18EF0503,18EF0503
50 : F0 | 68 : 18EF0017,18EF0017
51 : F0 | 69 : 18EEFF0B,18EEFF0B
52 : F0 | 70 : 18EEFF03,18EEFF03
53 : F0 | 71 : 18EAFF0B,18EAFF0B
54 : F0 | 72 : 18EAFF03,18EAFF03
55 : F0 | 73 : CFF0100,CFF0100
56 : F0 | 74 : CF00400,CF00400
57 : F0 | 75 : CF00300,CF00300
58 : F0 | 76 : CF00203,CF00203
59 : F0 | 77 : C01030B,C01030B
60 : F0 | 78 : C00290B,C00290B
61 : F0 | 79 : C000012,C000012
62 : F0 | 80 : C000003,C000003
63 : F0 | 81 : 8FE6E0B,8FE6E0B
18FF5000/18FF4E00
18FF4F00/18FF4E00
FCTP_FUNC bool FCTP_OPT::setMBFilter(FLEXCAN_MAILBOX mb_num, uint32_t id1, uint32_t id2) {
Serial.print(id1,HEX);Serial.print(F("/"));Serial.println(id2,HEX);
if ( mb_num < mailboxOffset() || mb_num >= FLEXCANb_MAXMB_SIZE(_bus) ) return 0; /* mailbox not available */
if ( (FLEXCAN_get_code(FLEXCANb_MBn_CS(_bus, mb_num)) >> 3) ) return 0; /* exit on TX mailbox */
uint32_t mask = ( !(FLEXCANb_MBn_CS(_bus, mb_num) & FLEXCAN_MB_CS_IDE) ) ? FLEXCAN_MB_ID_IDSTD(((id1 | id2) ^ (id1 & id2)) ^ 0x7FF) : FLEXCAN_MB_ID_IDEXT(((id1 | id2) ^ (id1 & id2)) ^ 0x1FFFFFFF);
setMBFilterProcessing(mb_num,id1,mask);
Serial.print(id1,HEX);Serial.print(F("/"));Serial.println(id2,HEX);
filter_store(FLEXCAN_MULTI, mb_num, 2, id1, id2, 0, 0, 0);
return 1;
}
18FF4E00/18FF4D00
18FF4E00/18FF4D00
9 : FF | 10 : 18FF4E00,18FF4E00/11 : 18FF4D00,18FF4D00
filter_store(FLEXCAN_MULTI, mb_num, 2, id1, id2, 0, 0, 0);
FCTP_FUNC volatile bool FCTP_OPT::filter_match(FLEXCAN_MAILBOX mb_num, uint32_t id) {
if ( !(mb_filter_table[mb_num][0] & 0x10000000) ) return 1;
if ( (mb_filter_table[mb_num][0] >> 29) == FLEXCAN_MULTI ) {
for ( uint8_t i = 0; i < ((mb_filter_table[mb_num][0] & 0x380) >> 7); i++)
{
Serial.print(mb_filter_table[mb_num][i+1],HEX);Serial.print(F("/"));
Serial.println(id,HEX);
if ( id == mb_filter_table[mb_num][i+1] ) return 1;
}
}
else if ( (mb_filter_table[mb_num][0] >> 29) == FLEXCAN_RANGE ) {
if ( id >= mb_filter_table[mb_num][1] && id <= mb_filter_table[mb_num][2] ) return 1;
}
else if ( (mb_filter_table[mb_num][0] >> 29) == FLEXCAN_USERMASK ) {
for ( uint8_t i = 1; i < ((mb_filter_table[mb_num][0] & 0x380) >> 7) + 1; i++) {
if ( (id & mb_filter_table[mb_num][5]) == (mb_filter_table[mb_num][i] & mb_filter_table[mb_num][5]) ) return 1;
}
}
return 0;
}
18FF5000/18FF4E00
18FF4F00/18FF4E00
mb_filter_table[mb_num][i+1]
volatile uint32_t mb_filter_table[64][6];
cout << F("RX MB ") << dec << (uint16_t)(i);
if (mb[j][i].single & MBSingEXTOffset) cout << F(" EXT");//Extended Recieve Frame
else cout << F(" STD");//Starndard Recieve Frame
cout << F(" ID: ");
if ((mb[j][i].single & MBSingMultiOffset)) {
cout << dec << (uint16_t)mb[j][i].StartMessage << F(":") << uppercase << hex << messages[j][mb[j][i].StartMessage].ID << F(",") << Can2.mb_filter_table[i][1] << F("/") << dec << (uint16_t)mb[j][i].EndMessage << F(":") << uppercase << hex << messages[j][mb[j][i].EndMessage].ID << F(",") << Can2.mb_filter_table[i][2] << endl; //two ID Filter MB
}
else cout << dec << (uint16_t)mb[j][i].StartMessage << F(":") << uppercase << hex << messages[j][mb[j][i].StartMessage].ID << F(",") << Can2.mb_filter_table[i][1]<< endl; //Single ID Filtered MB
}
cout << endl;
virtual volatile uint32_t mb_filter_table[64][6] = 0;
mb:8|18FF5000/18FF4D00
mb:8|18FF4F00/18FF4D00
So when I power up the controller and initialize everything I get nothing out of CAN3 (either by itself or in conjunction with the other two controllers). The other two controllers receive messages as expected.
But if after the power cycle and do not receive any messages from CAN I hit the "program button" and re-flash the same previously compiled code, CAN3 magically works.
#define CAN_Clock CLK_60MHz //Enumeration for CAN clock speed.
How his this done?try changing NVIC priority for CAN3?
I used "accept_all" to determine is was something with the filter because if I accept all messages are always received. The MB filters work as expected for CAN1 and CAN2 but for CAN3 it acts as I described above.does it work sometimes or not at all with the filters?
60 ohms as expected (I have terminating resistors that can be enabled with jumper on the board.try to check the line termination
One MCP2562FD removed...new MCP2562FD installed. Same result. Lucky everything on my board is DIP and socketedtry to check the line termination
bool error(CAN_error_t &error, bool printDetails);
Circular_Buffer<uint32_t, 16> busESR1;
Circular_Buffer<uint16_t, 16> busECR;
void printErrors(const CAN_error_t &error);
So just to confirm, for CAN3, it only shows this symptom only when using filtering, and works perfect otherwise?
Nope, CAN3 does it all by itself does the same thing.do you experience this issue when only CAN3 is initialized and not the other 2?
myCAN[channel]->begin();
myCAN[channel]->setClock(CAN_Clock);
myCAN[channel]->disableFIFO();
myCAN[channel]->setMBFilter(REJECT_ALL);
myCAN[channel]->setBaudRate((bus[channel].BaudRate * 500));
myCAN[channel]->distribute();
myCAN[channel]->setMaxMB(NUM_TX_MAILBOXES + Num_Tot_RX_MB);
CAN_error_t error; /* create a message struct to store the queue details, for data accesses */
if ( Can1.error(error, 1) ) { // overload 1 means internally print everything in error event to serial monitor
// Do Something...
if ( error.ACK_ERR ) Serial.print("ACK error occured");
if ( !strcmp(error.state, "Transmitting") ) Serial.println("TRANSMITTING!");
}
I've added the commits for error reporting, try it out
(me hot-plugging the esp32 and reconnecting)
Code:FlexCAN State: Receiving, FLT_CONF: Error Active FlexCAN State: Idle, FLT_CONF: Error Active FlexCAN State: Transmitting, FLT_CONF: Error Active FlexCAN State: Transmitting, ACK_ERR, FLT_CONF: Error Active FlexCAN State: Transmitting, ACK_ERR, TX_WRN: 96, FLT_CONF: Error Active FlexCAN State: Transmitting, ACK_ERR, TX_WRN: 104, FLT_CONF: Error Active FlexCAN State: Transmitting, ACK_ERR, TX_WRN: 128, FLT_CONF: Bus off FlexCAN State: Transmitting, TX_WRN: 127, FLT_CONF: Error Active FlexCAN State: Transmitting, FLT_CONF: Error Active FlexCAN State: Receiving, FLT_CONF: Error Active FlexCAN State: Idle, FLT_CONF: Error Active FlexCAN State: Transmitting, FLT_CONF: Error Active