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

Can commands?

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



Joined: 25 Nov 2004
Posts: 30
Location: Germany

View user's profile Send private message

Can commands?
PostPosted: Fri Dec 10, 2004 7:13 am     Reply with quote

Hello there,

I want to communicate between to PICs, for example a 18F258, by CAN. Unfortunately I don't know how to do this and I don't find anything in help or in examples for this. Can someone tell me just one command for using the CAN-Bus, so that I can search for this command instant just searching for "CAN"?

I think, if I know one command and find it in help, I will also be able to find all the others.

Thank you in advance, pom
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Dec 10, 2004 8:15 am     Reply with quote

My examples folder has at least 3 example files for CAN. They all begin with EX_CAN
pom



Joined: 25 Nov 2004
Posts: 30
Location: Germany

View user's profile Send private message

PostPosted: Mon Dec 13, 2004 3:44 am     Reply with quote

My example folder has none of these.

If there were examples with this name, I would not have asked for some commands.

But I have just an example called EX_PBUSM.C. It is an example for "Generic Pic to Pic message transfer program over one wire". I think, it is not the same. Am I right?
pom



Joined: 25 Nov 2004
Posts: 30
Location: Germany

View user's profile Send private message

PostPosted: Mon Dec 13, 2004 3:50 am     Reply with quote

Maybe someone can put the examples to this forum, so that I can see them. Or otherwise, someone can read them out and tell me some instruction which are used in there.

It would be very nice, I don't know what to do.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Dec 13, 2004 4:10 am     Reply with quote

Which version of the CCS ccompiler do you have? I think the examples were introduced in v3.186 or 3.187 and were improved in a later version.

No special CAN commands were introduced in the compiler, all functionality is in the supplied driver files. That's why you won't find information in the help files.

For more examples on implementing CAN commands you can also have a look at the Microchip website.
pom



Joined: 25 Nov 2004
Posts: 30
Location: Germany

View user's profile Send private message

PostPosted: Tue Dec 14, 2004 10:08 am     Reply with quote

I don't know how to explain, but I can't find an entry to the programming of the can-communication Sad .

At last I have an example for this and I have a Peak PCAN-hardware to connect the can-bus to the computer. But neither do I get messages on the computer nor can I send some from the Computer to the PIC.

I produced this code:

#if defined(__PCH__)
#include <18F258.h>
#fuses HS,PUT,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT
#use delay(clock=20000000)
#use rs232(baud=57600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12

#endif

#include <bootloader.h>
#include <can-18xxx8.c>

void main(void) {
struct rx_stat rxstat;
int i=5;
int in_data[8];
int32 tx_id;
int tx_len;


for (i=0; i++; i>8){
in_data[i]= 0;
}

printf("\r\nApplication program version 1.01 \r\n");

while (i<10){

can_init();
can_getd(tx_id, &in_data[0], tx_len,rxstat);
printf("angekommen %u \n\r",&in_data[0]);
}
}

First question: Why does the code just work once? i is always smaller than 10. I changed it to while (true) and it worked some times, but also stopped after a while.

Second question: By the RS232 the Pic writes in_data[0] to the screen. But it is always 8, independent from the message I try send.

I am near to the point to give up. Unfortunately I really need the solution of this problem. Please help me.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Dec 14, 2004 11:54 am     Reply with quote

First remark: When posting code please use the 'code' button from this forum, this will ensure the layout of your code is preserved.


Second remark: You never answered the question which compiler version you are using.

Third:
Quote:
I don't know how to explain, but I can't find an entry to the programming of the can-communication
I can see you found ex_can.c, so what exactly don't you understand?

Four:
Code:
for (i=0; i++; i>8){
  in_data[i]= 0;
}

This bug clears a large part of your RAM area and makes your program go crazy. I guess you meant:
Code:
for (i=0; i<8; i++){
  in_data[i]= 0;
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 14, 2004 1:04 pm     Reply with quote

I think you should buy the "1 year maintenance" for the CCS PCH
compiler. Then you will get all the required CAN example files and
driver files. There are several of them, and CCS doesn't allow us
to post them on this forum. There are maybe one or two things
that you might have to modify, to make the CCS drivers work with
your CAN interface, but they have been discussed on this forum and
you can find them in the archives.

The PCH maintenance is only $99 USD. Because the dollar is so low,
I think that price must seem really cheap in Europe.
http://www.ccsinfo.com/ccscorder.shtml#CCompiler
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