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

beginner for Can bus using 18F25K80

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



Joined: 14 Apr 2013
Posts: 2

View user's profile Send private message

beginner for Can bus using 18F25K80
PostPosted: Sun Apr 14, 2013 11:08 pm     Reply with quote

hi
I have school project that I must connect PICs by CAN bus. And I connect 18F25K80 with a built-in CAN bus module to mcp2551. But when I include <can-18F4580.c> or <can-18Fxxx8.c> in the code, it reminds me of "A #DEVICE required before this line" (in the header file).
Any help will be appreciated!!
Thanks!
Ttelmah



Joined: 11 Mar 2010
Posts: 19447

View user's profile Send private message

PostPosted: Mon Apr 15, 2013 12:51 am     Reply with quote

Are you possibly using MPLAB?.
If so, the include file _must not_ be included in the 'source files' tab. Only in the 'header files' tab. If you put it in the source files tab, MPLAB will try to compile this code "on it's own", and will give the error you have.
If not, then the order of stuff in your main source file must be:

1) Processor include file.
2) Fuses
3) Clock statement
4) Things like RS232 and SPI #use statements
5) Other includes like the can one
6) code

If you use the wizard, it'll put 1 to 4, together in a project include file, but the order things are actually handled, must basically remain the same.

Best Wishes
bignash13



Joined: 14 Apr 2013
Posts: 2

View user's profile Send private message

PostPosted: Mon Apr 15, 2013 1:13 am     Reply with quote

Thanks. It really helps. I am using MPLAB.
Can I include <can-18xxx8.c> file directly for the mcu 18F25k80?
or I have to write another can module function by myself to match 18F25k80?

my code is quite simple. MPLAB gives me the error"*** Error 128 "C:\Program Files\PICC\drivers\can-18xxx8.h" Line 82(1,2): A #DEVICE required before this line"

Best wishes


Code:

#include <18F25k80.h>
#fuses NOWDT,INTRC_IO
#use delay(clock=8000000)
#include <can-18xxx8.c>

void main(void)
{
 can_init();
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19447

View user's profile Send private message

PostPosted: Mon Apr 15, 2013 3:20 am     Reply with quote

In the MPLAB file list window, remove the can file from the 'source files' branch, and add it to the 'header files' branch.

Use can-18F4580, not 18xxx8. The latter is for the CAN module, the former is for the _ECAN_ module, which your chip has.

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