Forum Rule: Always post complete source code & details to reproduce any issue!
Page 30 of 36 FirstFirst ... 20 28 29 30 31 32 ... LastLast
Results 726 to 750 of 886

Thread: FlexCAN_T4 - FlexCAN for Teensy 4

  1. #726
    Senior Member
    Join Date
    Feb 2015
    Posts
    155

    Yeah, missed that one...

    Quote Originally Posted by tonton81 View Post
    Code:
    class FlexCAN_T4_Base {
      public:
        virtual void flexcan_interrupt() = 0;
        virtual void setBaudRate(uint32_t baud = 1000000, FLEXCAN_RXTX listen_only = TX) = 0;
        virtual uint64_t events() = 0;
        virtual int write(const CANFD_message_t &msg) = 0;
        virtual int write(const CAN_message_t &msg) = 0;
        virtual bool isFD() = 0;
        virtual uint8_t getFirstTxBoxSize();
    };
    it's already there, did you duplicate it? Only reason it's there is because setClock uses it to reconfigure baudrate on a new controller clock switch
    Yeah, I duplicated it...missed it.

    Does it matter which one is included?
    [CODE] virtual void onReceive(const FLEXCAN_MAILBOX &mb_num, _MB_ptr handler) = 0; /* individual mailbox callback function */
    //virtual void onReceive(_MB_ptr handler) = 0; /* global callback function */[/CODE

    I do not think it does but just checking.

    Thanks

    Bruce

  2. #727
    Senior Member
    Join Date
    Feb 2015
    Posts
    155
    Code:
      for (int i = 0; i<NUM_TX_MAILBOXES; i++)
      {
        if (bus[CanChannels].STDFrame == 0)
        {
          myCAN[channel]->setMB(i,TX,EXT);
        }
    Then the compiler complains

    6_CANFunctions.h: In function 'bool SetCAN(uint8_t)':
    C:\Users\bvernham\AppData\Local\Temp\arduino_build _605453\sketch\6_CANFunctions.h:97:37: warning: invalid conversion from 'int' to 'FLEXCAN_MAILBOX' [-fpermissive]
    myCAN[channel]->setMB(i,TX,EXT);
    ^
    In file included from C:\Users\bvernham\Dropbox (Isuzu North America)\Personal Backup\Arduino\ReadDBCV1\ReadDBCV1.ino:4:0:
    C:\Users\bvernham\Dropbox (Isuzu North America)\Personal Backup\arduino-1.8.13\hardware\teensy\avr\libraries\FlexCAN_T4/FlexCAN_T4.h:324:18: note: initializing argument 1 of 'virtual bool FlexCAN_T4_Base::setMB(const FLEXCAN_MAILBOX&, const FLEXCAN_RXTX&, const FLEXCAN_IDE&)'
    virtual bool setMB(const FLEXCAN_MAILBOX &mb_num, const FLEXCAN_RXTX &mb_rx_tx, const FLEXCAN_IDE &ide = STD) = 0;
    ^
    But I know in the header file:

    typedef enum FLEXCAN_MAILBOX {
    MB0 = 0,
    MB1 = 1,
    MB2 = 2,
    MB3 = 3,
    MB4 = 4,
    MB5 = 5,
    MB6 = 6,
    MB7 = 7,
    MB8 = 8,
    MB9 = 9,
    MB10 = 10,
    MB11 = 11,
    MB12 = 12,
    MB13 = 13,
    MB14 = 14,
    MB15 = 15,
    MB16 = 16,
    MB17 = 17,
    MB18 = 18,
    MB19 = 19,
    MB20 = 20,
    MB21 = 21,
    MB22 = 22,
    So in reality the enumeration is referencing an integer anyways so how do you get around the enumeration and just use and integer?

    Thanks

    Bruce

  3. #728
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,905
    Cast:
    (FLEXCAN_MAILBOX)myCAN[channel]->setMB(i,TX,EXT)

  4. #729
    Senior Member
    Join Date
    Feb 2015
    Posts
    155
    Quote Originally Posted by tonton81 View Post
    Cast:
    (FLEXCAN_MAILBOX)myCAN[channel]->setMB(i,TX,EXT)
    Duh... But I think you mean:

    myCAN[channel]->setMB((FLEXCAN_MAILBOX)i,RX,STD);?

    Thanks

    Bruce

  5. #730
    Senior Member
    Join Date
    Feb 2015
    Posts
    155
    Just in case anyone is interested this is where I have gotten so far:
    CAN1.dbc
    CAN2.dbc
    CAN3.dbc
    Total Signal Count: 831
    CAN: 1
    Messages: 65
    Baudrate: 500000
    Protocol: J1939
    STD ID: 0
    EXT ID: 65
    DBC Signals: 357
    PID: 0
    CAN: 2
    Messages: 1
    Baudrate: 500000
    Protocol: OBD-2
    STD ID: 1
    EXT ID: 0
    DBC Signals: 149
    PID: 114
    CAN: 3
    Messages: 69
    Baudrate: 500000
    Protocol: Unknown
    STD ID: 69
    EXT ID: 0
    DBC Signals: 325
    PID: 0
    SetCAN: CAN: 1
    DBC Messages: 65, RX Mail Boxes: 60
    STDFrame: 0, EXTFrame: 65
    Num_STD_RX_MB: 0, Num_EXT_RX_MB: 60
    STD_Num_SingMess_MB: 0, EXT_Num_SingMess_MB: 55
    STD_Num_2Mess_MB: 0, EXT_Num_2Mess_MB: 5
    Settting EXT TX MB #: 0 1 2 3
    Settting EXT RX MB #: 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

    SetCAN: CAN: 2
    DBC Messages: 1, RX Mail Boxes: 1
    STDFrame: 1, EXTFrame: 0
    Num_STD_RX_MB: 0, Num_EXT_RX_MB: 0
    STD_Num_SingMess_MB: 1, EXT_Num_SingMess_MB: 0
    STD_Num_2Mess_MB: 0, EXT_Num_2Mess_MB: 0
    Settting STD TX MB #: 0 1 2 3
    Settting STD RX MB #: 4

    SetCAN: CAN: 3
    DBC Messages: 69, RX Mail Boxes: 60
    STDFrame: 69, EXTFrame: 0
    Num_STD_RX_MB: 60, Num_EXT_RX_MB: 0
    STD_Num_SingMess_MB: 51, EXT_Num_SingMess_MB: 0
    STD_Num_2Mess_MB: 9, EXT_Num_2Mess_MB: 0
    Settting STD TX MB #: 0 1 2 3
    Settting STD RX MB #: 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

    Done
    Work with mixed standard and extended in each DBC file.

  6. #731
    Junior Member
    Join Date
    Nov 2019
    Posts
    6
    Good morning. Is there something similar to the myCan.available() function (like in the older FlexCAN library) in this new library? I am using the 4.1 for a new project and I would like to only read in a message when one is waiting. Is there a function like this? Thank you for your time regarding this.
    Code:
    if (Can0.available())
        { // checks if there is a waiting message, if so then it reads it in
          digitalWrite(LED_U5, 0);
          digitalWrite(LED_U9, 1);
    
          while (Can0.read(rxmsg))
          {
    
            lostCommCounter = 0;
            //        Serial.println(CANid);
                  Serial.println("Mask");
                  Serial.println(CANid);
                  Serial.println("ID");
                  Serial.println(rxmsg.id);
            ////      Serial.println("\n");
            //      Serial.println("EXT");
            //      Serial.println(rxmsg.ext);
            //      Serial.println("LENGTH");
            //      Serial.println(rxmsg.len);
            //      Serial.println("timeout");
            //      Serial.println(rxmsg.timeout);
            //      if (CANid == (byte) rxmsg.id)
            //      {
            for (i = 0; i < 8; i++)
            {
              newCANinfo[i] = (byte) rxmsg.buf[i];
              //                      Serial.println(newCANinfo[i]);
              newCANinfoflag = true;
    //          Serial.println(rxmsg.buf[i]);
            }
            //      }
    
            lostComms.reset();
          }
    This is how I used the older FlexCAN on the 3.2

  7. #732
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,905
    what is the point of available() if read() returns 1 if a message is found? if there are no messages then it will return 0.

    now think about this, we could check the IFLAG registers for message flags, but that includes transmits, which means we have to for-loop the non-interrupt message boxes and check for receive only boxes with messages.

    Now, we have to do this again for the read() function as well. Do you want to do double redundant checks?

    that available() i think is for the queue, but why would you check a queue if you are trying to read a mailbox?

  8. #733
    Junior Member
    Join Date
    Nov 2019
    Posts
    6
    Thank you. that helps

    I got the available() use from an example in the old libraries github page. If it is unnecessary, I don't need it.

  9. #734
    Senior Member
    Join Date
    Feb 2015
    Posts
    155
    Can you explain the following functions:

    FLEXCAN_EnterFreezeMode

    and

    enableDMA

    Thanks

    Bruce

  10. #735
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,905
    ONLY CAN3 CAN2.0 supports DMA (not FD), it doesn't use interrupts. You are still responsible for using read() periodically to prevent missing frames. Not very ideal if you ask me

    freeze mode halts the controller from operation. this is used only to modify critical registers on the controller that REQUIRE it to be in freeze mode first. Normally, the user does not touch this, the library handles all the configurations.

  11. #736
    Junior Member
    Join Date
    Mar 2021
    Posts
    9
    Hi tonton81, I've been working with FlexCAN_T4 for a while now, using Standard and FD mode.
    My configuration needs 500k in arbitration and 2M in data mode.
    I did not find an example for this constellation so I tested some configuration and ended up with this:

    config.clock = CLK_24MHz;
    config.baudrate = 500000;
    config.baudrateFD = 2000000;
    config.propdelay = 190;
    config.bus_length = 1;
    config.sample = 87.5;

    This works for approx. 99% but unfortunately not 100%. I now have an ECU as communication partner where some messages I should receive are clipped somehow...

    When I do the same with a RPi and socketcan, it works 100% so far. The init string for socketcan is:
    set can0 type can bitrate 500000 sample-point 0.6 sjw 6 dbitrate 2000000 dsample-point 0.8 dsjw 2 fd on.

    Do you have a suggestion for a more precise init of FlexCan for the bitrates 500k/2M?

    Thank you in advance!

    Best regards Ralph

  12. #737
    Senior Member
    Join Date
    Feb 2015
    Posts
    155
    Quote Originally Posted by tonton81 View Post
    freeze mode halts the controller from operation. this is used only to modify critical registers on the controller that REQUIRE it to be in freeze mode first. Normally, the user does not touch this, the library handles all the configurations.
    I am just wondering if FLEXCAN_EnterFreezeMode would help avoid having MB fill up on one controller while another controller or some other device is set up? I envision set up a controller, freezing it while doing the same for all the other controllers, finish setting up everything else then at the bottom set up unfreezing all the controllers.

    That way you doing fall behind before you even start.

    Thanks

    Bruce

  13. #738
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,905
    why would you initialize, disable, initialize, disable, initialize, disable, then all enable? I don't see a use case for that nor will anyone except you use that?

  14. #739
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,905
    Ralsi, you can play with sample point and clock (try 60MHz?)

    are you using interrupts? are you reading events() periodically to prevent missing frames? Tried increasing the constructor's RX buffer?

  15. #740
    Senior Member
    Join Date
    Feb 2015
    Posts
    155

    freeze

    Quote Originally Posted by tonton81 View Post
    why would you initialize, disable, initialize, disable, initialize, disable, then all enable? I don't see a use case for that nor will anyone except you use that?
    So the whole system (other than just the CAN) can be set up before filling up all the MB with message which will call an interrupt to clear it.

  16. #741
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,905
    setup CAN last then?

  17. #742
    Junior Member
    Join Date
    Jun 2021
    Posts
    1

    FlexCAN_T4 - FlexCAN for Teensy 4.1 with SN65HVD230

    Hi,
    I have this setup: https://imgur.com/a/iwCOfs5

    Can someone provide me a code sample to send something like e.g. the ASCII-Table from CAN1 to CAN2 on one Teensy 4.1. After recieving the answer send it to the serial port. I don't have some loggers or analyzing tools for the can bus. I just wanted to check out if the can bus is useable to me. For a quick test I ordered 5 parts SN65HVD230 @ amazon and now nothink works.

    The wiring and the setup:
    https://imgur.com/a/iwCOfs5

    Thanks a lot!

  18. #743
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,905
    use the new isotp integration in FlexCAN_T4. It can send/receive payloads between multiple teensies. Examples are on the repo, and it's currently running in my car project receiving isotp payloads from an ESP32

  19. #744
    Senior Member
    Join Date
    Feb 2015
    Posts
    155

    OK...I am stumped.

    By set up and CAN sourced are confirmed with the examples so I do not think that is the issue.

    Read in the DBC file and set the filters. There are only 45 ID's so 1 ID per filter.

    Set the common "onReceive" function. Store the selected msg data in a structure (one per active controller) and nothing.

    Should the mask be set to "07FF" for standard frames?

    No quite sure why I can not get an response?

    Code snippet is below:
    Code:
    static FlexCAN_T4_Base* myCAN[3] = { nullptr };
    FlexCAN_T4<CAN1, RX_SIZE_2, TX_SIZE_16> Can1;
    FlexCAN_T4<CAN2, RX_SIZE_2, TX_SIZE_16> Can2;
    FlexCAN_T4<CAN3, RX_SIZE_2, TX_SIZE_16> Can3;
    
    
    bool StartCAN()
    {
      myCAN[0] = &Can1;
      myCAN[1] = &Can2;
      myCAN[2] = &Can3;
    
    for (uint8_t j = 0; j < CanChannels; j++)
      {
        if (counts.messagecnt[j] > 0)
        {
          if (!SetCAN(j))
          {
    #ifdef CANInitDebug
            cout << F("SetCAN Channel ") << (uint16_t)j << F(" NG") << endl;
    #endif
            counts.messagecnt[j] = 0;///disable channel for the rest of the process.
            return false;
          }
          myCAN[j]->onReceive(canRecv);//set global call pack for each
        }
      }
      return true;
    }
    bool SetCAN(uint8_t channel)
    {
    
        myCAN[channel]->begin();
        myCAN[channel]->setClock(CAN_Clock);
        myCAN[channel]->disableFIFO();
        myCAN[channel]->setMBFilter(REJECT_ALL);
        myCAN[channel]->setBaudRate((uint16_t)(bus[channel].BaudRate * 500));
        myCAN[channel]->setMaxMB(NUM_TX_MAILBOXES + Num_Tot_RX_MB);
    ...
    set in a loop
    myCAN[channel]->setMB((FLEXCAN_MAILBOX)i, TX, STD)
    set in a loop
    myCAN[channel]->setMB((FLEXCAN_MAILBOX)i, RX, STD)
    ...
    myCAN[channel]->setMBUserFilter((FLEXCAN_MAILBOX)i, messages[channel][messcnt].ID, MAX_Std_ID)
    myCAN[channel]->enhanceFilter((FLEXCAN_MAILBOX)i);
    
    
    void canRecv(const CAN_message_t &msg) // global callback
    {
      uint8_t busidx =  msg.bus - 1;
      GotData = true;//set data recieved flag
      cout << F("Got Frame") << endl;
      recvFrame[busidx].newFrame = true; //indicate if new frame data is recieved.
      recvFrame[busidx].id = msg.id;          // can identifier
      recvFrame[busidx].overrun = msg.flags.overrun; // message overrun
      recvFrame[busidx].len = msg.len;      // length of data
      memcpy(recvFrame[busidx].buf, msg.buf, sizeof(msg.buf[0])*msg.len);
      //uint8_t buf[8] = { 0 };       // data
      recvFrame[busidx].mb = msg.mb;       // used to identify mailbox reception
      //recvFrame.bus = msg.bus;      // used to identify where the message came from when events() is used.
      return;
    }
    
    myCAN[j]->enableMBInterrupts();//set interrupts for each active controller
    I attached my code in case you can take a look.

    CAN set up is all in one tab.

    Mailboxstatus gives me:

    FIFO Disabled
    Mailboxes:
    MB0 code: TX_INACTIVE
    MB1 code: TX_INACTIVE
    MB2 code: TX_INACTIVE
    MB3 code: TX_INACTIVE
    MB4 code: RX_EMPTY (Standard Frame)
    MB5 code: RX_EMPTY (Standard Frame)
    MB6 code: RX_EMPTY (Standard Frame)
    MB7 code: RX_EMPTY (Standard Frame)
    MB8 code: RX_EMPTY (Standard Frame)
    MB9 code: RX_EMPTY (Standard Frame)
    MB10 code: RX_EMPTY (Standard Frame)
    MB11 code: RX_EMPTY (Standard Frame)
    MB12 code: RX_EMPTY (Standard Frame)
    MB13 code: RX_EMPTY (Standard Frame)
    MB14 code: RX_EMPTY (Standard Frame)
    MB15 code: RX_EMPTY (Standard Frame)
    MB16 code: RX_EMPTY (Standard Frame)
    MB17 code: RX_EMPTY (Standard Frame)
    MB18 code: RX_EMPTY (Standard Frame)
    MB19 code: RX_EMPTY (Standard Frame)
    MB20 code: RX_EMPTY (Standard Frame)
    MB21 code: RX_EMPTY (Standard Frame)
    MB22 code: RX_EMPTY (Standard Frame)
    MB23 code: RX_EMPTY (Standard Frame)
    MB24 code: RX_EMPTY (Standard Frame)
    MB25 code: RX_EMPTY (Standard Frame)
    MB26 code: RX_EMPTY (Standard Frame)
    MB27 code: RX_EMPTY (Standard Frame)
    MB28 code: RX_EMPTY (Standard Frame)
    MB29 code: RX_EMPTY (Standard Frame)
    MB30 code: RX_EMPTY (Standard Frame)
    MB31 code: RX_EMPTY (Standard Frame)
    MB32 code: RX_EMPTY (Standard Frame)
    MB33 code: RX_EMPTY (Standard Frame)
    MB34 code: RX_EMPTY (Standard Frame)
    MB35 code: RX_EMPTY (Standard Frame)
    MB36 code: RX_EMPTY (Standard Frame)
    MB37 code: RX_EMPTY (Standard Frame)
    MB38 code: RX_EMPTY (Standard Frame)
    MB39 code: RX_EMPTY (Standard Frame)
    MB40 code: RX_EMPTY (Standard Frame)
    MB41 code: RX_EMPTY (Standard Frame)
    MB42 code: RX_EMPTY (Standard Frame)
    MB43 code: RX_EMPTY (Standard Frame)
    MB44 code: RX_EMPTY (Standard Frame)
    MB45 code: RX_EMPTY (Standard Frame)
    Thanks

    Bruce
    Attached Files Attached Files

  20. #745
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,905
    why are you using setMBUserFilter? use the intended setMBFilter .

    Also setMaxMB should be set before setMBFilters
    Better yet you should be testing this with the simple demo before implementing it on a huge code, at least to see if you got the filter worked out

  21. #746
    Senior Member
    Join Date
    Feb 2015
    Posts
    155
    Quote Originally Posted by tonton81 View Post
    why are you using setMBUserFilter? use the intended setMBFilter .

    Also setMaxMB should be set before setMBFilters
    Better yet you should be testing this with the simple demo before implementing it on a huge code, at least to see if you got the filter worked out

    I am using setMBUserFilter so I can use the mask so I can eventually do J1939 ID filtering (not implemented yet). This is why I am trying to grab the protocol type from the DBC file.

    As you can see in the code snippet below setmaxmb is set after baud rate before setting up the MB type for setting up the filter.

    So I set the max MB and MB type based the ID count/type on the then set the user filters based on the DBC file ID's.

    Is there a way to check the status of the MB interrupt like the FIFO interrupt?

    Thanks

    Bruce

  22. #747
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,905
    did you check first on a simple sketch to see if you can receive that frame with and without a filter?

  23. #748
    Senior Member
    Join Date
    Feb 2015
    Posts
    155

    Yes

    Quote Originally Posted by tonton81 View Post
    did you check first on a simple sketch to see if you can receive that frame with and without a filter?
    I used one of the FIFO examples to confirm my CAN bus hardware is good.

    I am using SavvyCAN and GRVET hardware. Thanks Collin. He has help me with Due CAN also.

    Anyways so then I went for it.

    So now I fell back to the MB with interrupt example but modified for the CAN traffic I have.

    Code:
    #include <FlexCAN_T4.h>
    FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> Can0;
    
    #define NUM_TX_MAILBOXES 2
    #define NUM_RX_MAILBOXES 4
    void setup(void) {
      Serial.begin(115200); delay(400);
      // Wait for USB Serial
      while (!Serial) {
        yield();
      }
      Serial.println(F("Type any character to start"));
      while (!Serial.available()) {
        yield();
      }
      
      Can0.begin();
      Can0.disableFIFO();
      Can0.setBaudRate(500000);
      Can0.setMaxMB(NUM_TX_MAILBOXES + NUM_RX_MAILBOXES);
      for (int i = 0; i<NUM_RX_MAILBOXES; i++){
        Can0.setMB((FLEXCAN_MAILBOX)i,RX,STD);
      }
      for (int i = NUM_RX_MAILBOXES; i<(NUM_TX_MAILBOXES + NUM_RX_MAILBOXES); i++){
        Can0.setMB((FLEXCAN_MAILBOX)i,TX,STD);
      }
      Can0.setMBFilter(REJECT_ALL);
      Can0.enableMBInterrupts();
    /*  Can0.onReceive(MB0,canSniff);
      Can0.onReceive(MB1,canSniff);*/
      Can0.onReceive(canSniff);
      Can0.setMBUserFilter(MB0,0x1A2,0x7FF);
      Can0.setMBUserFilter(MB1,0x1A0,0x7FF);
      Can0.setMBUserFilter(MB2,0x378,0x7FF);
      Can0.setMBUserFilter(MB3,0x379,0x7FF);
      Can0.mailboxStatus();
    }
    Well I have traffic not but no filtering"

    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 31944 ID: 379 Buffer: 10 0 0 FC 0 1E 3B FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 32292 ID: 1B5 Buffer: CC 1 5 90 22 20 22 20
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 32611 ID: 4BC Buffer: 0 0 0 12 27 10 0 0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 32737 ID: 2B6 Buffer: 28 7D 4 E0 28 7D 4 E0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 32859 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 34309 ID: 1A2 Buffer: 13 5E 0 0 0 0 FA 0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 34433 ID: 1B7 Buffer: 0 0 0 FF FF 0 FF FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 37075 ID: 1A0 Buffer: F9 0 0 0 0 0 0 0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 37309 ID: 1B3 Buffer: C6 32 0 0 7D 0 0 FC
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 37433 ID: 4BE Buffer: 0 0 0 0 0 0 0 0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 37563 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 37690 ID: 2A8 Buffer: 0 0 0 0 0 0 0 FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 37825 ID: 4B6 Buffer: 3A 39 29 95 30 39 0 0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 39310 ID: 1A2 Buffer: 13 5E 0 0 0 0 FA 0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 41841 ID: 1A0 Buffer: F9 0 0 0 0 0 0 0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 41969 ID: 379 Buffer: 10 0 0 FC 0 1E 3B FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 42273 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 42400 ID: 2B0 Buffer: E5 39 3A 10 24 40 24 A0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 44622 ID: 1A2 Buffer: 13 5F 0 0 0 0 FA 0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 48068 ID: 2B2 Buffer: FF FF FF FF FF 7F 1F 1F
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 48194 ID: 1A0 Buffer: F9 0 0 0 0 0 0 0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 48322 ID: 1B3 Buffer: C6 32 0 0 7D 0 0 FC
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 48446 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 49202 ID: 1A2 Buffer: 13 5F 0 0 0 0 FA 0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 51823 ID: 1A0 Buffer: F9 0 0 0 0 0 0 0
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 51951 ID: 379 Buffer: 10 0 0 FC 0 1E 3B FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 52219 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 52415 ID: 2B4 Buffer: FF FF FF FF FF 7F 1F 1F
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 54824 ID: 1A2 Buffer: 13 5F 0 0 0 0 FA 0
    Everything is captured in MB0.

    I switch to the standard setMBFilter and magic:

    FIFO Disabled
    Mailboxes:
    MB0 code: RX_EMPTY (Standard Frame)
    MB1 code: RX_EMPTY (Standard Frame)
    MB2 code: RX_EMPTY (Standard Frame)
    MB3 code: RX_EMPTY (Standard Frame)
    MB4 code: TX_INACTIVE
    MB5 code: TX_INACTIVE
    MB 1 OVERRUN: 0 LEN: 8 EXT: 0 TS: 52561 ID: 1A0 Buffer: F9 0 0 0 0 0 0 0
    MB 2 OVERRUN: 0 LEN: 8 EXT: 0 TS: 52812 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 3 OVERRUN: 0 LEN: 8 EXT: 0 TS: 53338 ID: 379 Buffer: 10 0 0 FC 0 1E 3A FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 54340 ID: 1A2 Buffer: 13 5E 0 0 0 0 FA 0
    MB 1 OVERRUN: 0 LEN: 8 EXT: 0 TS: 57255 ID: 1A0 Buffer: F9 0 0 0 0 0 0 0
    MB 2 OVERRUN: 0 LEN: 8 EXT: 0 TS: 57507 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 59372 ID: 1A2 Buffer: 13 5E 0 0 0 0 FA 0
    MB 1 OVERRUN: 0 LEN: 8 EXT: 0 TS: 61872 ID: 1A0 Buffer: F9 0 0 0 0 0 0 0
    MB 2 OVERRUN: 0 LEN: 8 EXT: 0 TS: 62389 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 3 OVERRUN: 0 LEN: 8 EXT: 0 TS: 63472 ID: 379 Buffer: 10 0 0 FC 0 1E 3A FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 64468 ID: 1A2 Buffer: 13 5E 0 0 0 0 FA 0
    MB 1 OVERRUN: 0 LEN: 8 EXT: 0 TS: 2407 ID: 1A0 Buffer: F9 0 0 0 0 0 0 0
    MB 2 OVERRUN: 0 LEN: 8 EXT: 0 TS: 2785 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 3852 ID: 1A2 Buffer: 13 5E 0 0 0 0 FA 0
    MB 1 OVERRUN: 0 LEN: 8 EXT: 0 TS: 6268 ID: 1A0 Buffer: F9 0 0 0 0 0 0 0
    MB 2 OVERRUN: 0 LEN: 8 EXT: 0 TS: 6749 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 3 OVERRUN: 0 LEN: 8 EXT: 0 TS: 7777 ID: 379 Buffer: 10 0 0 FC 0 1E 3A FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 8984 ID: 1A2 Buffer: 13 5E 0 0 0 0 FA 0
    MB 1 OVERRUN: 0 LEN: 8 EXT: 0 TS: 11803 ID: 1A0 Buffer: F9 0 0 0 0 0 0 0
    MB 2 OVERRUN: 0 LEN: 8 EXT: 0 TS: 12410 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 13879 ID: 1A2 Buffer: 13 5E 0 0 0 0 FA 0
    MB 1 OVERRUN: 0 LEN: 8 EXT: 0 TS: 17642 ID: 1A0 Buffer: F9 0 0 0 0 0 0 0
    MB 2 OVERRUN: 0 LEN: 8 EXT: 0 TS: 17770 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 3 OVERRUN: 0 LEN: 8 EXT: 0 TS: 18006 ID: 379 Buffer: 10 0 0 FC 0 1E 3A FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 19282 ID: 1A2 Buffer: 13 5E 0 0 0 0 FA 0
    MB 1 OVERRUN: 0 LEN: 8 EXT: 0 TS: 21723 ID: 1A0 Buffer: F9 0 0 0 0 0 0 0
    MB 2 OVERRUN: 0 LEN: 8 EXT: 0 TS: 22634 ID: 378 Buffer: 10 FF FF FF FF C1 FF FF
    MB 0 OVERRUN: 0 LEN: 8 EXT: 0 TS: 24770 ID: 1A2 Buffer: 13 5E 0 0 0 0 FA 0
    So in the example the "user" filter does not filter but that still does not help me figure out why I do not have an interrupt fire in my code????

    Thanks

    Bruce

  24. #749
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,905
    the User filter you may be doing it wrong. the last example used on repo used 0xFF to match the last 8 bits of listed CAN frames.

    what happens if you set it to 0? 0 is pass through and each bits is checked if used if > 0

    if setMBfilter works it means the mask is wrong in your user filter. the only difference between setmbfilter and setmbuserfilter is one calculates the mask automatically and the other uses your own mask...

  25. #750
    Senior Member
    Join Date
    Feb 2015
    Posts
    155
    For the std frame I was using 0x7ff as the mask in the example. In my code I did both 0x7ff and 0...neither worked. Could it have something to do with "enhance filter". As you can see above in the example I had one std Id with 0x7ff as the Mask and it did not filter

    Thanks Bruce

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •