Booting M4 Core kills CANBUS

Hey guys, I'm having a really weird issue where when I boot the M4 core from M7 it causes CANBUS to stop working (initialized at top of file). Is this an MBED or Arduino type issue? Anyone have any ideas? Thanks!

Here is a simple example, by removing "RPC.begin();" CANBUS starts working fine again.

#include "CAN.h"
#include "RPC.h"

mbed::CAN can1(PB_5, PB_13, 1000000);

void receive() {
  mbed::CANMessage msg;
  if (can1.read(msg)) {
    Serial.println(msg.id);
  }
}

void setup() {
  Serial.begin(1000000);
  RPC.begin();
}

void loop() {
  receive();
}

(Behind the scenes I have a massive drone program that needed CAN, small example above is demo of problem only). I figured out the issue, MBED OS initializes CAN resources for the M4 core when booted and kills the M7 CAN (even though I never use CAN on M4). Solution is to reset the frequency of CAN to get it moving again. Here is the solution in the form of the example above:

#include "CAN.h"
#include "RPC.h"

mbed::CAN can1(PB_5, PB_13);

void receive() {
  mbed::CANMessage msg;
  if (can1.read(msg)) {
    Serial.println(msg.id);
  }
}

void setup() {
  Serial.begin(1000000);
  RPC.begin();
  can1.frequency(1000000);
}

void loop() {
  receive();
}
1 Like