We are converting a oldtimer Jaguar XJ-6 from 1988. It will be from the outside a classical jaguar expression but from the inside a electrical powered system. But to keep the originalnal dashboard cluster I need to develop a CANbus interface.
I already managed to work with the arduino due and the dueCAN library from Collin Kidder (https://github.com/collin80). Credits for that!
But now I want it to work with the Teensy 3.2 microcontroller. I am able to Send Canbus frames but for some reason I Cannot read any data. I have tried every FlexCAN library version availible. But nothing works. I am almost 100% sure the hardware connection is correct. My guess is that ther is a weird software isseu. Any Help or tips that can provide would be appreciated.
Some detaills:
a Teensy 3.2 microcontroller on a working CANbus line with a MCP2551 CANbus transeiver. On the same CAN bus line an arduino due with the GVRET SavvyCAN software to monitor the CANbus frames.
Flexcan version I used:
https://github.com/teachop/FlexCAN_Library
https://github.com/pawelsky/FlexCAN_Library
https://github.com/collin80/FlexCAN_Library
The working code I used to transmit :
#include <FlexCAN.h>
#include <kinetis_flexcan.h>
int led = 13;
// create CAN object
FlexCAN CANTransmitter(500000);
static CAN_message_t msg;
void setup() {
// init CAN bus
CANTransmitter.begin(500000);
pinMode(led, OUTPUT);
delay(1000);
Serial.println("CAN Transmitter Initialized");
}
void loop() {
Serial.print("Sending: ");
msg.id = 0x222;
msg.len = 2;
for(int i=0; i<msg.len; i++) {
msg.buf = '0' + i;
Serial.print(msg.buf); Serial.print(" ");
}
Serial.println("");
CANTransmitter.write(msg);
digitalWrite(led, !digitalRead(led));
delay(500);
}
The code to recieve ( that is not working ):
#include <FlexCAN.h>
#include <kinetis_flexcan.h>
int led = 13;
// create CAN object
FlexCAN CANReceiver(500000);
static CAN_message_t msg;
void setup() {
// init CAN bus
CANReceiver.begin(500000);
pinMode(led, OUTPUT);
delay(1000);
Serial.println("CAN Receiver Initialized");
}
void loop() {
while( CANReceiver.read(msg)) {
// toggle LEDs
digitalWrite(led, !digitalRead(led));
Serial.print("Receiving: ");
for(int i=0; i<msg.len; i++) {
Serial.print(msg.buf); Serial.print(" ");
}
Serial.println("");
}
}
NOTE: I used some information from an other topic. But I think there is an other problem.
(https://forum.pjrc.com/threads/41899-Teensy-3-2-Unable-to-get-a-successful-CAN-Bus-read)
already thank you all for the support!
I already managed to work with the arduino due and the dueCAN library from Collin Kidder (https://github.com/collin80). Credits for that!
But now I want it to work with the Teensy 3.2 microcontroller. I am able to Send Canbus frames but for some reason I Cannot read any data. I have tried every FlexCAN library version availible. But nothing works. I am almost 100% sure the hardware connection is correct. My guess is that ther is a weird software isseu. Any Help or tips that can provide would be appreciated.
Some detaills:
a Teensy 3.2 microcontroller on a working CANbus line with a MCP2551 CANbus transeiver. On the same CAN bus line an arduino due with the GVRET SavvyCAN software to monitor the CANbus frames.
Flexcan version I used:
https://github.com/teachop/FlexCAN_Library
https://github.com/pawelsky/FlexCAN_Library
https://github.com/collin80/FlexCAN_Library
The working code I used to transmit :
#include <FlexCAN.h>
#include <kinetis_flexcan.h>
int led = 13;
// create CAN object
FlexCAN CANTransmitter(500000);
static CAN_message_t msg;
void setup() {
// init CAN bus
CANTransmitter.begin(500000);
pinMode(led, OUTPUT);
delay(1000);
Serial.println("CAN Transmitter Initialized");
}
void loop() {
Serial.print("Sending: ");
msg.id = 0x222;
msg.len = 2;
for(int i=0; i<msg.len; i++) {
msg.buf = '0' + i;
Serial.print(msg.buf); Serial.print(" ");
}
Serial.println("");
CANTransmitter.write(msg);
digitalWrite(led, !digitalRead(led));
delay(500);
}
The code to recieve ( that is not working ):
#include <FlexCAN.h>
#include <kinetis_flexcan.h>
int led = 13;
// create CAN object
FlexCAN CANReceiver(500000);
static CAN_message_t msg;
void setup() {
// init CAN bus
CANReceiver.begin(500000);
pinMode(led, OUTPUT);
delay(1000);
Serial.println("CAN Receiver Initialized");
}
void loop() {
while( CANReceiver.read(msg)) {
// toggle LEDs
digitalWrite(led, !digitalRead(led));
Serial.print("Receiving: ");
for(int i=0; i<msg.len; i++) {
Serial.print(msg.buf); Serial.print(" ");
}
Serial.println("");
}
}
NOTE: I used some information from an other topic. But I think there is an other problem.
(https://forum.pjrc.com/threads/41899-Teensy-3-2-Unable-to-get-a-successful-CAN-Bus-read)
already thank you all for the support!