11 years ago.

Newbie CAN Bus Question

Hello,

I am a newbie trying to run just a basic example of using CAN Bus on the LPC1768. I am using the CanBusExample1 project, which I imported.

The problem I am having is that when I call the can2.write method, for the first 3 times, it correctly returns 1. After that point, it will only return 0. If I reset the device, it will again work 3 times and then stop.

Looking at the source code, other than a fault, I cannot find any other reason it should ever return a 0.

Any ideas??

Thanks, Tom

(NOTE: The actual call:

if (can2.write(CANMessage(0x200, &counter, 1))) { printf("CanTx> id: 0x200 dlc: 1 data: %x\n\r", counter); counter++; } )

Are you using CAN transceivers?

posted by Adam Osborn 12 Dec 2013

Yes I do. I have two transceivers setup that loop back thru both CAN controllers. CAN is not guaranteed delivery is it? Meaning, does the CAN controller even know if a Transceiver is attached? Looking at the mbed CAN "write()" source code function, it does not appear that there is any validation code for any other potential. Meaning, a "return 1" is just located on the bottom of the function. Please let me know if I am wrong on this?

posted by Thomas Smith 12 Dec 2013
Be the first to answer this question.