View previous topic :: View next topic |
Author |
Message |
itzsurajg
Joined: 24 Feb 2011 Posts: 3 Location: KERALA
|
can communication problem...... |
Posted: Thu Feb 24, 2011 1:52 am |
|
|
Hai..
I'm trying to get 2 PIC to communicate with each other via CAN.
The PIC I am using is P16F877A and the Transceiver ic is MCP2515.
Crystal frequency used is 4MHz.
I am getting output in loop back mode. But when I tried to send data to other node using normal mode I am facing some communication problem.
1,
TXB0CTRL.txreq bit is not clearing.
2,
Not getting transmit interrupt.
ie: I am getting CANINTF.tx0if = 0.
3,
TXB0CTRL.txerr =1;
4,
After setting TXB0CTRL.txreq the interrupt flag CANINTF.errif becomes one.
5,
I am still confused in configuring the Baud rate registers CNF1, CNF2 and CNF3.
I don't know how to debug this problem.
Pls help me.
Thanks
Suraj |
|
![](templates/subSilver/images/spacer.gif) |
collink
Joined: 08 Jan 2010 Posts: 137 Location: Michigan
|
|
Posted: Thu Feb 24, 2011 6:22 am |
|
|
All of your points lead to the same conclusion. One you even mentioned: You don't have your baud rate registers properly set up.
What are you currently using for settings? I'm not familiar with PIC16 chips but I'll help if I can. Hopefully the settings are similar to PIC18 chips with CAN hardware. |
|
![](templates/subSilver/images/spacer.gif) |
itzsurajg
Joined: 24 Feb 2011 Posts: 3 Location: KERALA
|
|
Posted: Fri Feb 25, 2011 1:46 am |
|
|
Thanks for your response...
The baud rate registers I had configured is
CNF1 = 0x01;
CNF2 = 0xBA;
CNF3 = 0x07;
Yesterday I included header files provided by ccs c compiler can-mcp2510.c and I tried to communicate by using the functions in that header file.
But still the result is same. the transmit buffer is not getting empty. ie it is not transmitting that data.
So is it because of any problem with my hardware. I am trying it by placing ICs in breadboard.
I am still getting accurate output in loop back mode so I think the connection between PIC and MCP2515 is correct.
The transceiver ic I am using is MCP2551.
In MCP2551
I am using 120 Ohm termination resistor and the
rs pin I connected to ground using 10k resistor.
I am an engineering student and am trying to debug this problem for the last one week. Next week I am having review also.
So shall I go for 18f458, having inbuilt can controller.
Looking for valuable advice.
Thanks,
Suraj |
|
![](templates/subSilver/images/spacer.gif) |
collink
Joined: 08 Jan 2010 Posts: 137 Location: Michigan
|
|
Posted: Fri Feb 25, 2011 6:44 am |
|
|
Are both sides using the same type of PIC chip and everything? Your baud rate settings are as follows:
Baud prescaler of 2 so 4Mhz / 2 / 2 = 1 million time quanta per second.
Seg 1 of 8 TQ, Seg2 of 8 TQ, propegation TQ of 3.
1 + 3 + 8 + 8 = 20 TQ.
1M / 20 = 50000 baud. That's a really weird and low baud rate but I don't see why it couldn't work. It divided nice so it ought to be OK so long as both sides are being set to 50k baud.
Do you have an oscilloscope? I would hope so... You could try to look at the CANH and CANL lines which run between the boards to see if you are seeing the expected signal shapes. The expected output on the lines should show CANH as being near 3-4V and CANL being near 1-2V or so at rest. On bus activity they should be square waves converging to near the same voltage on both CANH and CANL. If you are getting odd signal shapes or the signals are not configured like I said then you have bus link problems.
itzsurajg wrote: | Thanks for your response...
The baud rate registers I had configured is
CNF1 = 0x01;
CNF2 = 0xBA;
CNF3 = 0x07;
Yesterday I included header files provided by ccs c compiler can-mcp2510.c and I tried to communicate by using the functions in that header file.
But still the result is same. the transmit buffer is not getting empty. ie it is not transmitting that data.
So is it because of any problem with my hardware. I am trying it by placing ICs in breadboard.
I am still getting accurate output in loop back mode so I think the connection between PIC and MCP2515 is correct.
The transceiver ic I am using is MCP2551.
In MCP2551
I am using 120 Ohm termination resistor and the
rs pin I connected to ground using 10k resistor.
I am an engineering student and am trying to debug this problem for the last one week. Next week I am having review also.
So shall I go for 18f458, having inbuilt can controller.
Looking for valuable advice.
Thanks,
Suraj |
|
|
![](templates/subSilver/images/spacer.gif) |
itzsurajg
Joined: 24 Feb 2011 Posts: 3 Location: KERALA
|
|
Posted: Fri Feb 25, 2011 7:24 am |
|
|
thanks a lot...
i will try... |
|
![](templates/subSilver/images/spacer.gif) |
|