🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    M5Dial port A as RX / TX interface for CAN module?

    General
    3
    10
    3.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • U
      uberdweeb
      last edited by

      I am using M5Dial for CAN, using the CAN interface and TWAI type driver on port B, no problem. But now I am trying to interface with two CAN modules and would like to use Port A and PortB. However seems Port A is set for I2C and can't be repurposed. Is there any way to reconfigure Port A to work as just a serial connection so I can use the CAN interface on this port also?

      teastainT 1 Reply Last reply Reply Quote 0
      • teastainT
        teastain @uberdweeb
        last edited by

        @uberdweeb If you are using Arduino IDE you can specify the pins for PortA.

        Cheers, Terry!

        100% M5Stack addict with several drawers full of product!

        1 Reply Last reply Reply Quote 0
        • U
          uberdweeb
          last edited by

          I do something like:
          CAN0.setCANPins(GPIO_NUM_1, GPIO_NUM_2);
          and it works fine but when I do:
          CAN0.setCANPins(GPIO_NUM_15, GPIO_NUM_13);
          it does not work

          and the pins are labeled as being for I2C, so just thinking that there is other circuitry that is blocking RX /TX operation or other software configured to force them in another mode?

          teastainT 1 Reply Last reply Reply Quote 0
          • teastainT
            teastain @uberdweeb
            last edited by

            @uberdweeb said in M5Dial port A as RX / TX interface for CAN module?:

            CAN0.setCANPins(GPIO_NUM_1, GPIO_NUM_2);

            It is just a StampS3 inside and I just wrote a sketch and confirmed that pin15 will turn on an LED when the button '0' is pushed.
            The ESP32 uses an IOMUX to allow almost any pin to have any function.
            Hope this helps, -Terry

            Cheers, Terry!

            100% M5Stack addict with several drawers full of product!

            1 Reply Last reply Reply Quote 0
            • felmueF
              felmue
              last edited by

              Hello @uberdweeb

              hmm, both M5Dial ports (A and B) work for me. I used this CAN example as basis. Below is the beginning of setup():

              void setup()
              {
                auto cfg = M5.config();
                M5Dial.begin(cfg, false, false);
              
                Serial.println("Initializing ...");
              
                CAN0.setCANPins(GPIO_NUM_15, GPIO_NUM_13); // Port A - works
              //  CAN0.setCANPins(GPIO_NUM_1, GPIO_NUM_2); // Port B - works
                CAN0.begin(500000);
              
                Serial.println("Ready ...!");
              

              Thanks
              Felix

              GPIO translation table M5Stack / M5Core2
              Information about various M5Stack products.
              Code examples

              1 Reply Last reply Reply Quote 0
              • U
                uberdweeb
                last edited by

                Thanks for the advice @teastain and @felmue !
                Did that code compile for you or did you confirm that you were able to get actual CAN traffic on either port? When I tried it I got a few CAN msgs and then no more. Port B worked 100%

                I did a test with the 2 relay board on Port A, GPIO 15 and 13 and it does work just fine...

                1 Reply Last reply Reply Quote 0
                • felmueF
                  felmue
                  last edited by

                  Hello @uberdweeb

                  the code compiled for me after disabling the SPI chips using CAN1. I also removed all mcp* files from the libray's src directory. And yes, I successfully tested sending messages back and forth using either port.

                  Which CAN library are you using?

                  Thanks
                  Felix

                  GPIO translation table M5Stack / M5Core2
                  Information about various M5Stack products.
                  Code examples

                  1 Reply Last reply Reply Quote 0
                  • U
                    uberdweeb
                    last edited by

                    I am using Collin Kidder's CAN library, and no mcp stuff as I believe this is the SPI based CAN modules. This library:
                    https://github.com/collin80/esp32_can
                    If there is another that is more compatible please let me know.

                    Maybe there is more I need to do so it doesn't attempt to do any SPI on that port?

                    1 Reply Last reply Reply Quote 0
                    • felmueF
                      felmue
                      last edited by

                      Hello @uberdweeb

                      I understand in using this library you can successfully transmit data using port B but not port A, correct? That should mean the library itself works ok.

                      What speed are you trying to use? I successfully tested with 125kBits and 500kBits.

                      Thanks
                      Felix

                      GPIO translation table M5Stack / M5Core2
                      Information about various M5Stack products.
                      Code examples

                      1 Reply Last reply Reply Quote 0
                      • U
                        uberdweeb
                        last edited by

                        Yes, the program works great on port B but not port A. Library has been great and solid. If I change the code I might get a few CAN messages (like 21-22) but then it stops. That is why I was wondering if something was electrically different in those two ports.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post