Pages: 1 ... 16 17 [18] 19 20 ... 27   Go Down
Author Topic: Building a CAN API for Arduino DUE  (Read 94393 times)
0 Members and 1 Guest are viewing this topic.
Honolulu
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I believe J1939 is a higher level than just the signals, but it does utilize the extended id.  I guess what I am trying to do first is just get the raw data, even though I might not know exactly what it means.  The only CAN thing I have is a dynaGen GSC 400.  There is a J1939 plug, and the manual is not very helpful about... well... anything.  Right now I am just trying to get my arduino to send extended id messages to itself.  So I tweaked the first example.  Here is my code:

Code:
// Required libraries
#include "variant.h"
#include <due_can.h>
#include <sn65hvd234.h>

#define TEST1_CAN_COMM_MB_IDX    0
#define TEST1_CAN_TRANSFER_ID    0xFEEE00
#define TEST1_CAN0_TX_PRIO       0
#define CAN_MSG_DUMMY_DATA       0x55AAAA55

// CAN frame max data length
#define MAX_CAN_FRAME_DATA_LEN   8

// Message variable to be send
uint32_t CAN_MSG_1 = 0;

void setup()
{
  // start serial port at 9600 bps:
  Serial.begin(9600);
  Serial.println("Type CAN message to send");
  while (Serial.available() == 0);
}
void loop(){

  while (Serial.available() > 0) {
    CAN_MSG_1 = Serial.parseInt();
    if (Serial.read() == '\n') {
      Serial.print("Sent value= ");
      Serial.println(CAN_MSG_1);
    }
  }
 
  CAN.reset_all_mailbox();
  CAN2.reset_all_mailbox();

  // Initialize CAN0 and CAN1, baudrate is 1Mb/s
  CAN.init(SystemCoreClock, CAN_BPS_1000K);
  CAN2.init(SystemCoreClock, CAN_BPS_1000K);

  // Initialize CAN1 mailbox 0 as receiver, frame ID is 0x07
  CAN2.mailbox_init(0);
  CAN2.mailbox_set_mode(0, CAN_MB_RX_MODE);
  CAN2.mailbox_set_accept_mask(0, 0, true);
  CAN2.mailbox_set_id(0, 0, true);

  // Initialize CAN0 mailbox 0 as transmitter, transmit priority is 15
  CAN.mailbox_init(0);
  CAN.mailbox_set_mode(0, CAN_MB_TX_MODE);
  CAN.mailbox_set_priority(0, TEST1_CAN0_TX_PRIO);
  CAN.mailbox_set_accept_mask(0, 0, true);
  // Prepare transmit ID, data and data length in CAN0 mailbox 0
  CAN.mailbox_set_id(0, TEST1_CAN_TRANSFER_ID, true);
  CAN.mailbox_set_datal(0, CAN_MSG_1);
  //CAN.mailbox_set_datah(0, CAN_MSG_DUMMY_DATA);
  CAN.mailbox_set_datalen(0, MAX_CAN_FRAME_DATA_LEN);

  // Send out the information in the mailbox
  CAN.mailbox_send_transfer_cmd(0);

  // Wait for CAN1 mailbox 0 to receive the data
  while (!(CAN2.mailbox_get_status(0) & CAN_MSR_MRDY)) {

  }

  RX_CAN_FRAME incoming;
  // Read the received data from CAN1 mailbox 0
  CAN2.mailbox_read(0, &incoming);
  Serial.println("CAN message received= ");
  Serial.print("ID:");
  Serial.println(incoming.id);
  Serial.print("FID:");
  Serial.println(incoming.fid);
  Serial.print("RTR:");
  Serial.println(incoming.rtr);
  Serial.print("IDE:");
  Serial.println(incoming.ide);
  Serial.print("DLC:");
  Serial.println(incoming.dlc);
  Serial.print("DATA:");
  Serial.print(incoming.data[0]);
  Serial.print(incoming.data[1]);
  Serial.print(incoming.data[2]);
  Serial.print(incoming.data[3]);
  Serial.print(incoming.data[4]);
  Serial.print(incoming.data[5]);
  Serial.print(incoming.data[6]);
  Serial.println(incoming.data[7]);
 
  // Disable CAN0 Controller
  CAN.disable();

  // Disable CAN1 Controller
  CAN2.disable();

  Serial.print("End of test");

  while (1) {
  }
}

