Jump to content

Recommended Posts

The on board CAN controller fitted to the PIC182680 when used in legacy mode is surprizingly similar to the MCP2515, if you ignore the windowing system for relocating buffers int base RAM it is in fact easier because you dont have the overhead of SPI comms.

Unlike the MCP2515 There is no RESET instruction (the processor reset does that!)

 

All you need to do to set up for standard (Not extended) legacy is

 

Request config mode

When config granted (should be immediate)

 

Set up the three control register for setting the bit period (follow the example for the external CAN)

Set the TX regs priorities etc(again identical to external)

Set up RX regs priorites etc(again identical to external)

 

Set up any required MASKS and Filters

Set up any interrupts (again not needed you can always poll)

Set Normal mode and off you go!

 

Note that you do not need to set any masks and filters but the controller will accept all received messages

 

That should get you going. Dont forget you still need a CAN driver such as the MCP2551.

 

 

Have fun!

 

Does anyone have any example 'C' code implementing the on board CAN controller in the 18F2680 or related chips?  The only thing I could find on the Sourceboost site was interfacing to an external controller via SPI.

 

Thanks

Link to post
Share on other sites

My experiances with CAN are possibly somewhat less than Picxie's but i disagree with him

on using the internal CAN vs the external SPI, just based on timing issues and CAN bus

interfacing adaptability. As for SPI overhead ... i find it is far less than handling all the

common aspects of CAN since the MCP2515 does most everything by itself. Why handle

every message on the bus if your only interested in a few?

 

Using the MCP2515 via SPI means your more flexible to connect to almost any CAN

bus frequency and can actually control/monitor multiple CANs since they will happily

idle, interrupt, capture, etc any data you tell them to.

 

It always comes back to what your expecting to do i guess, if your only talking to the CAN

then internal is probably the best choice. None of my projects ever seem that simple

anymore and they all end up with a lot of components that i am constantly looking

for parts to run independant of the main mcu.

 

i am as well interested in looking at other's internal CAN code, as always, since in the near

future i am looking at doing a CAN monitor on a bus that i know the specifications for and

want to handle all the messages.

Link to post
Share on other sites

Emte, I don't know what your expectations of the internal CAN interface are but I guess it pretty low and based upon experience of other serial PIC peripherals:)

 

The Microchip guys have done a good job (for a change) with CAN interface, it does all the work of filtering and buffering and requires very little processor overhead once set, up consider it more of an MCP2515 conjoined twin.

 

 

However... the documentation supplied for the PIC18F2680 CAN is overwhelming (particularly for a CAN virgin) due to the complication thrown in by eCAN, it would be easier on the eyes if it was split into a standard CAN and enhanced CAN chapter.

Link to post
Share on other sites

Thanks for the hints. I have doing CAN on Freescale/Motorola START12 controllers for years and am looking for a low cost solution to a smaller application. The documentaion on the PIC18F2680 is quite mountainous and was just looking for something to bypass the learning curve a little.

 

 

The on board CAN controller fitted to the PIC182680 when used in legacy mode is surprizingly similar to the MCP2515, if you ignore the windowing system for relocating buffers int base RAM it is in fact easier because you dont have the overhead of SPI comms.

Unlike the MCP2515 There is no RESET instruction (the processor reset does that!)

 

All you need to do to set up for standard (Not extended) legacy is

 

Request config mode

When config granted (should be immediate)

 

Set up the three control register for setting the bit period (follow the example for the external CAN)

Set the TX regs priorities etc(again identical to external)

Set up RX regs priorites etc(again identical to external)

 

Set up any required MASKS and Filters

Set up any interrupts (again not needed you can always poll)

Set Normal mode and off you go!

 

Note that you do not need to set any masks and filters but the controller will accept all received messages

 

That should get you going. Dont forget you still need a CAN driver such as the MCP2551.

 

 

Have fun!

 

Does anyone have any example 'C' code implementing the on board CAN controller in the 18F2680 or related chips?  The only thing I could find on the Sourceboost site was interfacing to an external controller via SPI.

 

Thanks

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...