EmbDev.net

Forum: ARM programming with GCC/GNU tools CAN in AT91SAM7X w/FreeRTOS


Author: Andy Kunz (andykunz)
Posted on:

Rate this post
0 useful
not useful
Just wondering if anybody is using the CAN module in an AT91SAM7X, under
FreeRTOS or other.  I'm just looking for a head start at this point -
the only thing I've found was a posting on the Sparkfun site looking for
questions answered as well.

Thanks.

Andy

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Andy Kunz wrote:
> Just wondering if anybody is using the CAN module in an AT91SAM7X, under
> FreeRTOS or other.  I'm just looking for a head start at this point -
> the only thing I've found was a posting on the Sparkfun site looking for
> questions answered as well.

So far I have not worked with CAN on an SAM7X (no hardware here) so just
some ideas: There is an example-code from Atmel in a package called
AT91SAM7X256-BasicCAN-IAR430A-1_2.zip (google should find it) and a
Powerpoint-file Training for CAN with SAM7X/SAM7A3 on at91.com
(devices->7x->CAN). Together with the datasheet/manual this should get
you started with the CAN-driver. Once you have the driver working you
can use most of this code in a RTOS project. Make sure the CAN-hardware
is only accessed from on task to avoid conflicts and send/receive
to/from this task using two FreeRTOS's queues. One for messages to be
transmitted and one for received packages.

Hope this helps a little bit
Martin Thomas

Author: Andy Kunz (andykunz)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Thanks Martin.  I already have both of those.  If you look at the IAR
code it's very unhelpful (typical IAR code).

I have the basic driver written now, just working directly off the data
sheet.  I put together a spreadsheet for setting the CAN_BR register
properly.  It's rather involved to get a good selection; attached is a
first pass of the spreadsheet.

The driver runs from interrupts and uses queues to communicate with the
application.  Once I am happy with it I intend to post it here (feel
free to remind me in a week if I forget).

Andy

Author: Brett Wood (fishnchips2)
Posted on:

Rate this post
0 useful
not useful
Andy Kunz wrote:
Once I am happy with it I intend to post it here (feel
> free to remind me in a week if I forget).
>
> Andy

Hey Andy,

I have also just started to 'try' and implement CAN with FreeRTOS on the
AT91SAM7x, and seem to have followed the same path with the IAR code
etc.

Was just wondering how you were going with yours?

Thanks
Brett

Author: Andy Kunz (andykunz)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Attached are the CAN drivers I am using under FreeRTOS on a AT91SAM7X.
I've had it running between two boards for several days now without
reset.  My task has stack set to 300.

Thanks to Brett Wood for finding "the last bug" in it.

Andy

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.