Freertos with teensy 4.0

Looking at the card the 23,22 will precede 0,1:
1714115890476.png
 
in code what we should declare if we are any one of this can pins?
for 0,1 and 23,22 that I want to know.
 
My question is like I have connected two can controllers one with 23,22 pin number and one with 0,1 pin number suppose I am connecting either of them can controller so in code will it matter which can controller I am defining in code? that is my concern.
 
Thank you. what about can shield v1.5 what is cs, INT pin so that I can communicate can shield v1.5 which is connected to Arduino board and one can controller which is connected to teensy board.
 
Check
https://wiki.elecrow.com/index.php?title=CAN-BUS_Shield

I can read this in the example code
Code:
// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;

MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin

But your code is
Code:
MCP_CAN CAN0(10); // Set CS to pin 10

And you said you have V1.5. So change the 10 to 9, and try again
 
if I am changing pin number 9 to 10 then I am not able to send the message through CAN but if I am changing that to 9 can initialization is failed but able to send the message so confused in pin configuration.
 
Pin 16 on MCP2515 is CS.
Check with ohm-meter where it is connected on Arduino connectors.
And try to use an oscilloscope to check the CAN-L and CAN-H line. Is the message really sent on the lines ???
 
Again, add the #define DEBUG_MODE. The driver will send additional error messages on serial port.
 
Simply add
Code:
#define DEBUG_MODE
in your skech, before
Code:
#include "MCP_CAN.h"

Rebuild the project, run, and check the messages on serial port
 
Individually both CAN controllers are working fine (one connected to Arduino uno and other to teensy 4.0) but when I want to communicate between the two boards it is not happening.
 
I have connected CANH and CANL wires of both controllers to each other and connected both boards to USB.
 
I am trying to write to can2 and after that trying to read from can2, but I am not able to read through can2. what can be possible reason? output I am getting is for some time it is printing sent after sending successful can message but after some time it is printing fail.

output:
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
sent
Loop
fail
Loop
fail
Loop
fail
Loop
fail
Loop
fail
Loop
fail


Code:
#include "Arduino.h"
#include <FlexCAN_T4.h>
#define NUM 0x03
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2;
static CAN_message_t inMsg;
static CAN_message_t msg;
void setup()
{
  Serial.begin(115200);
  can2.begin();
  can2.setBaudRate(500000);
  msg.id = 0x04000001;
  msg.len = 8;
  msg.flags.extended = 1;
  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()
{
  Serial.print("Loop");

  int fd = can2.write(msg);
  if (fd)
    Serial.print("sent");
  else
    Serial.print("fail");

  if (can2.read(inMsg) != 0)
  {

    Serial.print("Received CAN ID on can2:  0x");
    Serial.printf("%08X\n", inMsg.id);
    inMsg.id |= (NUM << 4);
    Serial.print("Modified CAN ID: 0x");
    Serial.printf("%08X\n", inMsg.id);
  }
  delay(4000);
}
 
To be able to receive something on CAN2, another node on your can bus should send something.
 
Back
Top