Hi ,
I am having trouble getting my CAN shield to output 2 pieces of data alternatly. all it does is showes the first piec of data once and then repeats the second piece of data repeatedly.
#include <CAN.h>
#include <SPI.h>
#define BUS_SPEED 500
//global variable used to determine whether loop should
//be in Tx or Rx mode.
int state;
//global variable used to toggle pin
int pin;
void setup() {
Serial.begin(9600);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
// initialize CAN bus class
// this class initializes SPI communications with MCP2515
CAN.begin();
CAN.baudConfig(BUS_SPEED);
CAN.setMode(NORMAL);
//CAN.setMode(LOOPBACK); // set to "NORMAL" for standard com
//Wait 10 seconds so that I can still upload even
//if the previous iteration spams the serial port
delay(100);
state = 0;
pin = LOW;
}
byte val = 0;
void loop() {
byte length,rx_status,i;
unsigned short frame_id;
byte frame_data[8];
frame_data[0] = val;
frame_data[1] = 0xAA;
frame_data[2] = 0x0F;
frame_data[3] = 0xAA;
frame_data[4] = 0x02;
frame_data[5] = 0x1F;
frame_data[6] = 0xDD;
frame_data[7] = 0x7A;
frame_id = 0x1d4;
length = 8;
CAN.load_ff_0(length,frame_id,frame_data);
CAN.load_ff_1(length,0x1d5,frame_data);
//CAN.load_ff_2(1,0x1d6,frame_data);
CAN.send_0();
CAN.send_1();
//CAN.send_2();
val++;
delay(10);
}
Thanks in advanced