View previous topic :: View next topic |
Author |
Message |
hithat
Joined: 16 Apr 2010 Posts: 5
|
Help 18F4685 CAN bus |
Posted: Fri Apr 16, 2010 11:43 am |
|
|
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
|
|
|
MikeW
Joined: 15 Sep 2003 Posts: 184 Location: Warrington UK
|
|
Posted: Fri Apr 16, 2010 11:28 pm |
|
|
I am using a PIC18F4680, and it works fine using the CCS supplied routines.
Mike |
|
|
hithat
Joined: 16 Apr 2010 Posts: 5
|
|
Posted: Sat Apr 17, 2010 9:49 am |
|
|
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
|
|
Posted: Sat Apr 17, 2010 10:16 am |
|
|
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
|
|
Posted: Sat Apr 17, 2010 11:49 am |
|
|
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
|
|
Posted: Sat Apr 17, 2010 12:20 pm |
|
|
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
|
|
|
hithat
Joined: 16 Apr 2010 Posts: 5
|
|
Posted: Sat Apr 17, 2010 6:31 pm |
|
|
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
|
|
Posted: Sun Apr 18, 2010 12:27 am |
|
|
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 |
|
|
|