and my output on the serial monitor below.  Notice the Data is all zeroes.  This the case no matter what i put in.  Any ideas of why I can't get the data through?

Thanks!



* Untitled.png (27.63 KB, 411x396 - viewed 47 times.)
Logged

Pacific Electro-Mechanical Inc. - Honolulu -

Honolulu
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I figured out my problem.  I needed to put a
CAN.global_send_transfer_cmd(CAN_TCR_MB0);

instead of
CAN.mailbox_send_transfer_cmd(0);

Success! Now I can actually try to do something with this.  I'm going to try to send some info to my DynaGen GSC 400.  If anyone has any knowledge of doing such things hit me up, otherwise I'll keep ya'll posted.   
Logged

Pacific Electro-Mechanical Inc. - Honolulu -

Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi All.

First off, Fantastic Effort.

I am having real trouble getting the example 1 to compile,

Getting a lot of errors that i think stem from incorrect Variant file, does anyone have the variant file i need? as i cant find it on Collins Git page

Cheers

Rich
Logged

Venezuela
Offline Offline
Sr. Member
****
Karma: 12
Posts: 433
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Rich,

Please see my reply #181.

http://forum.arduino.cc/index.php?topic=131096.181

Regards,
Wilfredo
Logged

Honolulu
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Rich,

Check out Replies 229-231 also.  I was getting a bunch of errors too at first.
Logged

Pacific Electro-Mechanical Inc. - Honolulu -

Honolulu
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So just an update on the J1939 endeavor.  I was able to find several parameters and PGN's to test.  However, most of them are just to read information not necessarily change throttle speed or even send stop/start signals.  In the picture you can see the Eng. Temp and Hours as N/A and 0.0 respectively.  I was able to send fake data on the bus and have the Dyna Gen pick it up and display it.  Pretty much made my day.

All in all this due is pretty awesome.  Thanks again to all those who worked on putting together the library! Now if only SAE and manufacturers would give access to all the PGN's and detailed descriptions of what each block of data does.  I could do a lot more.  But I'm just glad it worked.  So that's the scoops, and the next step is actually using the Due in a real application.



* IMG_2601.JPG (3217.4 KB, 6368x1736 - viewed 76 times.)
Logged

Pacific Electro-Mechanical Inc. - Honolulu -

Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Thanks for the VAriant Files,

I replaced the standard arduino Variant Files with these and i still cant compile it,

The first error is that variant.h doesnt exist. i have checked spelling of the file and location (in the variants folder i assuem?) seems ok

See below, i am completely confused, i dont usually have issues like this but i have not used the due much as of yet,

Code:
Arduino_Due_CAN_Sample_1.ino:7:21: error: variant.h: No such file or directory
In file included from \\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:72,
                 from Arduino_Due_CAN_Sample_1.ino:8:
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:34: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:37: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:39: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:40: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:41: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:43: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:44: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:46: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:47: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/sn65hvd234.h:48: error: expected `)' before 'Rs'
In file included from Arduino_Due_CAN_Sample_1.ino:8:
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:76: error: 'uint8_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:77: error: 'uint8_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:129: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:130: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:131: error: 'uint8_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:132: error: 'uint8_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:144: error: 'uint8_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:151: error: ISO C++ forbids declaration of 'Can' with no type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:151: error: expected ';' before '*' token
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:159: error: 'uint16_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:160: error: 'uint16_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:161: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:161: error: 'uint32_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:167: error: expected `)' before '*' token
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:213: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:213: error: 'uint16_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:214: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:215: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:216: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:217: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:218: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:219: error: 'uint32_t' does not name a type
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:220: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:220: error: 'uint32_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:221: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:221: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:222: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:222: error: 'uint32_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:223: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:223: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:224: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:224: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:224: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:225: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:225: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:226: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:226: error: 'uint32_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:227: error: 'uint8_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:227: error: 'uint32_t' has not been declared
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\due_can/due_can.h:232: error: 'uint32_t' does not name a type
Arduino_Due_CAN_Sample_1.ino: In function 'void loop()':
Arduino_Due_CAN_Sample_1:39: error: 'class CANRaw' has no member named 'init'
Arduino_Due_CAN_Sample_1:39: error: 'SystemCoreClock' was not declared in this scope
Arduino_Due_CAN_Sample_1:40: error: 'class CANRaw' has no member named 'init'
Arduino_Due_CAN_Sample_1:60: error: 'CAN_TCR_MB0' was not declared in this scope
Arduino_Due_CAN_Sample_1:63: error: 'class CANRaw' has no member named 'mailbox_get_status'
Arduino_Due_CAN_Sample_1:63: error: 'CAN_MSR_MRDY' was not declared in this scope
Arduino_Due_CAN_Sample_1:68: error: 'class CANRaw' has no member named 'mailbox_read'
Arduino_Due_CAN_Sample_1:70: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:71: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:72: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:73: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:74: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:75: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:76: error: 'struct RX_CAN_FRAME' has no member named 'data'
Arduino_Due_CAN_Sample_1:77: error: 'struct RX_CAN_FRAME' has no member named 'data'
Logged

