chipKIT® Development Platform

Inspired by Arduino™

CAN bus example code

Created Tue, 30 Aug 2011 00:49:54 +0000 by supermac


supermac

Tue, 30 Aug 2011 00:49:54 +0000

Hi, Are there any working examples yet?


GeneApperson

Tue, 30 Aug 2011 21:06:29 +0000

There should be a working demo in the example folder with the library. This example loops CAN1 back to CAN2.

Gene Apperson Digilent


rftech

Tue, 06 Sep 2011 16:16:34 +0000

Gene,

I finally got around to trying the Can Bus library, however the example will not compile, giving multiple errors related to "FALSE and TRUE" statments in the main example, PDE, errors related to BOOL statements in the canbus.h file, calls to p32xxxx.h not able to find this file, ect ect.

It appears to throw 10's of errors preventing compiling.

I am using the newst MPIDE 2011-08-22, and the librarys from the Digilent Website.

Do you have an updated Canbus library that works on your PC that you can share or is there something else I need to do to get this working. I am fairly new to programming so having a working example is essential to my being able to adapt the code to my project.

Thanks in advance.


GeneApperson

Mon, 12 Sep 2011 19:00:19 +0000

For anyone trying to use the CAN library and getting tons of compile errors. Make sure that you have the correct board selected. If you try building this library with an Uno32 selected as the current board, you will get a lot of compiler errors.

I spent about an hour trying to figure out why I was getting all of the errors, and then realized that I had the wrong board selected.

The CAN demo included with the library does compile and run. (At least if did that last time I built and ran it).

Gene Apperson Digilent


MGLSOFT

Mon, 09 Jan 2012 18:55:11 +0000

The example provided with CANBus libraries use the standard mode, in my case I use the extended mode, but changing all references of SID to EID and try to compile it, generate hundreds of errors, the first says that the structure of such EID is undefined, but I searched and searched and can not find that file to redefine and to use extended mode ... Can you help me do it?


MGLSOFT

Tue, 17 Jan 2012 01:18:22 +0000

You could use the example in extended mode. Just can document the changes I made what I come up here for others to use.


iainism

Tue, 03 Apr 2012 12:18:53 +0000

Hi,

Where is the example code located please? I've grepped the MPIDE installation tree for canbus.h and not found it.

(Also, does the code work with the MX7cK please, as I'm considering using this for my project rather than the chipkit and network shield so I have a single board solution?)

Thanks,

Iain


dc101

Thu, 05 Apr 2012 15:14:35 +0000

I don't have the CAN bus shield, but I think you're looking the example which is in the chipkit CAN/ethernet library and is located here: http://www.digilentinc.com/Agreement.cfm?DocID=DSD-0000318

Enjoy! -Tim

Hi, Where is the example code located please? I've grepped the MPIDE installation tree for canbus.h and not found it. (Also, does the code work with the MX7cK please, as I'm considering using this for my project rather than the chipkit and network shield so I have a single board solution?) Thanks, Iain


iainism

Thu, 05 Apr 2012 17:14:46 +0000

Brilliant - thanks Tim, I'm downloading it now to take a look.

Iain


whitnasty1

Thu, 02 Aug 2012 20:50:52 +0000

I am not using the CAN network shield, however I do have a boat load of 8 pin DIP MCP 2551 CAN transceivers, I am very eager to try this out with the chipKIT MAX32, but I am having a hard time trying to locate a schematic to hook up one or two transceivers. If anyone has access to a schematic so I can interface the transceiver(s) with the MAX32 I would greatly appreciate it and I will post back results. All help is greatly appreciated, thanks alot guys!


sundar@19

Mon, 30 Nov 2020 10:38:25 +0000

Hi , I am using chipkit network shield (max32) and I am running CAN examples from digilent. Is there any library support from chipkit ? Thanks!

