I am running my own sketch. Mainly starting with one of your sketches that was designed to show traffic on both CAN ports.
This is my variable defs and startup. Does waiting for the USB stack interfere with running the rest of the code?
// Required libraries
#include “variant.h”
#include <due_can.h>
#include <M2_12VIO.h>
#include <pins_arduino.h>
#include <Arduino.h>
#include “M2_IO.h”
#include <pwm_lib.h>
M2_12VIO M2IO;
//Leave defined if you use native port, comment if using programming port
//This sketch could provide a lot of traffic so it might be best to use the
//native port
#define Serial SerialUSB
byte rpm1 = 0;
byte rpm2 = 0;
byte APP = 0;
byte Mux1 = 0;
byte Mux2 = 0;
byte RadFan = 0; //Porsche Radiator Fan signal - 7 bits long. Bit 8 is engine run status
byte RadFanUnCnvrt = 0; //GM Radiator Fan Signal is 8 bits long
byte TPS = 0; //Maybe GM Controller does not transmit - send APP instead, close enough
byte Coolant = 0; //Eng Coolant Temp
byte OilLvl = 0; //Eng Oil Level
byte OilPress = 0; //Oil Pressure
byte OilTemp = 0; //Oil Temperature
byte VehSpeed1 = 0; //Vehicle Speed
byte VehSpeed2 = 0; //Other Half Veh Speed
byte SpdL = 0;
byte SpdH = 0;
byte Cnt2 = 0;
byte EngTorqH = 0;
byte EngTorqL = 0;
byte CmndTorqH = 0;
byte CmndTorqL = 0;
byte Baro = 0;
byte PRNDL = 0x50;
uint16_t EngTorq = 0;
uint16_t CmndTorq = 0;
uint16_t TOS_TmTx = 0;
uint16_t TOS_Cnt = 0;
uint16_t TOS_TmMax = 65534;
uint16_t TOS_CntMax = 1023;
int Rvr_Input = 1; //Sets Analog Input 1 to be the input for reverse.
int TOS_Tm = 0;
int Timer = 0;
int value = 0;
int test = 0;
int Spd = 0;
int test2 = 0;
int RvrSwitch = 1;
int RPM = 0;
int VSS = 0;
unsigned long PrevTime=0;
unsigned long PreCntTm=0;
unsigned long LoopRate_17ms = 0;
unsigned long LoopRate_1000ms = 0;
unsigned long LoopRate_100ms = 0;
unsigned long LoopRate_13ms = 0;
unsigned long time_now = 0;
void setup()
{
M2IO.Init_12VIO(); // Initialize the M2I/O library
//M2IO.Setpin_12VIO(2, ON, SOURCE, PWM_PIN, 2, 20);
//M2IO.Setpin_12VIO(1, ON, SOURCE);
pinMode(Led5, OUTPUT); // Set the Green LED PIN as an OUTPUT
//pinMode(Led4, OUTPUT); // Set the Yellow LED PIN as an OUTPUT
//pinMode(Led3, OUTPUT); // Set the Yellow LED PIN as an OUTPUT
digitalWrite(Led5, LOW); // turn the Green LED ON by making the PIN LOW
// digitalWrite(Led4, HIGH); // turn the Yellow LED OFF by making the PIN HIGH
// digitalWrite(Led3, HIGH); // turn the Yellow LED OFF by making the PIN HIGH
M2IO.InitButton_12VIO(Rvr_Input); //Inits the input as a digital input for a button. Looks for voltage to set true. Use pullup resistor to use a ground input (ground will set false, so invert the logic)
//Serial.begin(115200);
// Initialize CAN0 and CAN1, Set the proper baud rates here
Can0.begin(CAN_BPS_500K);
Can1.begin(CAN_BPS_500K);
//By default there are 7 mailboxes for each device that are RX boxes
//This sets each mailbox to have an open filter that will accept extended
//or standard frames
//Ignore this bit - Unsure what it means. Copied from setup
int filter;
//extended
for (filter = 0; filter < 3; filter++) {
Can0.setRXFilter(filter, 0, 0, true);
Can1.setRXFilter(filter, 0, 0, true);
}
//standard
for (int filter = 3; filter < 7; filter++) {
Can0.setRXFilter(filter, 0, 0, false);
Can1.setRXFilter(filter, 0, 0, false);
}