I'm stuck figuring this out

I have this code running continuously in my Tesla powered Mustang and it works great controlling my DC to DC converter and electric power steering. Now I want to use this code to run a couple things in Realdash and for reason I cannot figure out how to make the Can1 start when feeding 3.3 volts into pin 14 to turn it on instead of it running all the time. I've watch hours of tutorials and everything I've tried does not work. I left all my trials out of it because of it being a mess. I'm using a Teensy 4.0. I want to turn it on with Pin 14 and shut it off with pin 15.

#include <FlexCAN_T4.h>

int parkPin=14;
int revPin=15;
int dt=500;


FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> myCan1;


void setup() {
  // put your setup code here, to run once:
  delay(dt);
  pinMode(parkPin, INPUT);
  pinMode(revPin, INPUT)
  
myCan1.begin();
myCan1.setBaudRate(500*1000);


}

void loop() {
  // put your main code here, to run repeatedly:
CAN_message_t frame;
frame.id = 0x201;
frame.len = 8;
frame.buf[0] = 0x0C;
frame.buf[1] = 0x80;
frame.buf[2] = 0x00;
frame.buf[3] = 0x00;
frame.buf[4] = 0x27;
frame.buf[5] = 0x10;
frame.buf[6] = 0x14;
frame.buf[7] = 0x00;
myCan1.write(frame);
  
 if ( myCan1.read(frame) ) 
 {
 Serial.print("CAN1 "); 
 Serial.print("  ID: 0x"); Serial.print(frame.id, HEX );
 }

 
digitalWrite(parkPin, !digitalRead(parkPin));
delay (dt);
}

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

That spells schematics! Else You might receive useless guesses putting Your car at risk. Links to datasheets of special devices is highly wanted.

Hi Railroader, Well I guess you did not understand my question. I do have schematics and have build Mustang Tesla conversions for years but that's not my issue. Thank you for taking the time though.

I read your post and have no idea what the question might be, except that, as you say, "everything I've tried does not work".

For hints on successful posting, please read and follow the instructions in the "How to get the best out of the forum" post.

1 Like

@roadstercycle

First - please add the code tags to your message!

And second - please show the piece of the code, where you try to control the pins depending on CAN messages? I don't see nothing similar in the code.

1 Like

Your question is no problem but how on earth are helpers supposed to get hold of Your build without requested documentation? Just, good luck to You.

I'm having the post deleted so all is good.

It's Your choice.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.