Rafal_Typiak
Member
Hello everyone. I'm having trouble switching from 5V to 3.3V logic for CAN transceivers. I'm currently using MCP2551s but the 'problem' is that it needs a lot of cabling as I need to drive the voltage down using logic converters. And so I've decided to use a SN65HVD230. I've built up my testing rig and .... *pfffff*. Nothing. I've set up my Teensy 4.0 to use two CAN controllers CAN 1 and CAN 2 (I'm actually driving three but I don't thing that matters here). CAN 2 is connected to the MCP2551 via a logic converter and the SN65HVD230 is connected to CAN1.
I connect a CAN-2-USB converted to a PC and see if I'm receiving a message.
Teensy creates an identical message for both buses with the exception that CAN 1 has a message with ID=1 and CAN 2 has a message with ID=2.
When reading CAN buses I can see CAN 2 messages but not CAN 1.
Can someone tell me what am I doing wrong? Maybe it has something to do with the library? I'm using a FlexCAN_T4. Maybe I've screwed up my connections? Or maybe the SN65HVD230 just doesn’t play well with Teensy 4.0, though I think I did see examples of people getting it to work.
If anyone could help me, I'd appreciate it.
Cheers,
Rafał Typiak
Code below
Connection diagram below
I connect a CAN-2-USB converted to a PC and see if I'm receiving a message.
Teensy creates an identical message for both buses with the exception that CAN 1 has a message with ID=1 and CAN 2 has a message with ID=2.
When reading CAN buses I can see CAN 2 messages but not CAN 1.
Can someone tell me what am I doing wrong? Maybe it has something to do with the library? I'm using a FlexCAN_T4. Maybe I've screwed up my connections? Or maybe the SN65HVD230 just doesn’t play well with Teensy 4.0, though I think I did see examples of people getting it to work.
If anyone could help me, I'd appreciate it.
Cheers,
Rafał Typiak
Code below
Code:
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> myCan1;
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> myCan2;
FlexCAN_T4<CAN3, RX_SIZE_256, TX_SIZE_16> myCan3;
void setup() {
// put your setup code here, to run once:
myCan1.begin();
myCan2.begin();
myCan3.begin();
myCan1.setBaudRate(250*1000);
myCan2.setBaudRate(250*1000);
myCan3.setBaudRate(250*1000);
}
void loop() {
// put your main code here, to run repeatedly:
CAN_message_t msg;
msg.len=8;
msg.id=1;
msg.buf[0]=1;
msg.buf[1]=2;
msg.buf[2]=3;
msg.buf[3]=4;
msg.buf[4]=5;
msg.buf[5]=6;
msg.buf[6]=7;
msg.buf[7]=8;
myCan1.write(msg);
msg.id=2;
myCan2.write(msg);
msg.id=3;
myCan3.write(msg);
delay (500);
}
Connection diagram below
Last edited: