Anybody?
Here's my CAN_RX code if that helps (can't find the CAN_TX at the moment, I will have to search around for that if it's needed):
CAN_RX.ino:
// CAN_RX.ino
// Arduino Due - CAN Test based on CAN Sample 3
// RX Side
// Required libraries
#include "variant.h"
#include <due_can.h>
#define TEST1_CAN_COMM_MB_IDX 0
#define TEST1_CAN_TRANSFER_ID 0x07
#define TEST1_CAN0_TX_PRIO 15
#define CAN_MSG_DUMMY_DATA 0x55AAAA55
// CAN frame max data length
#define MAX_CAN_FRAME_DATA_LEN 8
uint32_t receivedFrames;
void setup() {
// start serial port at 115200 bps:
Serial.begin(115200);
// Verify CAN0 initialization, baudrate is 1Mb/s:
if (CAN.init(SystemCoreClock, CAN_BPS_1000K)) {
// Disable all CAN0 interrupts
CAN.disable_interrupt(CAN_DISABLE_ALL_INTERRUPT_MASK);
// Configure and enable interrupt of CAN0, as the tests will use receiver interrupt
NVIC_EnableIRQ(CAN0_IRQn);
}
else {
Serial.println("CAN initialization (sync) ERROR");
}
}
// Test the transmission from CAN0 Mailbox 0 to CAN1 Mailbox 0
static void test_1(void)
{
//Reset all CAN0 and CAN1 mailboxes:
CAN.reset_all_mailbox();
//setup four receive mailboxes that each accept a different frame id
for (uint8_t count = 0; count < 4; count++)
{
CAN.mailbox_set_mode(count, CAN_MB_RX_MODE);
CAN.mailbox_set_accept_mask(count, 0x7FF, false); //only accept the exact ID
CAN.mailbox_set_id(count, TEST1_CAN_TRANSFER_ID + count * 4, false);
Serial.print("ID: ");
Serial.print(TEST1_CAN_TRANSFER_ID + count * 4);
Serial.print("\n");
}
// Enable interrupt for mailboxes 0-3 on first canbus
CAN.enable_interrupt(CAN_IER_MB0 | CAN_IER_MB1 | CAN_IER_MB2 | CAN_IER_MB3);
// Wait for the communication to come in.
Serial.print("Waiting for a frame...\n");
Serial.print(CAN.rx_avail());
while (!CAN.rx_avail()) { //while no frame is received
}
RX_CAN_FRAME inFrame;
while (CAN.rx_avail()) {
CAN.get_rx_buff(&inFrame);
receivedFrames++;
}
}
// can_example application entry point
void loop()
{
// Run test
while (Serial.available() == 0)
{
Serial.print("Testing...\n");
test_1();
delay(8);
Serial.print(" R: ");
Serial.println(receivedFrames);
Serial.print("\n");
}
// Disable CAN0 Controller
CAN.disable();
while (1) {
}
}