CAN bus implementation

Technical questions regarding the XTC tools and programming with XMOS.
omega7
Active Member
Posts: 32
Joined: Thu Jun 03, 2010 12:16 pm

CAN bus implementation

Post by omega7 »

Hi,
Is there anyone having experience with the CAN bus, implemented with XMOS? Are there C routines available for download? Searching the internet I found that more developers are looking for sources :?.
Any help or links are welcome!
Martin


User avatar
shawn
XCore Addict
Posts: 238
Joined: Thu Dec 17, 2009 5:15 am

Post by shawn »

Sure seems that CAN is a good candidate for XC and its XMOS eventful core.
I haven't read alot yet on CAN on the XMOS SDS. I'll bet there is C source to
get the pieces then optimize in XC. Controller Area Networks are big money
in the auto world. Me myself I would Like to hang a CAN or 2 off the side of a
Flexray typo Xbus jamming with aggregated FastXlinks.
,but thats over the edge
.
.
.
User avatar
jonathan
Respected Member
Posts: 377
Joined: Thu Dec 10, 2009 6:07 pm

Post by jonathan »

There is a CAN bus implementation that has been done on the XMOS devices using an external PHY.

Old thread briefly discussing it:

http://www.xmoslinkers.org/forum/viewto ... 97&start=0

The docs and code are here:

http://archive.xmoslinkers.org/node/296

You might need to click through a warning about Xlinkers no longer being active to get it.
A software defined silicon implementation of a CAN controller. The following is an extract of the first page of the attached documentation:

******************************************************
1 Introduction

This document describes the XMOS implementation of the CAN protocol on an XS1-G4 chip using the XC1 development board.

Please note this is an early release of this API as the implementation is not complete yet. This document will be updated to reflect further progress.

2 API details

Details of the API are included in files:

• include/CanConfig.h
• include/CanFunctions.h
• include/CanIncludes.h

Include the include/CanIncludes.h file which brings in all the needed APIs to your project. This API implements the bottom two layers of the ISO/OSI reference model, namely the Physical Layer and the Data Link Layer. The implementation maps those two layers into two separate hardware threads:

• void CanPhyRx(chanend toData, buffered in port:32 canRX, port canTX)
• void CanDataRx(chanend toNetwork, chanend fromPhy)
• void CanPhyTx(chanend fromData, in port canRX, port canTX)
• void CanDataTx(chanend fromNetwork, chanend toPhy)

******************************************************

Please refere to the attached documentation for more information.

In the build directory, you'll find a can.xe already built using the desktop tools version 9.2.2. Using loop back configuration and a minimal debug output, with all the error checking activated, it will send and receive 1000 fixed CAN packets. The output is just a progress indication after every 10 packets (i.e. 1% progress).
Files replicated here as about 5 people have previously asked for CAN bus; I believe the old Xlinkers site is no longer being Google-indexed but there is still an awful lot of project material that has not been moved over.
You do not have the required permissions to view the files attached to this post.
Image
omega7
Active Member
Posts: 32
Joined: Thu Jun 03, 2010 12:16 pm

Post by omega7 »

This helps a lot! What does this implementation need regarding threads and cores?
Should I reserve a core for CAN bus?
User avatar
jonathan
Respected Member
Posts: 377
Joined: Thu Dec 10, 2009 6:07 pm

Post by jonathan »

omega7 wrote:This helps a lot! What does this implementation need regarding threads and cores?
Should I reserve a core for CAN bus?
The source and documentation are linked above at the bottom of my post. This isn't a complete implementation (as the docs say). I haven't dug into it to check thread (or memory) usage, sorry.
Image
User avatar
xcorific
Member++
Posts: 17
Joined: Fri Aug 12, 2011 2:36 pm

Post by xcorific »

Just wondering if anyone has actually tried the CANbus code attached in one of the above posts. I am looking into CAN/CANopen and thought it might be a good start since I am pretty new to this communication layer.
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

xcorific wrote:Just wondering if anyone has actually tried the CANbus code attached in one of the above posts. I am looking into CAN/CANopen and thought it might be a good start since I am pretty new to this communication layer.
I'm not familiar with the code itself, but there is a more up to date version on github:

https://github.com/xcore/sc_can
User avatar
matrix
Active Member
Posts: 62
Joined: Sat Sep 17, 2011 12:05 pm

Post by matrix »

@xcorific

Well, I devloped once a text and symbol based communication system for my company.
There are a couple of CAN- connected stations, with LCD-screens and piezo buttons, where
users can select and send messages to other users.

It is a simple system, based on a properitary protocol with near to zero overhead.

Now we are moving on to CANopen, because we want to go with standards. Also, we want
to replace many existing in-vehicle sensors with CANopen sensors.

It would be nice to have a CANopen stack for XMOS hardware, but I think that is not a simple
undertaking. The protocol is quite complicated, the complete spec with all the device profiles is also
not availbable for free. So, in this sense the 'open' in CANopen is a bit missleading.

matrix
User avatar
matrix
Active Member
Posts: 62
Joined: Sat Sep 17, 2011 12:05 pm

Post by matrix »

Hi all,

Has anyone thought of license fees, in case of implementing a CAN
controller in silicon ? I am sure about the scenario with XMOS. In the past, If one
wanted to do that on FPGA, and it was not just for academic purposes, a license
fee was due because CAN is a Bosch patented technology.
User avatar
dan
Experienced Member
Posts: 102
Joined: Mon Feb 22, 2010 2:30 pm

Post by dan »

Regarding canbus, the link richard posted above is good to go and has been pretty well tested.

For CANopen, it'd be great to see a project to work on this. There is an open source stack design for microcontrollers (there is an AVR port) called CANfestival.

http://www.canfestival.org/

Anyone wanting to port that to XMOS, or do their own from-scratch implementation please get in touch - we'd be interested to discuss how we could support this project.

Cheers,

Dan