M5Dial port A as RX / TX interface for CAN module?
-
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?
-
@uberdweeb If you are using Arduino IDE you can specify the pins for PortA.
-
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 workand 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?
-
@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 -
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 -
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...
-
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 -
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?
-
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 -
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.