View previous topic :: View next topic |
Author |
Message |
Ranfo
Joined: 08 Sep 2008 Posts: 38
|
|
Posted: Tue Jun 27, 2017 10:26 am |
|
|
So...
Code: | #define CAN_BRG_PRESCALAR 8 // ??? |
How do I calculate Tq? |
|
|
Ranfo
Joined: 08 Sep 2008 Posts: 38
|
|
Posted: Tue Jun 27, 2017 10:57 am |
|
|
This works, but I don't know why. Seems some of the values are bad. CAN sniffer set at 100Kb/s. If I define just CAN_BRG_PRESCALAR what value should I use?
Quote: | #define CAN_CANCKS 1 // CANCKS
#define CAN_BRG_PRESCALAR 19 // BRP
#define CAN_BRG_PHASE_SEGMENT_1 3 // SEG1PH
#define CAN_BRG_PHASE_SEGMENT_2 3 // SEG2PH
#define CAN_BRG_SYNCH_JUMP_WIDTH 0 // SJW
#define CAN_BRG_PROPAGATION_TIME 0 // PRSEG |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19215
|
|
Posted: Tue Jun 27, 2017 1:53 pm |
|
|
We can't tell you.
It depends on your peripheral clock rate.
What you post is using 10Tq/bit, and /20 division feeding this. |
|
|
Ranfo
Joined: 08 Sep 2008 Posts: 38
|
|
Posted: Tue Jun 27, 2017 2:19 pm |
|
|
Ttelmah wrote: | We can't tell you. |
I think you mean YOU can't tell me because YOU don't know. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1900
|
|
Posted: Tue Jun 27, 2017 6:15 pm |
|
|
Google "Microchip CAN Bit Timing Calculator." Install it. Play with it. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19215
|
|
Posted: Wed Jun 28, 2017 1:26 am |
|
|
Ranfo wrote: | Ttelmah wrote: | We can't tell you. |
I think you mean YOU can't tell me because YOU don't know. |
No, I mean we can't tell you. You have never told us the clock speed you are running....
However as I said in my first reply, and repeated by Newguy, use the Microchip calculator, not all these third party tools. |
|
|
Ranfo
Joined: 08 Sep 2008 Posts: 38
|
|
Posted: Wed Jun 28, 2017 5:46 am |
|
|
Quote: | Google "Microchip CAN Bit Timing Calculator." Install it. Play with it. |
No such thing.
Quote: | You have never told us the clock speed you are running |
If you need additional information, ask for it.
I think you guys are trolling me. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1900
|
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
|
Posted: Wed Jun 28, 2017 6:58 am |
|
|
Ranfo wrote: |
Quote: | You have never told us the clock speed you are running |
If you need additional information, ask for it.
|
Eh?
A much more appropriate response to:
Quote: | You have never told us the clock speed you are running |
would be something like: "Oh yes, I understand, sorry. It's XXMHz, here is my device, fuses and clock setup code..."
The advice you are being given is sound. I use precisely the same approach: I have a common bit timing setup, but for 100kbps and 10Tq rather than, say, 125Kbps and 8 TQ. I simply alter the prescaler to accommodate different clock rates. I have PICs, 18s and 24s with 10, 20, 40, 16, 32, 64 and 80Mhz clocks all using the same basic CAN setup parameters and all talking to each other without problems.
I do not use a web app for this. I also use and recommend the Microchip CAN bit timing calculator PC application (aka MB Time) as described above. It is available for free from intrepidcs at the more direct link of https://www.intrepidcs.com/products/free-tools/ Though you do have to use half the clock rate for 24s (and others including dsPics and probably 33s, though as I don't use these yet I can't be sure) which can be confusing. |
|
|
|