Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Creating a Bascom CAN-bus lib for MCP2515 chip

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Per Svensson

Bascom Member



Joined: 03 Oct 2004
Posts: 235
Location: Gothenburg, Sweden

sweden.gif
PostPosted: Wed Dec 25, 2019 11:12 pm    Post subject: Creating a Bascom CAN-bus lib for MCP2515 chip Reply with quote

I am planning to use the MCP2515 chip from Microchip for CAN-communication for a product I make.
There is already support for AVR's with built in CAN within bascom as we all know, but this limits us to a few models that accommodates a HW CAN-controller.
MCP2515 seem to be the dominating chip for standalone CAN units so I settle for this as it is very easy to get boards and chips,

Now , my question is whether there is any interest for an include library written in Bascom for this chip?
And also if there are others who want to contribute with some experience, opinions, ideas, or perhaps even code for such a lib.
My idea is to make this an open lib for this community and I plan to make the first contribution of an embryo to this lib quite soon.

At first, it looks quite easy to use this chip, but in fact, it is more complex that one might think after a quick glance.
Especially if extended identifiers shall be accepted, and I think it is best do do that from start...

Another interesting aspect is to, also from start, build the lib with CAN-OPEN in mind. This standard is partly free, but much of the information is only
available for the CAN SIG-group members (CiA) . Membership seem to be free of charge (?) but registration is needed. Do we already have CiA members
among us?
https://www.can-cia.org/can-knowledge/canopen/canopen-history/

Comments?
/Per

[b][color=red](BASCOM-AVR version : 2.0.8.2 )[/b][/color]
Back to top
View user's profile Visit poster's website
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2156

netherlands.gif
PostPosted: Wed Dec 25, 2019 11:46 pm    Post subject: Reply with quote

Have a look here: https://www.roboternetz.de/community/threads/21698-Funktionierendes-CAN-Bus-Projekt-entwickeln-unter-Bascom before doing maybe double work.
_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
Per Svensson

Bascom Member



Joined: 03 Oct 2004
Posts: 235
Location: Gothenburg, Sweden

sweden.gif
PostPosted: Thu Dec 26, 2019 3:55 pm    Post subject: Reply with quote

Thanks Evert

Lots of interesting stuff there, but still not a "final grip" of the problem as I saw it.
What I want to create is a complete API. A general library where we can find calls for all tasks that possibly is necessary when talking over CAN with an MCP2515.
Not just solutions to specific problems.
In fact I'm quite surprised that this hasn't been done before. There must be lots of Bascom'ers that have used CAN since long ago. Perhaps they are just keeping their code to themselves?

So - anyone who have experience from this chip . Please hand up! I am prepared to do the hard work and create the lib, but a little help to avoid pitfalls would be appreciated.

The first question I stumbled over was the peculiar use of extended ID. Both when reading or writing one have to set a register bit to inform the chip if it is a standard or extended ID.
Why is that necessary? An ID above 7FF is by definition an extended ID so why bother to set this bit?
There is also some strange interpretation of these ID when I look at messages through Microchips CA-analyzer. The ID is not identified continuously from 0 - 3FFF_FFFF_FFFF_FFFF.
I would have expected that ID 800 would come after 7FF, but not so. Instead 0x follows after 7FF (x for eXtended!) And when I try to stuff an extended address into the registers, it does not arrive as expected. (Standard ID's always arrive as expected). There is obviously something I do not understand... Sad
If anyone can enlighten me I would be most grateful.

/Per
Back to top
View user's profile Visit poster's website
Per Svensson

Bascom Member



Joined: 03 Oct 2004
Posts: 235
Location: Gothenburg, Sweden

sweden.gif
PostPosted: Mon Jan 06, 2020 5:20 pm    Post subject: Reply with quote

Hi again,

I have now made a general CAN-library for Bascom. Have a look here:
https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&p=78374#78374

I hope to get a lot of comments and ideas of course. Smile

Happy New Year by the way...
/Per
Back to top
View user's profile Visit poster's website
nicofer

Bascom Member



Joined: 01 May 2013
Posts: 90
Location: GRJ

southafrica.gif
PostPosted: Wed Jan 15, 2020 11:38 am    Post subject: Reply with quote

Hi
I just now notice the latest post regarding the library - very good news .

CAN on BASCOM is super easy - hope this lib will work as a second port .

Regards
Nico
Back to top
View user's profile
rkumetz

Bascom Member



Joined: 23 Jan 2007
Posts: 165
Location: Vermont

usa.gif
PostPosted: Mon Feb 10, 2020 8:02 pm    Post subject: Reply with quote

Wow. Nice work. I put an MCP2517 in a new design and have been struggling to get it going.
Finally determined that there are Microchip "quirks" that make it advisable to use an oscillator rather than
a crystal as well as advice in various places to use the MCP2518 due to the aforementioned quirks.

Now I wish I had used the (unfortunately not pin compatible) MCP2515.

Since I only have prototype boards it may be more expedient to wire in a Mikroe MCP2515 "click" board and
go this route. Nothing involving Microchip is ever simple.......

Thanks for your hard work!
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum