View previous topic :: View next topic |
Author |
Message |
andro
Joined: 12 Mar 2007 Posts: 94 Location: Ljubljana
|
Posted: Thu Feb 06, 2020 10:57 pm Post subject: |
|
|
Hi Per,
It seems to me, You do not use INT pin (from MCP2515). Is that correct?
BR
Andrej |
|
Back to top |
|
|
Per Svensson
Joined: 03 Oct 2004 Posts: 235 Location: Gothenburg, Sweden
|
Posted: Fri Feb 07, 2020 9:48 am Post subject: |
|
|
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 |
|
|
andro
Joined: 12 Mar 2007 Posts: 94 Location: Ljubljana
|
Posted: Fri Feb 07, 2020 1:05 pm Post subject: |
|
|
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 |
|
|
rkumetz
Joined: 23 Jan 2007 Posts: 165 Location: Vermont
|
Posted: Fri Feb 14, 2020 11:02 pm Post subject: Baud Rate Register Values |
|
|
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 |
|
|
Per Svensson
Joined: 03 Oct 2004 Posts: 235 Location: Gothenburg, Sweden
|
Posted: Tue Feb 18, 2020 1:48 pm Post subject: |
|
|
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 |
|
|
rkumetz
Joined: 23 Jan 2007 Posts: 165 Location: Vermont
|
Posted: Tue Feb 18, 2020 3:06 pm Post subject: |
|
|
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 |
|
|
Memen
Joined: 06 May 2016 Posts: 13
|
Posted: Fri Oct 23, 2020 4:59 pm Post subject: |
|
|
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 |
|
|
|