Noticed this on 2/3 of my M2s. CAN0 communicates fine, however CAN1 has a tendency to just not receive or send. Usually I didn’t mind as the previous projects didn’t really require both busses.
So the code for testing I used was actually pretty simple, just the usual Traffic modifier. Just so happens the job I was using it on also required bus speed modification.
CAN 0 Recieved data @ 250kBd, and CAN1 was supposed to output it at 500kBd. However nothing actually occurred. After reconfirming I am using pin 7 & 8, and correct way around, along with termination resistor (Bus at 60ohms), I swapped the busses around, and the speeds. Again, CAN1 remains unresponsive.
The literal code is below.
Now being a a careless dumbfuck, I then proceeded to set the M2 down on my desk while it was powered up, right on a strand of solder. Thus sticking 12v right up the processors ass.
Luckily as a test case I had a shit ton of Due(s?) lying around, with a copperhill can shield. I then reused the exact same code, and it worked flawlessly. That being said, not sticking a due in a commercial truck. Picture of “What the hell is this idiot doing” also attached below.
tl;dr
Am I being retarded or is there occasional issues I’ve been missing on the M2? I have briefly managed to check that the bus really is down, both with an ixxat sniffer, along with a oscilloscope. Bus stays nice and steady with no data coming through, and couldn’t check the actual rx/tx as thats when I decided to bbq the M2.
#include “variant.h”
#include <due_can.h>
#define Serial SerialUSB
void setup()
{
Serial.begin(115200);
Can0.begin(CAN_BPS_500K);
Can1.begin(CAN_BPS_250K);
int filter;
for (filter = 0; filter < 3; filter++) {
Can0.setRXFilter(filter, 0, 0, true);
Can1.setRXFilter(filter, 0, 0, true);
}
}
void printFrame(CAN_FRAME &frame) {
Serial.print(“ID: 0x”);
Serial.print(frame.id, HEX);
Serial.print(" Len: “);
Serial.print(frame.length);
Serial.print(” Data: 0x");
for (int count = 0; count < frame.length; count++) {
Serial.print(frame.data.bytes[count], HEX);
Serial.print(" “);
}
Serial.print(”\r\n");
}
void loop(){
CAN_FRAME incoming;
if (Can0.available() > 0) {
Can0.read(incoming);
Can1.sendFrame(incoming);
printFrame(incoming);
}
if (Can1.available() > 0) {
Can1.read(incoming);
Can0.sendFrame(incoming);
printFrame(incoming);
}
}