Hot!PIC18F2680 ECAN Stuck in Config Mode

Author
ssabin
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2011/04/18 17:01:11
  • Location: 0
  • Status: offline
2017/09/13 19:17:20 (permalink)
0

PIC18F2680 ECAN Stuck in Config Mode

I've used this exact micro about 8 years ago on a couple different projects with a common architecture and a few unique I/O features.  I never had a problem with the CAN module, but I did use a different CAN transceiver with an opto-isolator between the 18F and the transceiver.
 
At any rate, rather than learn one of the newer controllers with multiple CAN controllers, I decided to design a module with two  of these 18F2680s, each with its own CAN transceiver, and connected to each other via SPI without chip select.  Figured I could easily re-purpose old code and save some development time.
 
I used my old code as a framework for starting the code in each micro, and in fact used SPI in the past for a DAC channel output.  For whatever reason, I'm not able to get the CAN module out of config mode.  So far I've only been debugging the "slave" micro, but neither micro appears to be online on its respective CAN bus, which makes me think I may have a coding problem.  There are no error frames present on the bus, but as I said, the CAN controller is stuck in config mode.
 
I've taken the normal considerations in my previous projects and carried over to this:
- CANRX pin is configured as an input (RB3)
- CANTX pin is configured as an output (RB2)
- 10Mhz xtal oscillator with HSPLL to run at 40 MHz
- same bit rate as in previous project - 500kbps, using BRP = 3, PROP=3Tq, PH1 = 4Tq, PH2 = 2Tq, SJW=2
- PIE3=0 --> no CAN interrupts being used
 
While there are no pin conflicts, I'm considering trying to initialize CAN before setting up the SPI port and see how that does.  I've noticed that if I set the bit to Abort Messages being transmitted in the CANCON, the bit never gets cleared.  So, I've changed my code to never set that bit when I'm initializing the BAUD, TX, RX, filter and mask registers.  I can't explain why that bit gets stuck, but it seems like it could be related to getting stuck in config mode.
 
I'm using the TLE6250G at 5V - used a 251 in the past.
 
Should I try pull-ups on CANRX (TLE6250 contains weak pull-ups)?  I'm driving CANTX to 5V in the recessive state by setting the appropriate bit in CIOCON.
 
Any suggestions would be appreciated.  I plan on getting on a scope soon and see what is going on between the micro and transceiver.  My project deadline is nearing, and I don't have a backup plan.
 
Thanks in advance for your help!
 
 
 
#1

4 Replies Related Threads

    ssabin
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2011/04/18 17:01:11
    • Location: 0
    • Status: offline
    Re: PIC18F2680 ECAN Stuck in Config Mode 2017/09/14 17:43:28 (permalink)
    +1 (1)
    Update:  Based on what this module seems to do to the CAN bus, I would say that the physical layer is behaving typically.  CAN line waveform shows very rounded edges, and squares up nicely when the module is disconnected.  Going to do a new layout and add a choke on the CAN bus side of the transceiver and see how that works.  The physical layer must prevent the CAN controller from going into normal mode, and I'm going to keep this exact code around to prove that.  
    #2
    ssabin
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2011/04/18 17:01:11
    • Location: 0
    • Status: offline
    Re: PIC18F2680 ECAN Stuck in Config Mode 2017/09/26 15:11:41 (permalink)
    0
    Before getting to the new layout, I created a new project and copied my source files into that new project directory.  The module now does exit CAN init mode, but never transmits messages, nor does it receive any messages on the bus.  I am now wondering if the physical layer isn't THE problem, but should be cleaned up nonetheless, and perhaps I have a toolchain issue.  My previous projects were built prior to MPLAB X and this is my first MPLAB X project.  I may try download the older MPLAB and build this project and see how that works.
    #3
    jack@kksound
    code tags!
    • Total Posts : 2107
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: PIC18F2680 ECAN Stuck in Config Mode 2017/09/26 15:13:55 (permalink)
    0
    I may try download the older MPLAB and build this project and see how that works.

    More likely a change in the compiler/compiler version, IMHO
    #4
    ssabin
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2011/04/18 17:01:11
    • Location: 0
    • Status: offline
    Re: PIC18F2680 ECAN Stuck in Config Mode 2017/10/12 05:57:00 (permalink)
    0
    Thought I would provide an update, as I now consider this main issue solved.
     
    First issue, CAN module being stuck in CONFIG mode, was essentially remedied by moving the source code into a new folder and creating a new project from scratch.  I haven't yet looked into a comparison of the .HEX files created between these two processes, but the difference was in how the projects were created.  First one I selected "Existing MPLAB 8 Project", second one I used the "standalone project" option, and that one seemed to not hang in config mode.  I will abandon any hope of bringing in entire old projects into the newish IDE, but that doesn't matter much to be honest.
     
    But even the new project resulted in an application that refused to read CAN messages.  And in laying out a new board design, I found the embarassing but simple explanation - I had connected a cap to Vcc and GND, but I never grounded the GND pin on the transceiver!  Once I did that, I was able to read the message I was looking without a problem.
     
    Never underestimate the value of a fresh eyes review of your board design!
    #5
    Jump to:
    © 2017 APG vNext Commercial Version 4.5