Page 1 of 1

Reading CAN-BUS data

Posted: Thu Sep 16, 2010 6:05 pm
by ChrisD
Hello

I am experimenting with CAN-BUS and I am having a problem reading the can signal
I am checking the buffer and then read the can data, I use the "GetRXData" macro using Parameters buffer 0 index 0 and returning the Value to a variable but the data in the variable is always the same value, I have tried sending a can data Via a PIC chip or “PEAK” can-bus reader/transmitter but it still comes up with the same value, I have proved that can signal is getting through the RX buffer filtering. If use a different chip it returns a different value but again always the same value

Looking at the example programs and instructions I believe I am doing this correctly but as this does not work I am thinking that I am missing something?

I am running 2 PIC18f2585 using the internal can

Any help would be much appreciated

Re: Reading CAN-BUS data

Posted: Fri Sep 17, 2010 8:19 am
by Benj
Hello,

The GetRXData macro should only be used after calling the CheckRX function.

The CheckRX function checks for incoming messages and if there are any available it will return a non 0 value and add the message to the internal buffer. It is then this buffer that you are reading from when calling the GetRXData function.

Re: Reading CAN-BUS data

Posted: Fri Sep 17, 2010 10:50 am
by ChrisD
Hello
I have included a very simple program that I believe should work? I am using the CheckRX function then the using the GetRxData function but it always returns the same value? I can see the can data I am sending via my can-bus reader so I know what value I should be getting just don’t
I am using the internal can on the chip so have used a prototype board to connect the chips together using the 2 MCP2551 chips as per the information for internal can on the forums, as I can send data ok I have to presume I have done this correctly?
Many thanks

Re: Reading CAN-BUS data

Posted: Fri Sep 17, 2010 11:03 am
by Benj
Hello Chris,

Are you using a 20MHz crystal?

Also I noticed that in your chip configuration you have the following settings enabled which should be disabled instead.

Watchdog Timer
Low Voltage Program
Extended CPU Enable

What are you using to transmit the CAN messages? Is it using a baud of 125KBPs to match your Flowcode CAN baud?

Re: Reading CAN-BUS data

Posted: Fri Sep 17, 2010 11:21 am
by ChrisD
Hello
Yes I am using a 20MHZ crystal
I will change the setting I was unsure what they should be
I have tried two ways of sending messages first was via a second chip I could connect a key pad up to and to change the can data using this and send it, I know I am sending a message because I am using a Peak P-Can can bus reader to check this reader can also transmit a message but I still get know joy from either off this two methods and all running at 125KBPs

http://www.peak-system.com/Product-Deta ... howUid]=16

Many thanks

Re: Reading CAN-BUS data

Posted: Fri Sep 17, 2010 11:57 am
by ChrisD
Hello Ben
Thank you very much I changed the chip configurations you mentioned and it worked instantly.
Thanks Again
Chris

Re: Reading CAN-BUS data

Posted: Fri Sep 17, 2010 12:00 pm
by Benj
Hi Chris,

Thats great thanks for letting me know. Those config settings can be a little daunting if you've not experienced them before.