Dear All,
I am using the nvidia jetson nx boards( ubuntu 18.04) USB 3.1 interface to power ON the Teensy 3.6 Board.
I have uploaded the FLEXCAN library example sketch to the teensy 3.6 board. The code is given below:
#include <FlexCAN.h>
#ifndef __MK66FX1M0__
#error "Teensy 3.6 with dual CAN bus is required to run this example"
#endif
static CAN_message_t msg;
static uint8_t hex[17] = "0123456789abcdef";
// -------------------------------------------------------------
static void hexDump(uint8_t dumpLen, uint8_t *bytePtr)
{
uint8_t working;
while( dumpLen-- ) {
working = *bytePtr++;
Serial.write( hex[ working>>4 ] );
Serial.write( hex[ working&15 ] );
}
Serial.write('\r');
Serial.write('\n');
}
// -------------------------------------------------------------
void setup(void)
{
delay(1000);
Serial.println(F("Hello Teensy 3.6 dual CAN Test."));
Can0.begin();
Can1.begin();
//if using enable pins on a transceiver they need to be set on
pinMode(2, OUTPUT);
pinMode(35, OUTPUT);
digitalWrite(2, HIGH);
digitalWrite(35, HIGH);
msg.ext = 0;
msg.id = 0x100;
msg.len = 8;
msg.buf[0] = 10;
msg.buf[1] = 20;
msg.buf[2] = 0;
msg.buf[3] = 100;
msg.buf[4] = 128;
msg.buf[5] = 64;
msg.buf[6] = 32;
msg.buf[7] = 16;
}
// -------------------------------------------------------------
void loop(void)
{
CAN_message_t inMsg;
while (Can0.available())
{
Can0.read(inMsg);
Serial.print("CAN bus 0: "); hexDump(8, inMsg.buf);
}
msg.buf[0]++;
Can1.write(msg);
msg.buf[0]++;
Can1.write(msg);
msg.buf[0]++;
Can1.write(msg);
msg.buf[0]++;
Can1.write(msg);
msg.buf[0]++;
Can1.write(msg);
delay(20);
}
The sketch works perfectly for me. I am able to send and receive CAN messages. But the problem is when i turn off the NVIDIA NX board and again power ON then the uploaded sketch is not working.
Interestingly if i unplug the Teensy 3.6 and again plug in then the uploaded sketch started working.
I have checked the LED blinking example also. The LED blinking example is working perfectly and i am not facing any issue.
Any suggestion how to solve this problem will be highly appreciated.
Regards
Anayat
I am using the nvidia jetson nx boards( ubuntu 18.04) USB 3.1 interface to power ON the Teensy 3.6 Board.
I have uploaded the FLEXCAN library example sketch to the teensy 3.6 board. The code is given below:
#include <FlexCAN.h>
#ifndef __MK66FX1M0__
#error "Teensy 3.6 with dual CAN bus is required to run this example"
#endif
static CAN_message_t msg;
static uint8_t hex[17] = "0123456789abcdef";
// -------------------------------------------------------------
static void hexDump(uint8_t dumpLen, uint8_t *bytePtr)
{
uint8_t working;
while( dumpLen-- ) {
working = *bytePtr++;
Serial.write( hex[ working>>4 ] );
Serial.write( hex[ working&15 ] );
}
Serial.write('\r');
Serial.write('\n');
}
// -------------------------------------------------------------
void setup(void)
{
delay(1000);
Serial.println(F("Hello Teensy 3.6 dual CAN Test."));
Can0.begin();
Can1.begin();
//if using enable pins on a transceiver they need to be set on
pinMode(2, OUTPUT);
pinMode(35, OUTPUT);
digitalWrite(2, HIGH);
digitalWrite(35, HIGH);
msg.ext = 0;
msg.id = 0x100;
msg.len = 8;
msg.buf[0] = 10;
msg.buf[1] = 20;
msg.buf[2] = 0;
msg.buf[3] = 100;
msg.buf[4] = 128;
msg.buf[5] = 64;
msg.buf[6] = 32;
msg.buf[7] = 16;
}
// -------------------------------------------------------------
void loop(void)
{
CAN_message_t inMsg;
while (Can0.available())
{
Can0.read(inMsg);
Serial.print("CAN bus 0: "); hexDump(8, inMsg.buf);
}
msg.buf[0]++;
Can1.write(msg);
msg.buf[0]++;
Can1.write(msg);
msg.buf[0]++;
Can1.write(msg);
msg.buf[0]++;
Can1.write(msg);
msg.buf[0]++;
Can1.write(msg);
delay(20);
}
The sketch works perfectly for me. I am able to send and receive CAN messages. But the problem is when i turn off the NVIDIA NX board and again power ON then the uploaded sketch is not working.
Interestingly if i unplug the Teensy 3.6 and again plug in then the uploaded sketch started working.
I have checked the LED blinking example also. The LED blinking example is working perfectly and i am not facing any issue.
Any suggestion how to solve this problem will be highly appreciated.
Regards
Anayat