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 CCS Technical Support

canbus kit baud rate settings help me please

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Tufican



Joined: 23 Feb 2011
Posts: 10
Location: Turkey- izmir

View user's profile Send private message

canbus kit baud rate settings help me please
PostPosted: Thu Mar 10, 2011 10:49 am     Reply with quote

Hi everybody I have a canbus development kit and I can't find what is my baud rate?

How can I change this baud rate?
Code:

can_putd(0x400, buffer, 8 1, TRUE, FALSE);

Where is baud rate settings?

Thank you
collink



Joined: 08 Jan 2010
Posts: 137
Location: Michigan

View user's profile Send private message Visit poster's website

PostPosted: Thu Mar 10, 2011 12:16 pm     Reply with quote

Your baud rate is set when you call can_init(); Within that function there is a call to: can_set_baud();

If you look at the can_set_baud() function you'll see it setting the baud rate. The manual for your PIC chip has the info on what those registers mean.

But, as an overview: The canbus baud is the main CPU clock scaled by some power of two and then sampled over X time quanta. It explains all this in the manual.
Tufican



Joined: 23 Feb 2011
Posts: 10
Location: Turkey- izmir

View user's profile Send private message

PostPosted: Thu Mar 10, 2011 1:25 pm     Reply with quote

collink wrote:
Your baud rate is set when you call can_init(); Within that function there is a call to: can_set_baud();

If you look at the can_set_baud() function you'll see it setting the baud rate. The manual for your PIC chip has the info on what those registers mean.

But, as an overview: The canbus baud is the main CPU clock scaled by some power of two and then sampled over X time quanta. It explains all this in the manual.


thank you i see this now. but i dont see how can i change? wich command

and can you tell me what is my baud rate now:(

how can i see my baud rate from this code and how can i calculate this thanks for helps and sorry about my bad english
Code:

c:\program files\picc\drivers\can-18xxx8.c


+++++++++++++++++++++++++
Pathname substituted for code.

Reason: Forum rule #10

10. Don't post the CCS example code or drivers, or ask for such code and drivers

Forum rules:
http://www.ccsinfo.com/forum/viewtopic.php?t=26245

-- Forum Moderator
+++++++++++++++++++++++++
collink



Joined: 08 Jan 2010
Posts: 137
Location: Michigan

View user's profile Send private message Visit poster's website

PostPosted: Thu Mar 10, 2011 1:45 pm     Reply with quote

The settings it uses for the baud rate are in the .H file it's including but here is a quick overview of what they mean:

First, start with the clock rate of your pic chip. For giggles we'll say you are running at 40MHz.

Then, remember that all values you set are actually one higher than you set them to. For instance, if you set your Seg1 time to 1 then it's really 2.

Then, take your PIC clock rate and divide it by two. Then divide it again by whatever your baud prescaler is set at (remember to add one).

So, let's say you put a value of 1 in for your prescale. That's really two so your time quanta value is 40000000 / 2 / 2 = 10000000.

That's 10 million time quanta per second. So, if you want 500K baud then you need to soak up 20 of those time quanta per baud. There is always 1 start TQ so you need 19 more. There are three places you can put them. The propagation time, seg1, and seg2. You could set your propagation to 2 (remember that will make it 3!), your Seg 1 to 7, your seg2 to 7. That's 1 + 3 + 8 + 8 = 20TQ.

For, for this example, if you have a clock of 40Mhz, a prescale value of 1, a propegation of 2, a seg1 of 7, and a seg2 of 7 then your baud will be 500k.

That is how you calculate baud rates for canbus on a PIC chip. All of this is found in the pic chip manual too.
Tufican



Joined: 23 Feb 2011
Posts: 10
Location: Turkey- izmir

View user's profile Send private message

PostPosted: Thu Mar 10, 2011 2:15 pm     Reply with quote

thank you so so so much man here is great forum Smile THANKS
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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