Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

CAN-bus library for general CAN-bus controller chip MCP2515
Goto page Previous  1, 2
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
andro

Bascom Member



Joined: 12 Mar 2007
Posts: 94
Location: Ljubljana

slovenia.gif
PostPosted: Thu Feb 06, 2020 10:57 pm    Post subject: Reply with quote

Hi Per,

It seems to me, You do not use INT pin (from MCP2515). Is that correct?

BR
Andrej
Back to top
View user's profile
Per Svensson

Bascom Member



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

sweden.gif
PostPosted: Fri Feb 07, 2020 9:48 am    Post subject: Reply with quote

Hi Andro,

Yes I skipped the INT pin and use register polling instead.
SPI is so fast so I decided not to use interrupt.
But it is of course easy to let DataReady generate an interrupt, if that better suits the application.
Perhaps we should let a compiler directive select between hard INT or soft polling?

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

Bascom Member



Joined: 12 Mar 2007
Posts: 94
Location: Ljubljana

slovenia.gif
PostPosted: Fri Feb 07, 2020 1:05 pm    Post subject: Reply with quote

That would be a major change of the concept. First I would start as it is - without INT / ISR handling.
I already prepared some HW
BR
A
Back to top
View user's profile
rkumetz

Bascom Member



Joined: 23 Jan 2007
Posts: 165
Location: Vermont

usa.gif
PostPosted: Fri Feb 14, 2020 11:02 pm    Post subject: Baud Rate Register Values Reply with quote

I noticed that the values being written to the baud rate registers do not match those shown in the calculation table above the code.
In particular, CNF1 @ 250K and 500K do not match. They may have been swapped.
Back to top
View user's profile
Per Svensson

Bascom Member



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

sweden.gif
PostPosted: Tue Feb 18, 2020 1:48 pm    Post subject: Reply with quote

Hi rkumetz

Yes there was a typing error in the CASE for 250 and 500 kbit/s
The table was right however. I double-checked it against Kvasers's baudrate calculator.
Here is the correct CASE table:

Select Case Baudrate 'kbit/s
Case 10 : Cnf1 = &H27 : Cnf2 = &HBF : Cnf3 = &H2
Case 20 : Cnf1 = &H13 : Cnf2 = &HBF : Cnf3 = &H2
Case 50 : Cnf1 = &H09 : Cnf2 = &HB5 : Cnf3 = &H1
Case 125 : Cnf1 = &H03 : Cnf2 = &HB5 : Cnf3 = &H1
Case 250 : Cnf1 = &H03 : Cnf2 = &H91 : Cnf3 = &H1 '<- Corrected Feb.18 2020
Case 500 : Cnf1 = &H00 : Cnf2 = &HB5 : Cnf3 = &H1 '<- Corrected Feb.18 2020
Case 800 : Cnf1 = &H00 : Cnf2 = &H9A : Cnf3 = &H1
Case 1000 : Cnf1 = &H00 : Cnf2 = &H91 : Cnf3 = &H1
Case Else : Can_baud = 1 : Exit Function 'Error (ignore new baud)
End Select

How many people have tried this CAN-implementation? Is would be interesting to know.
Just wave hand, or give a short comment here if you have the time...

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

Bascom Member



Joined: 23 Jan 2007
Posts: 165
Location: Vermont

usa.gif
PostPosted: Tue Feb 18, 2020 3:06 pm    Post subject: Reply with quote

Thanks for double checking. I looked at the values in the comment table and corrected them but
since I am new to CAN I wanted to make sure that I was not making a mistake somewhere.

This code is super helpful. I started out with the MCP2517 and then found that there are apparently
some odd "quirks" such as an unstable oscillator so I switched to the pin compatible MCP2518.
For my simple application I found that the '2518 was horribly complex compared to the '2515 and
the added functionality did not outweigh the extra time to get it going. There is also virtually little
information out there about the 2518 which makes finding examples tough. I bought an MikroElektronika
"Click" board and hand wired it to the pads for the MCP2518. In an hour I was way ahead
of where I started out.

Thanks again!
Back to top
View user's profile
Memen

Bascom Member



Joined: 06 May 2016
Posts: 13

blank.gif
PostPosted: Fri Oct 23, 2020 4:59 pm    Post subject: Reply with quote

Connected to listen to the bus at 500 kbps. I get the only result after turning it on.

Got: ID=09C7A785h Extended=1 INT=10100001 STATUS=00000000 HIT=0 FILTER=0 ROLLOVER=1 SOURCE=0 N=82 RxData: 239 248 165 127 239 22 53 167 0 0 0 12 186 159 251 78 155 231 236 118 141 173 59 90 0 0 0 240 169 56 244 82 239 248 165 127 239 22 53 167 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 57 32 50 50 32 53
Back to top
View user's profile AIM Address
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
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