Crash while using I2C2 device and CANbus


I´m using a BBB with Codesys Controll 4.10 for BBB.
CANbus is connected to SN65HVD230 and is controlling a Nanotec Controller.
I2C2 PIN 9.19 and 9.20 are connectet to a TCA9517ADGK with 6 MCP23017 address 0.22 - 0x27.
Everything by its own is working but when I connect all together the BBB randomly chrashes. Mostly when ich send the motor in home position. (Works fine without I2c2 connected)
Most of the time all LEDs are off after the crash and sometimes LED0 (normaly heartbeat) is constant on.
What could be the reason for the beaglebone to crash that way?

I checked all voltages and connections. I thought about a potential difference but found nothing.

All Pins used:
P9.1 GND
P9.3 3V3
P9.5 VDD
P9.7 SYS
P9.19 SCL
P9.20 SCA
P9.24 TXD
P9.26 RXD

Insert some printf statements, before, during and after the problematic sequence. Label them with accuracy and meaning, regarding where they are exactly located in the function.

If you are using c consider moving to c++ and wrapping your c with c++, just one of my first thoughts.

I can’t help but think that the motor is able to inject noise or spikes / ground bounce
back into the BBB supply, messing up CPU stability.

How are you powering your setup?
Does it happen even if a motor is not connected at all?
( just the motor )

Granted, I don’t know of the board in question, so this could all be very wrong.