CanDemo.cpp.o: In function doCan2Interrupt()': C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:742: undefined reference to CAN::getModuleEvent()' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:749: undefined reference to CAN::getPendingEventCode()' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:766: undefined reference to CAN::enableChannelEvent(CAN::CHANNEL, CAN::CHANNEL_EVENT, bool)' CanDemo.cpp.o: In function doCan1Interrupt()': C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:670: undefined reference to CAN::getModuleEvent()' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:677: undefined reference to CAN::getPendingEventCode()' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:694: undefined reference to CAN::enableChannelEvent(CAN::CHANNEL, CAN::CHANNEL_EVENT, bool)' CanDemo.cpp.o: In function __static_initialization_and_destruction_0': C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:102: undefined reference to CAN::~CAN()' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:101: undefined reference to CAN::~CAN()' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:101: undefined reference to CAN::CAN(CAN::MODULE)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:102: undefined reference to CAN::CAN(CAN::MODULE)' CanDemo.cpp.o: In function initCan1(unsigned long)': C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:243: undefined reference to CAN::enableModule(bool)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:245: undefined reference to CAN::setOperatingMode(CAN::OP_MODE)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:247: undefined reference to CAN::getOperatingMode()' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:263: undefined reference to CAN::setSpeed(CAN::BIT_CONFIG const*, unsigned long, unsigned long)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:274: undefined reference to CAN::assignMemoryBuffer(void*, unsigned long)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:282: undefined reference to CAN::configureChannelForTx(CAN::CHANNEL, unsigned long, CAN::TX_RTR, CAN::TXCHANNEL_PRIORITY)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:283: undefined reference to CAN::configureChannelForRx(CAN::CHANNEL, unsigned long, CAN::RX_DATA_MODE)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:292: undefined reference to CAN::configureFilter(CAN::FILTER, unsigned long, CAN::ID_TYPE)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:293: undefined reference to CAN::configureFilterMask(CAN::FILTER_MASK, unsigned long, CAN::ID_TYPE, CAN::FILTER_MASK_TYPE)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:294: undefined reference to CAN::linkFilterToChannel(CAN::FILTER, CAN::FILTER_MASK, CAN::CHANNEL)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:295: undefined reference to CAN::enableFilter(CAN::FILTER, bool)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:303: undefined reference to CAN::enableChannelEvent(CAN::CHANNEL, CAN::CHANNEL_EVENT, bool)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:304: undefined reference to CAN::enableModuleEvent(CAN::MODULE_EVENT, bool)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:309: undefined reference to CAN::setOperatingMode(CAN::OP_MODE)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:310: undefined reference to CAN::getOperatingMode()' CanDemo.cpp.o: In function initCan2(unsigned long)': C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:340: undefined reference to CAN::enableModule(bool)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:342: undefined reference to CAN::setOperatingMode(CAN::OP_MODE)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:343: undefined reference to CAN::getOperatingMode()' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:359: undefined reference to CAN::setSpeed(CAN::BIT_CONFIG const*, unsigned long, unsigned long)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:370: undefined reference to CAN::assignMemoryBuffer(void*, unsigned long)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:378: undefined reference to CAN::configureChannelForTx(CAN::CHANNEL, unsigned long, CAN::TX_RTR, CAN::TXCHANNEL_PRIORITY)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:379: undefined reference to CAN::configureChannelForRx(CAN::CHANNEL, unsigned long, CAN::RX_DATA_MODE)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:388: undefined reference to CAN::configureFilter(CAN::FILTER, unsigned long, CAN::ID_TYPE)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:389: undefined reference to CAN::configureFilterMask(CAN::FILTER_MASK, unsigned long, CAN::ID_TYPE, CAN::FILTER_MASK_TYPE)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:390: undefined reference to CAN::linkFilterToChannel(CAN::FILTER, CAN::FILTER_MASK, CAN::CHANNEL)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:391: undefined reference to CAN::enableFilter(CAN::FILTER, bool)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:399: undefined reference to CAN::enableChannelEvent(CAN::CHANNEL, CAN::CHANNEL_EVENT, bool)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:400: undefined reference to CAN::enableModuleEvent(CAN::MODULE_EVENT, bool)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:405: undefined reference to CAN::setOperatingMode(CAN::OP_MODE)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:406: undefined reference to CAN::getOperatingMode()' CanDemo.cpp.o: In function setup': C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:165: undefined reference to CAN::attachInterrupt(void (*)())' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:166: undefined reference to CAN::attachInterrupt(void (*)())' CanDemo.cpp.o: In function txCAN1(unsigned long)': C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:433: undefined reference to CAN::getTxMessageBuffer(CAN::CHANNEL)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:458: undefined reference to CAN::updateChannel(CAN::CHANNEL)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:464: undefined reference to CAN::flushTxChannel(CAN::CHANNEL)' CanDemo.cpp.o: In function txCAN2(unsigned long)': C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:492: undefined reference to CAN::getTxMessageBuffer(CAN::CHANNEL)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:517: undefined reference to CAN::updateChannel(CAN::CHANNEL)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:523: undefined reference to CAN::flushTxChannel(CAN::CHANNEL)' CanDemo.cpp.o: In function rxCAN1()': C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:564: undefined reference to CAN::getRxMessage(CAN::CHANNEL)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:576: undefined reference to CAN::updateChannel(CAN::CHANNEL)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:577: undefined reference to CAN::enableChannelEvent(CAN::CHANNEL, CAN::CHANNEL_EVENT, bool)' CanDemo.cpp.o: In function rxCAN2()': C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:617: undefined reference to CAN::getRxMessage(CAN::CHANNEL)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:629: undefined reference to CAN::updateChannel(CAN::CHANNEL)' C:/Users/sundar krishna/AppData/Local/Temp/build158564042545731317.tmp/CanDemo.cpp:630: undefined reference to CAN::enableChannelEvent(CAN::CHANNEL, CAN::CHANNEL_EVENT, bool)' collect2: ld returned 1 exit status