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

Help 18F4685 CAN bus

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



Joined: 16 Apr 2010
Posts: 5

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

Help 18F4685 CAN bus
PostPosted: Fri Apr 16, 2010 11:43 am     Reply with quote

Hi,
I'm working with pic18f4685 and I can't get CAN working! and I don't know what I'm doing wrong.
Can you help me? I just need a simple test (send and receive something).
Thanks.
Tiago
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 16, 2010 12:29 pm     Reply with quote

Use the forum's search page. Search for
Quote:
18F4685 CAN

Set it to: Search for All Terms

Then you find posts like this one:
PIC18F4685 - which CAN header? (which CCS driver file to use)
http://www.ccsinfo.com/forum/viewtopic.php?t=36676
The answer is: can-18F4580.c

This thread discusses your problem.
http://www.ccsinfo.com/forum/viewtopic.php?t=40898
He uses the code from this thread (but he modified it):
http://www.ccsinfo.com/forum/viewtopic.php?t=29627&start=7

Also search for this:
Quote:
can-18F4580.c

You will find many threads which discuss how to use that driver file.

There are many topics on the forum about the CAN bus, and these
threads discuss all the likely problems that you will have. Please
read all these threads. This is a 3-page thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=40202
MikeW



Joined: 15 Sep 2003
Posts: 184
Location: Warrington UK

View user's profile Send private message

PostPosted: Fri Apr 16, 2010 11:28 pm     Reply with quote

I am using a PIC18F4680, and it works fine using the CCS supplied routines.

Mike
hithat



Joined: 16 Apr 2010
Posts: 5

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

PostPosted: Sat Apr 17, 2010 9:49 am     Reply with quote

Hi,

I already read and search and everything that suppose to do i have done and nothing works. I have only 2 boards and one looks to be fine but i don't know because the other boards have a problem or i think that have. Because when i do can_init() the mode must be config and when exit the routine can_init() mode is put to mode normal but if i try to change to mode config again he stop in the while( (CANSTAT.opmode) != mode ); in routine can_set_mode.
Another thing that i try was enable CAN interrupts and when i try to send something it goes to CANIRX and CANERR interrupts, and this means that an error occur! Right? Sorry for my english:-(
I'm not using any resistance of 120 ohms the cable is about 20 inch. Is anything wrong? please help :-(

MikeW wrote:
I am using a PIC18F4680, and it works fine using the CCS supplied routines.

Mike
hithat



Joined: 16 Apr 2010
Posts: 5

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

PostPosted: Sat Apr 17, 2010 10:16 am     Reply with quote

MikeW wrote:
I am using a PIC18F4680, and it works fine using the CCS supplied routines.

Mike


Hi Mike, did you change anything in ccs routines for your code work? Can you post here your code?
Many thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Apr 17, 2010 11:49 am     Reply with quote

Quote:
Another thing that i try was enable CAN interrupts

You don't have it working in a basic program. Then you try an advanced program.

Quote:
I'm not using any resistance of 120 ohms

I suppose you also left off the CAN bus transceiver chips (MCP2551) ?
hithat



Joined: 16 Apr 2010
Posts: 5

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

PostPosted: Sat Apr 17, 2010 12:20 pm     Reply with quote

PCM programmer wrote:
Quote:
Another thing that i try was enable CAN interrupts

You don't have it working in a basic program. Then you try an advanced program.

Quote:
I'm not using any resistance of 120 ohms

I suppose you also left off the CAN bus transceiver chips (MCP2551) ?


I am an Electronic Eng. i know that i need to use a transceiver.
i test the 2 boards in CAN_OP_LOOPBACK mode, and they work fine. but if i change for normal mode they donĀ“t detect nothing in receiver buffers and they return sucsses in PUTD().

i have seen many code with this library of ccs "can-18F4580.c" and i am doing just the same.
some info:
- i dont use terminal resistor.
- conected rs terminal of mcp2551 to ground
- and the baud rate is define as default from ccs library "can-18F4580.c".
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Apr 17, 2010 1:44 pm     Reply with quote

The test program for two CAN bus boards that is shown in this
thread does work. It has been tested many times (not only by me):
http://www.ccsinfo.com/forum/viewtopic.php?t=29627&start=7

The two boards should be connected as shown in this schematic:
http://www.microchip.com/forums/upfiles.aspx/52252/1E05A177D4B746B0B4C23DB18CC4F360.JPG

If you do it as shown in the two posts above, then it should work.
hithat



Joined: 16 Apr 2010
Posts: 5

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

PostPosted: Sat Apr 17, 2010 6:31 pm     Reply with quote

PCM programmer wrote:
The test program for two CAN bus boards that is shown in this
thread does work. It has been tested many times (not only by me):
http://www.ccsinfo.com/forum/viewtopic.php?t=29627&start=7

The two boards should be connected as shown in this schematic:
http://www.microchip.com/forums/upfiles.aspx/52252/1E05A177D4B746B0B4C23DB18CC4F360.JPG

If you do it as shown in the two posts above, then it should work.

I had already did that and nothing works... like I said it only works in loopback and it give me success in PUTD() functions but nothing appears on the other side. The only thing that miss me was the terminal resistor 120 ohms, but I know that for small test it suppose to work without... but we never sure :(
So I will work until this do what I want. So thanks very much for your help and time with me.
MikeW



Joined: 15 Sep 2003
Posts: 184
Location: Warrington UK

View user's profile Send private message

PostPosted: Sun Apr 18, 2010 12:27 am     Reply with quote

I suggest you post your schematics, and how you are connecting the 2 boards.

For your information, this was my methodology :-

First, I purchased the excellent CCS CAN development system.

The CCS board has 4 CAN nodes, one can(sic) be used as a "sniffer", one as an output, one as an input.

So, I had the CCS system displaying LED data, responding to pushbutton presses, using the supplied CCS example software.

I then connected my own design board to the CCS one, and "sniffed" the data traffic on the bus generated by the CCS dev. system.

That proved that my CAN timing etc was corrrect (which was not simple).

After that I sent messages from my board to the CCS output nodes.

Voila !!, I was up and running.

Mike
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