Page 1 of 1

PIC24 ECAN Library

PostPosted: Mon Apr 20, 2015 8:06 am
by Coccoliso
I posted in wiki a CAN BUS library for Firewing R2 / PIC24 device here http://www.firewing.info/pmwiki.php?n=F ... User.CAN24

Re: PIC24 ECAN Library

PostPosted: Mon Apr 20, 2015 10:05 am
by Timbo
Many thanks even though I do not need can my self now.

Its great to know its there...

Re: PIC24 ECAN Library

PostPosted: Mon Apr 20, 2015 11:15 am
by Coccoliso
.. Is useful if you need to transfer data between PIC.
Some time ago I tried to link together two PIC18 in I2C and with that kind of MCU was impossible set one as "I2C master" so CAN is still the best system.

Re: PIC24 ECAN Library

PostPosted: Mon Apr 20, 2015 12:18 pm
by Timbo
I had not thought of using it just for direct Pic Pic coms. Usually I roll my one. But I can see a lot of advantages using a CAN bus.

Re: PIC24 ECAN Library

PostPosted: Mon Apr 20, 2015 12:31 pm
by Coccoliso
An example can be when you have to specialize many unit and share states between them.
I used it in domotic call system where I have different units with different functions but the state is common to all.
You can add / remove station unit or display unit without changing a single line of firmware.

Re: PIC24 ECAN Library

PostPosted: Mon Apr 20, 2015 12:45 pm
by Jerry Messina
CAN has a lot of advantages.

I tried to link together two PIC18 in I2C and with that kind of MCU was impossible set one as "I2C master"

Not sure what you mean. I link PIC18's together using I2C all the time... either using one as master and the rest as slaves or multi-masters (which is a lot more involved).

The I2C slave code is very different from the master end.

Oh, and thanks for the library!

Re: PIC24 ECAN Library

PostPosted: Mon Apr 20, 2015 1:11 pm
by Coccoliso
Jerry, I was referring to the PIC18 and some families like 46K2x.
With Swordfish about a year ago I tried with different MPU to run the application notes AN735a and AN736a and the only PIC18 that worked correctly as slave was the 18F452 and since then I have not tried again.
It still interests me so what PIC did you use?

PS: I noticed only now that have wrote in the previous post "AS MASTER" but I meant "AS SLAVE" .. and now understand the clarification.

Re: PIC24 ECAN Library

PostPosted: Mon Apr 20, 2015 3:31 pm
by Jerry Messina
I've used the 26K22, 45K50 and 87K22 in both master AND slave roles so the 46K2x should work also. I recently used a 26K22 to emulate portions of an MCP23017 I2C IO expander.

It doesn't surprise me that the mchip app notes only worked on an original 18F part. I think the app notes started out for the 16F series and were later changed for some of the 18F parts. Trouble is, there are a few different I2C hardware modules in the 18F's and they don't all work the same.

I remember having to handle some states differently.

Re: PIC24 ECAN Library

PostPosted: Mon Apr 20, 2015 5:34 pm
by Jerry Messina
Now that we're way off topic, I dug up some old sample code I had for an I2C slave and posted it on the swordfish forum

http://sfcompiler.co.uk/phpBB3/viewtopic.php?f=4&t=1948

From what I remember it worked for the K22, but it might have issues with other devices.