CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

DSPIC33 ECAN What am I missing?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ranfo



Joined: 08 Sep 2008
Posts: 38

View user's profile Send private message

PostPosted: Tue Jun 27, 2017 10:26 am     Reply with quote

So...
Code:
#define CAN_BRG_PRESCALAR 8 // ???

How do I calculate Tq?
Ranfo



Joined: 08 Sep 2008
Posts: 38

View user's profile Send private message

PostPosted: Tue Jun 27, 2017 10:57 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 27, 2017 1:53 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 27, 2017 2:19 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 27, 2017 6:15 pm     Reply with quote

Google "Microchip CAN Bit Timing Calculator." Install it. Play with it.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Wed Jun 28, 2017 1:26 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jun 28, 2017 5:46 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jun 28, 2017 6:23 am     Reply with quote

Ranfo wrote:
Quote:
Google "Microchip CAN Bit Timing Calculator." Install it. Play with it.

No such thing.


It's literally the first hit when you type the above (plus "download") into google:

http://lmgtfy.com/?q=microchip+can+bit+timing+calculator+download
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Wed Jun 28, 2017 6:58 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
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


Powered by phpBB © 2001, 2005 phpBB Group