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

How to send 2 CAN BUS FRAME (or more)with 18F2480 ?

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



Joined: 22 Mar 2012
Posts: 70
Location: France (Paris)

View user's profile Send private message

How to send 2 CAN BUS FRAME (or more)with 18F2480 ?
PostPosted: Fri Jul 06, 2012 9:04 am     Reply with quote

Hi,
I'm looking for a small example to generate 2 CAN BUS Frame.
I'm using this part of code :

1) can_putd(Tx_Id,buffer0_len,tx_pri,tx_ext,tx_rtr);
2) can_putd(Tx_Id1,buffer1,tx_len,tx_pri,tx_ext,tx_rtr);

Actually, I'm able to generate ONE frame but I need 2 frame or better
3 frame.

Thanks in advance for your help.

Cogitum
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Mon Jul 09, 2012 2:24 am     Reply with quote

You can send as many messages as you like. I assume that by "frame" you meant message.

The CAN hardware has three transmit buffers, so that you can give it three messages to send before it blocks. That hardware will send these three in the order it wants to, NOT in the order you give them to the hardware. There is no idea of message ordering in CAN, every message is complete in itself and so can, and may be sent in any order relative to any other.

An example: if you send three message A, B and C, all with the SAME priority, then the hardware will send them as A, C and then B due to the way it buffers the data.

You can control this to some extent by usign the priority, but this inly works if you are sending occasional messages or groups of messages and can therefore work out the state of the hardware buffers.

When it comes to sending groups of messages I like to have just one message buffer in my code. I fill it with the first message I want to send, and can_putd it, then I change the bits I want changing (as usually groups of my messages are often related and share some bytes) and then send again, repeating as required. As at 100kbs a CAN message takes around 1ms to be sent there's plenty of time to get the new data prepared. Note that the message is put into hardware by can_putd, so you don't have to worry about changing the data in YOUR buffer while it sends.

I don't know whether that answers your question.... I hope so.

RF Developer
Cogitum



Joined: 22 Mar 2012
Posts: 70
Location: France (Paris)

View user's profile Send private message

sending several frames of CAN BUS with 18F2480
PostPosted: Tue Jul 10, 2012 5:51 am     Reply with quote

Hi,

Very Happy Thanks a lot for your quick answer.

I did a small hardware with a little software to send 3 Frames and,
everything RUN normally.

Best regards
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