View previous topic :: View next topic |
Author |
Message |
matt1971
Joined: 26 Oct 2008 Posts: 15
|
MCP2510 warning, when generating timings for CAN? |
Posted: Sun Oct 26, 2008 3:57 pm |
|
|
I'm currently trying to interface a PIC18 based datalogger to a CAN based automotive display. This requires messages to be sent at 1Mbit. I'm currently using a PIC18F4685 at 20MHz, with an MCP2551, but cannot get the display to accept any data.
The timings I have from the Microchip calculator are :
CNF1/BRGCON1 b'00000000' 0x00
CNF2/BRGCON2 b'10100000' 0xA0
CNF3/BRGCON3 b'00000010' 0x02
And I've edited can-18xxx8.c to :
Code: |
void can_set_baud(void) {
//BRGCON1.brp=CAN_BRG_PRESCALAR;
//BRGCON1.sjw=CAN_BRG_SYNCH_JUMP_WIDTH;
//BRGCON2.prseg=CAN_BRG_PROPAGATION_TIME;
//BRGCON2.seg1ph=CAN_BRG_PHASE_SEGMENT_1;
//BRGCON2.sam=CAN_BRG_SAM;
//BRGCON2.seg2phts=CAN_BRG_SEG_2_PHASE_TS;
//BRGCON3.seg2ph=CAN_BRG_PHASE_SEGMENT_2;
//BRGCON3.wakfil=CAN_BRG_WAKE_FILTER;
/* 20 MHz, 1 MHz CAN bus */
BRGCON1=0x00;
BRGCON2=0xA2;
BRGCON3=0x02;
}
|
This doesn't work, and the Microchip timing program gives me a warning. So two questions, are the timing values above correct, and do I really need to increase the crystal to say 32MHz? I'm reluctant to push the crystal so high as I need an accurate 100Hz sample frequency, without generating lots of idle interrupts. Thanks-in-advance. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 26, 2008 4:14 pm |
|
|
Build two boards. Get them to talk to each other. Once you have done
that, then you know that you have a proven, working board. You can
now attempt to talk to the automobile's CAN bus.
Or have your board talk to some other commercial CAN bus analyzer.
Either way, you need to know that your board works before you try
using it with the automobile CAN bus.
This thread contains a link to code for testing two identical CAN bus
boards which are connected to each other. It also contains some
warnings about operating at 1 MHz CAN bus frequency:
http://www.ccsinfo.com/forum/viewtopic.php?t=35834 |
|
![](templates/subSilver/images/spacer.gif) |
matt1971
Joined: 26 Oct 2008 Posts: 15
|
|
Posted: Sun Oct 26, 2008 4:34 pm |
|
|
Thanks, I will try that first and see how I get on. I am new to CAN and may I ask another quick question. The PIC I'm using is an 18F4685, which uses ECAN, the display I want to talk to is CAN 2.0B. I have read through datasheets for both the PIC and the MCP2551 and can find no reference to anything needing to be explicitly be done to enable ECAN to operate on CAN 2.0B (Other than using/enabling extended headers) Is this correct, or do I somehow need to enable ECAN -> 2.0B compatibility ? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 26, 2008 5:06 pm |
|
|
vs. 2.0B has 29-bit identifiers. The functions in the CCS CAN bus
drivers typically have a parameter where you can select either 11-bit
or 29-bit (i.e., Extended) identifiers. |
|
![](templates/subSilver/images/spacer.gif) |
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
Re: MCP2510 warning, when generating timings for CAN? |
Posted: Mon Oct 27, 2008 12:30 am |
|
|
matt1971 wrote: | the Microchip timing program gives me a warning. So two questions, are the timing values above correct, and do I really need to increase the crystal to say 32MHz? I'm reluctant to push the crystal so high as I need an accurate 100Hz sample frequency, without generating lots of idle interrupts. |
What is the warning? It's probably relevant.
Running at 32MHz and generating a 100Hz interrupt isn't a problem either, so long as timer 1 or 3 and the CCP module are available. Just divide the timer down and set the compare value to get your 100Hz. _________________ Andrew |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 27, 2008 2:12 pm |
|
|
This is the warning message that he's getting from the CAN bus bit
timing calculator from Intrepid Systems:
Quote: |
According to MCP2510 Silicon Revision A Errata Sheet, the settings
you selected expose you to a "Minimum Bus Idle Time" problem.
You currently have 20 OSC1 clocks and the minimum is 26. Please
refer to the latest MCP2510 Errata sheets to determine if this problem
has been fixed.
|
The bug is fully discussed in the MCP2510 Errata sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/80059d.pdf
However, he's not using the MCP2510. He's using the CAN module in
the 18F4685 and that errata is not mentioned in the latest Errata sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/80284e.pdf |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Tue Oct 28, 2008 6:00 am |
|
|
Thanks for that reply PCM, not been able to get to a PC to send the warning in. Having setup two PICs, I can get them to communicate, but I can't send anything to the display (an AiM MXL). AiM dont appear to want to help me on this, but it seems the CAN is at 1Mbit, CAN 2.0A, and that the data is sent as a single CAN message, but with 35 bytes in it, those bytes follow a given schema, e.g. bytes 0..1 are the RPM.
I'm still not convinced I've actually set the CAN to 1Mbit, and the code is the same on the two PIC's I've joined so they are both working on the same speed - no matter what it is!
Is there a way to tell what speed a CAN bus is operating at ? Also, can anyone recommend a cheap (CHEAP!) CAN bus sniffer, or if anyone has a suitable schematic I can build one. Thanks again. |
|
![](templates/subSilver/images/spacer.gif) |
|