Are the jm_mcp2515 object CNF values correct?
sccoupe
Posts: 118
I'm using the jm_mcp2515 object and it seems to work ok for most testing, but sometimes there are issues with it not playing nice with other CAN modules. Its specifically being used at 1mbit. Checking into the speed setting set by CNF1, CNF2, and CNF3, the values don't seem to match any that are on the list provided by the Kvaser calculator. The values below are what are called out in the jm_mcp2515.spin module.
1000:
write(CNF1, $00)
write(CNF2, $C9)
write(CNF3, $02)
return 1000
Wouldn't $00, $91, and $01 be more appropriate as suggested by the Kvaser site given the unknowns of a CAN network? I haven't tested these values yet, but would like to get some further understanding on what they are used for and why the existing spin code is set the way that it is set.
Thanks
1000:
write(CNF1, $00)
write(CNF2, $C9)
write(CNF3, $02)
return 1000
Wouldn't $00, $91, and $01 be more appropriate as suggested by the Kvaser site given the unknowns of a CAN network? I haven't tested these values yet, but would like to get some further understanding on what they are used for and why the existing spin code is set the way that it is set.
Thanks
Comments
You know, Microchip makes a data sheet available which if you don't have, you should download and study before criticizing my code. I'm not saying that you aren't correct, but you're just flailing, hoping someone will back you up which saves you the hard work of studying the data sheet. Step up, read the data sheet, show me where I erred, and I'll change my code.
-- http://ww1.microchip.com/downloads/en/DeviceDoc/21801G.pdf
That particular object is running in a commercial application without issue. To be fair, all other nodes are using the same code so that could be masking things. Still, I validated the object and hardware with a commercial CAN bus adapter and software.
-- http://www.phytools.com/PCAN_USB_Adapter_CAN_USB_Interface_IPEH_002021_p/ipeh-002021.htm
I'll step up here and apologize if it sounds like i'm criticizing the work that you put out to the community freely. Now that I re-read how I put it, it does sound a little off. As far as looking for flailing agreement, I beg to differ. Your code comments that the CNF values are from the Kvaser calculator and is where my question is from. If all nodes are using the same bit timing, them I'd expect that everything would work fine. However, the current situation is with equipment of unknown bit timing, so one can only hope that it is standard. Now back to the MCP2515 setup... If a rate of 1mbit with a 16mhz crystal is put into the calculator and up to 1.5% error allowed, none of the CNF values in the list line up with the ones in your code, so their must be a reason for it.
In the future, i'll be more sensitive to how my questions are worded. Emotion is so difficult to text out.
Thanks
Really? Here's the output from that calculator:
See the values in the circle? I know what you're thinking: "But your CNF2 value is $C9, not $89!"
Let's have a look at my code, shall we? -- just the header portion of the "offending" method.
Note that pesky second comment: manually added SAM bit to CNF2 (for 3x buss sampling)
If we take the time to crack open the data sheet (hint, hint), we find the SAM bit is bit6 ($40) of CNF2. $89 | $40 is.... $C9.
Case closed.
Am I irritated? You bet. Take a shot at me if you want, but if you're unwilling to understand my code before criticizing it, be prepared to unleash my inner tiger.
Happy Thanksgiving everyone!
Regards
No, David. Your questions are always thoughtful.
For those that don't know me, I don't mind being challenged -- in fact, I benefit from those exchanges. What I find tiresome is people challenging me (and others) without doing some basic research or attempting understanding.
If you change the baud rate, you need to get new settings.
If you have long wires or many drops, you may need to explore several alternative settings.
If you don't have proper termination (at least a 300 ohm resistor), you are going to get reflections on the wire that will degrade performance.
Even the calculators will give you more than one setting combination that may work. There is a bit of art in getting a high performance CANbus to operate smoothly.
But if you have trouble, you need to consider that you are expecting too much speed or too much traffic on the CANbus.
The documentation for the MCP2515 is a bit large, and requires reading until one understands it.