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

bad CAN bit timing

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



Joined: 30 Jun 2011
Posts: 3
Location: France

View user's profile Send private message

bad CAN bit timing
PostPosted: Tue Jul 05, 2011 3:54 am     Reply with quote

Hi everybody
I actually developed a CAN bus interface which is running with an external 16MHz (100ppm) XO clock. I want a can bitrate up to 1Mbit/s. I have a PIC18F45K80 and CAN CCS library. I configure the can_set_baud function with these parameters :
Code:

 BRGCON1.sjw=0;  //CAN_BRG_SYNCH_JUMP_WIDTH;
 BRGCON2.prseg=1;  //CAN_BRG_PROPAGATION_TIME;
 BRGCON2.seg1ph=1;  //CAN_BRG_PHASE_SEGMENT_1;
 BRGCON2.sam=CAN_BRG_SAM;
 BRGCON2.seg2phts=CAN_BRG_SEG_2_PHASE_TS;
 BRGCON3.seg2ph=2;  //CAN_BRG_PHASE_SEGMENT_2;
 BRGCON3.wakfil=CAN_BRG_WAKE_FILTER;

with prescaler @ 0 I have a 125ns Tq and configuration above give

1 Tq for jumpwidth
2 Tq for phase seg 1
2 Tq for propagation time
3 Tq for phase seg 2

So 8 Tq . I have a CAN PEAK user interface on my computer which receive succesfully my data frames.

BUT on oscilloscope I can see 1.2µs bit time instead of 1µs
Why?

Regards
collink



Joined: 08 Jan 2010
Posts: 137
Location: Michigan

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

PostPosted: Tue Jul 05, 2011 11:25 am     Reply with quote

If it's working then I wouldn't complain. ;-)

Your calculations do seem correct as far as the canbus timing goes.

One thing though: That's 1 TQ for the start quanta. It's always 1 TQ for start then however many TQ you set for SEG1, PROP, SEG2. Jump width is something else entirely.

As for your oscilloscope: You might not be able to trust that. Oscilloscopes are for looking at wave forms not getting perfectly accurate pulse widths. Depending on how you have the scope setup and how the waveform looked you could have some error. The most important thing is that your baud timing seems to be accurate and you say that the PC side is able to properly receive the data.
Thom



Joined: 30 Jun 2011
Posts: 3
Location: France

View user's profile Send private message

PostPosted: Wed Jul 06, 2011 3:21 am     Reply with quote

Thanks for your answer
Most device with CAN are running at 20MHz. I'm trying to run at this frequency in order to see if I add 2 Tq (so 10 Tq instead 8) give a good bit timing
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