pazi88 / STM32_CAN

CAN bus Library for Arduino STM32
GNU General Public License v3.0
67 stars 28 forks source link

Is there possibility to switch between CAN ALT and DEF during runtime? #23

Open johnnykow1234 opened 8 months ago

johnnykow1234 commented 8 months ago

I have very interesting Board with STM32F105RBT6 chip which has... three cans. On the board i have three transceivers and these are connected to the chip in the following way:

I wrote some code for that. Here is the setup part


STM32_CAN first(CAN1, ALT);
STM32_CAN second(CAN2, DEF);
STM32_CAN third(CAN2, ALT);

void setup() {
  first.begin(false);
  first.setBaudRate(125000);

  second.begin(false);
  second.setBaudRate(500000);  //500KBPS

  third.begin(false);
  third.setBaudRate(500000);  //500KBPS
}

And obviously the first one and the second one work without any issues. The third one is dead. Theoretically the board is running fine, but there are no messages on the can bus from the third one (i have arduino based board connected to it and i am sniffing messages).

The question is: is there any way to make that working with that library? I have no doubts that it can work in some way because the board was previously used as a OBD tool - i just deciced to transform it to some other device.

michpro commented 2 months ago

The STM32F105RB datasheet clearly informs that it has TWO CAN interfaces, not THREE. You yourself wrote "PB5/PB6 - CAN2 ALT" ... these are alternate pins for CAN2, not the third CAN interface, so CAN2 can be connected to pins PB12/PB13 or PB5/PB6 but never to both pairs at the same time.