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 CCS Technical Support

[CANbus] communication between two nodes with PIC18F2580
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Martinez_pt



Joined: 26 Sep 2008
Posts: 11

View user's profile Send private message

PostPosted: Tue Oct 28, 2008 6:27 pm     Reply with quote

Hi, Ambrogio.

ambrojohn wrote:
Do you think I could use the same 20 MHz oscillator for both PICs?

A


I'm not sure if that is possible! Confused

http://en.wikipedia.org/wiki/Crystal_oscillator
http://www.ecliptek.com/crystals/glossary.html
http://www.cardinalxtal.com/docs/notes/quartz_operation.pdf

And after i analized this links i can't say any thing at all, but tomorrow i'll ask it to an understood person.

But a 20 MHz Crystal is cheaper at least here in Portugal.

I alredy change the CCS EX_CAN.C to do what you want, but i didn't load it on PIC's yet. On next days i'll do it and i let you know the results.

If you want to give a look, here they are:

http://www.ave.dee.isep.ipp.pt/~1010792/node_A.C
http://www.ave.dee.isep.ipp.pt/~1010792/node_B.C


Best regards

Nuno (my name, not my nick Wink )
Martinez_pt



Joined: 26 Sep 2008
Posts: 11

View user's profile Send private message

PostPosted: Tue Oct 28, 2008 9:06 pm     Reply with quote

Ok, it works perfectly!!! Very Happy


With the two files on the post above you will get the following output, that is what i understand you wanted.

OUTPUT:

Code:
Rede CAN

Rede criada e iniciada...

Enviado 1: ID=24 LEN=8 PRI=3 EXT=1 RTR=0
   DADOS = 08 08 08 08 08 08 08 08

Recebido: BUFF=0 ID=25 LEN=8 OVF=0 FILT=0 RTR=0 EXT=1 INV=0
    DADOS = 09 09 09 09 09 09 09 09

Enviado 1: ID=24 LEN=8 PRI=3 EXT=1 RTR=0
   DADOS = 08 08 08 08 08 08 08 08

Recebido: BUFF=0 ID=25 LEN=8 OVF=0 FILT=0 RTR=0 EXT=1 INV=0
    DADOS = 09 09 09 09 09 09 09 09

Enviado 1: ID=24 LEN=8 PRI=3 EXT=1 RTR=0
   DADOS = 08 08 08 08 08 08 08 08

Recebido: BUFF=0 ID=25 LEN=8 OVF=0 FILT=0 RTR=0 EXT=1 INV=0
    DADOS = 09 09 09 09 09 09 09 09



The node A with ID 24, send eight (8) through the bus to node B. Then, node B with ID 25, add "1" to the 8 and send it back through the bus to node A so we get nines (9) on serail port of PC.

One thing, i saw you had changed the pin's of RS232 RX and TX conection, have you also chaged the pin's of CAN (RX and TX)?

If you have done it, you have to take care with the port you will use because other port's unless the B may not have internal pullups that are necessary to get the state of RX MCP 2551 Pin. I read on another post that for TX pin MCP 2551 has already a pullup resistor on that pin.

Any way i advisory you to use the original pin's just to make the CAN work, after that you make your own modifications.


I hope i had managed to help you.

Best regards

Nuno


Last edited by Martinez_pt on Fri Oct 31, 2008 12:08 am; edited 1 time in total
ambrojohn



Joined: 27 Apr 2008
Posts: 18

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

PostPosted: Wed Oct 29, 2008 3:06 am     Reply with quote

Martinez_pt wrote:
Ok, it works perfectly!!! Very Happy


Yes, that is what I meant.

Quote:

One thing, i saw you had changed the pin's of RS232 RX and TX conection,


Do you mean in my example code on the first page? Yes but it works perfectly.

Quote:

have you also chaged the pin's of CAN (RX and TX)?


I don't think it is possible...

Actually, I picture them switched on the PIC side in the hw scheme, but my hardware it's ok (CANTX with TXD and CANRX with RXD)

Quote:

Any way i advisory you to use the original pin's just to make the CAN work, after that you make your own modifications.


But I yet use the original pins for CAN communication: pin 23 and pin 24 of the PIC16F2580 (I could not do otherwise)

Regards
shashank27187



Joined: 28 Jul 2009
Posts: 13

View user's profile Send private message

PostPosted: Thu Aug 06, 2009 2:38 am     Reply with quote

could you pls tell me whether i need can-18f2580.c for implementing can using pic 18f2585..

as i am using can-18f4580.c as the can driver file in my program, but i have'nt got results for the same...
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
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