× This is the optional category header for the Suggestion Box.

can write

3 years 11 months ago #289 by Fox95
can write was created by Fox95
question, do you have a example program that would work with a teeesy 3.6 and waveshare that is a Write/Send?

I need to send a value over a can bus, nothing fancy, i just need to transmit values in this format, so i can easily type to them in and change them manually:

it needs to transmit at 1M.

i need the ablilty to just change the code manually and type in the canMsg.data = values. no need for anything else as it over complicates things for me as i am very new. I have made the below code work on a arduino uno and spark fun can shield, but i'd like to switch to the teensy and waveshare CAN shield and the examples in flexcan and IFCT are too complicated for new user to hack through. the sparkfun was simple enough that i could get through it.

thanks for your help

void setup() {
canMsg1.can_id = 0x640;
canMsg1.can_dlc = 8;
canMsg1.data[0] = 0x3e;
canMsg1.data[1] = 0xfe;
canMsg1.data[2] = 0x7a;
canMsg1.data[3] = 0x00;
canMsg1.data[4] = 0x37;
canMsg1.data[5] = 0x00;
canMsg1.data[6] = 0x00;
canMsg1.data[7] = 0x00;

canMsg2.can_id = 0x036;
canMsg2.can_dlc = 8;
canMsg2.data[0] = 0x0E;
canMsg2.data[1] = 0x00;
canMsg2.data[2] = 0x00;
canMsg2.data[3] = 0x08;
canMsg2.data[4] = 0x01;
canMsg2.data[5] = 0x00;
canMsg2.data[6] = 0x00;
canMsg2.data[7] = 0xA0;

Please Log in or Create an account to join the conversation.

3 years 11 months ago #290 by collink
Replied by collink on topic can write
I did write a FlexCAN driver several years ago:


It has examples that should show you how to do what you want.

However, if you're starting out and not beholden to a specific CAN library you might try Tony Brewer's CAN libraries instead: github.com/tonton81?tab=repositories

In my opinion he's done a better job than me of making CAN drivers for Teensy.

Please Log in or Create an account to join the conversation.

Time to create page: 0.030 seconds
Powered by Kunena Forum