Venezuela
Offline Offline
Sr. Member
****
Karma: 12
Posts: 433
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Rich,
I would recommend you to move (cut and paste) the CAN library folder 'due_can' from

Quote
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\libraries\

to

Quote
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\hardware\arduino\sam\libraries\

Please, let me know.

EDIT:
Remember also that the variant files should be located at:

Quote
\\fs02\users\richardpel\arduino-1.5.2-windows\arduino-1.5.2\hardware\arduino\sam\variants\arduino_due_x
« Last Edit: July 30, 2013, 08:26:57 am by Palliser » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just downloaded arduino 1.5.2, downloaded CAN library from GitHub, also updated the variant file just like the last posts indicated but still getting all kinds of errors when I try to run a sketch. Are there more files that I need to be updating within arduino 1.5.2?

Thanks
Logged

Venezuela
Offline Offline
Sr. Member
****
Karma: 12
Posts: 433
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello djusthof,
Could you show us part of the errors you are getting? Thanks.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

when i try to compile this
Code:
#include <due_can.h>

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
  
}

Here is part of the error,

Code:
In file included from sketch_jul31a.ino:1:
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:9: error: stray '\302' in program
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:9: error: stray '\267' in program
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:9: error: stray '\302' in program
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:9: error: stray '\267' in program
In file included from sketch_jul31a.ino:1:
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:314: error: invalid suffix "b4c26c6e36e6baaed686d0d5c3666b" on integer constant
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:315: error: invalid suffix "b4c26c6e36e6baaed686d0d5c3666b" on integer constant
In file included from sketch_jul31a.ino:1:
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:369: error: too many decimal points in number
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:373: error: too many decimal points in number
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:377: error: too many decimal points in number
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:426: error: invalid digit "9" in octal constant
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:430: error: invalid digit "8" in octal constant
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:466: error: invalid digit "9" in octal constant
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:470: error: invalid digit "8" in octal constant
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:498: error: too many decimal points in number
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:502: error: too many decimal points in number
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:522: error: too many decimal points in number
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:526: error: too many decimal points in number
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:530: error: too many decimal points in number
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:534: error: too many decimal points in number
C:\Users\Derek\Desktop\Arduino 1.5.2\arduino-1.5.2\hardware\arduino\sam\libraries\CAN/due_can.h:538: error: too many decimal points in number

Thanks
Logged

Venezuela
Offline Offline
Sr. Member
****
Karma: 12
Posts: 433
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello djusthof,
I don't know which due_can.h file you pulled but the one from collin80 here: https://github.com/collin80/due_can only has 241 lines and I see you are getting error in line 538?. Thus, I would recommend you to download again the library and try it again. Regards.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Palliser, works great
Logged

United States
Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there any way at all to get more than 8 total mailboxes?

Code:
CAN.global_send_transfer_cmd(CAN_TCR_MB0 | CAN_TCR_MB1 | CAN_TCR_MB2 | CAN_TCR_MB3 | CAN_TCR_MB4 | CAN_TCR_MB5 | CAN_TCR_MB6 | CAN_TCR_MB7 | CAN_TCR_MB8 | CAN_TCR_MB9 | CAN_TCR_MB10 | CAN_TCR_MB11 | CAN_TCR_MB12);

