...
Method 1
Configure your CAN controller to *NOT* assert the hardware acknowledge.
Connect at one speed and listen .
If you see CAN errors, switch to the other speed.
If you see no CAN errors, reconfigure to enable hardware acknowledge.
Method 2 → Will be attempting this method
Most CAN transceivers have a pin that can put the chip into a listen only mode.
Wire that pin to a micro pin.
Configure the transceiver for listen only.
Configure CAN for one speed and listen.
If you see CAN errors, switch to the other speed.
If you see no CAN errors, toggle the pin to the CAN transceiver to enable the full mode.
Method 3
If the CAN Rx pin on the micro could be configured to grab a hardware timestamp, measure the time of CAN pulses.
It would need to capture many, to ensure it found the smallest pulse.
Compute the bit-rate and configure the CAN controller.
Questions
What hardware is the CAN bus connected to?
Hardware setup for the STM32
Does method 2 seem feasible?
Baudrate options currently using/will need?
How do you want the program to finish/what does it return?
How do we test? What should we test?
Where do we code this? (file path)