Code:
dueCAN4.ino: In function 'void loop()':
dueCAN4:475: error: 'CAN_TCR_MB8' was not declared in this scope
dueCAN4:475: error: 'CAN_TCR_MB9' was not declared in this scope
dueCAN4:475: error: 'CAN_TCR_MB10' was not declared in this scope
dueCAN4:475: error: 'CAN_TCR_MB11' was not declared in this scope
dueCAN4:475: error: 'CAN_TCR_MB12' was not declared in this scope


I tried this in the library... but not sure what is going on


due_can.cpp
Code:
void CANRaw::interruptHandler() {

uint32_t ul_status = m_pCan->CAN_SR; //get status of interrupts

if (ul_status & CAN_SR_MB0) { //mailbox 0 event
mailbox_int_handler(0, ul_status);
}
if (ul_status & CAN_SR_MB1) { //mailbox 1 event
mailbox_int_handler(1, ul_status);
}
if (ul_status & CAN_SR_MB2) { //mailbox 2 event
mailbox_int_handler(2, ul_status);
}
if (ul_status & CAN_SR_MB3) { //mailbox 3 event
mailbox_int_handler(3, ul_status);
}
if (ul_status & CAN_SR_MB4) { //mailbox 4 event
mailbox_int_handler(4, ul_status);
}
if (ul_status & CAN_SR_MB5) { //mailbox 5 event
mailbox_int_handler(5, ul_status);
}
if (ul_status & CAN_SR_MB6) { //mailbox 6 event
mailbox_int_handler(6, ul_status);
}
if (ul_status & CAN_SR_MB7) { //mailbox 7 event
mailbox_int_handler(7, ul_status);
}
if (ul_status & CAN_SR_MB8) { //mailbox 7 event
mailbox_int_handler(8, ul_status);
}
if (ul_status & CAN_SR_MB9) { //mailbox 7 event
mailbox_int_handler(9, ul_status);
}
if (ul_status & CAN_SR_MB10) { //mailbox 7 event
mailbox_int_handler(10, ul_status);
}
if (ul_status & CAN_SR_MB11) { //mailbox 7 event
mailbox_int_handler(11, ul_status);
}
if (ul_status & CAN_SR_MB12) { //mailbox 7 event
mailbox_int_handler(12, ul_status);
}

keywords.txt
Code:
CAN_TCR_MB0 LITERAL1
CAN_TCR_MB1 LITERAL1
CAN_TCR_MB2 LITERAL1
CAN_TCR_MB3 LITERAL1
CAN_TCR_MB4 LITERAL1
CAN_TCR_MB5 LITERAL1
CAN_TCR_MB6 LITERAL1
CAN_TCR_MB7 LITERAL1
CAN_TCR_MB8 LITERAL1
CAN_TCR_MB9 LITERAL1
CAN_TCR_MB10 LITERAL1
CAN_TCR_MB11 LITERAL1
CAN_TCR_MB12 LITERAL1

I didn't know I was so limited in this respect and am almost ready for this project and just hit an enormous wall!
Logged

Venezuela
Offline Offline
Sr. Member
****
Karma: 12
Posts: 433
Ground.......ground........always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello zabaat.

According to Atmel doc11057 (page 1207) http://www.atmel.com/Images/doc11057.pdf, each of the two CAN controllers inside SAM3X8E has 8 mailboxes implemented. Thus, you have 16 mailboxes available which is more than enough for a general purpose CAN project. It is a hardware limitation of the MCU. Notice also that the component_can.h file from the CMSIS library on the Arduino Due...
Quote
(...\arduino-1.5.2-windows\arduino-1.5.2\hardware\arduino\sam\system\CMSIS\Device\ATMEL\sam3xa\include\component)
... there are only 8 defined mailboxes per CAN controller (MB0->MB7). On the other hand, you could optimize the use of the mailboxes implementing the Producer<->Consumer mode where you need half of the amount of mailboxes as compared to the clasical Transmit<->Receive mode. Can you tell us more about you application?. Why more than 16 mailboxes? Regards!
Logged

Pages: 1 ... 16 17 [18] 19 20 ... 27   Go Up
Jump to: