• AVR Freaks

Hot!Using MCP2517 with classic can bus (not FD)

Author
jeff.lynn
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2006/07/14 07:07:58
  • Location: 0
  • Status: offline
2018/09/03 11:50:59 (permalink)
0

Using MCP2517 with classic can bus (not FD)

Hi there
I'm wondering how to set an MCP2517 to use classic can with all the usual baud rates. I have used the old MCP2515 for ages, but this one is different. There are two bitrates, nominal and data, and I don't know which one I should set if I want to receive old 2.0 can frames.
#1

8 Replies Related Threads

    JoostH
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2018/10/22 00:12:06
    • Location: 0
    • Status: offline
    Re: Using MCP2517 with classic can bus (not FD) 2018/10/23 05:43:54 (permalink)
    0
    I ran into the same unclarity in the datasheets, I assume you have to set both to the same baud rate, but i haven't tested it yet.
    #2
    BLmicro
    Starting Member
    • Total Posts : 48
    • Reward points : 0
    • Joined: 2011/03/22 08:20:17
    • Location: 0
    • Status: offline
    Re: Using MCP2517 with classic can bus (not FD) 2018/11/01 08:35:17 (permalink)
    0
    I'm using the dsPic33CH with CAN-FD on the same bus with an old MCP2515. I have BRSDIS (Bit Rate Switch Disable) set to 0 (match Tx object) and set the Nominal and Data rates the same. I can receive messages from the 2515 with no problems.
     
    -BL
    #3
    ankit250ec
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2016/06/23 20:22:14
    • Location: 0
    • Status: offline
    Re: Using MCP2517 with classic can bus (not FD) 2019/10/07 21:24:01 (permalink)
    0
    Hi Jeff,
     
    Have you figured it out?
    I am also trying to interface MCP2517FD kit from Mikroe to MCP2515 through classic CAN.
    Till now unable to succeed.
    #4
    JPortici
    Super Member
    • Total Posts : 852
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: Using MCP2517 with classic can bus (not FD) 2019/10/08 05:00:01 (permalink)
    0
    If you are using it in a CAN 2.0 network, can't you put the controller in CAN 2.0 mode? It should ignore all the CAN-FD related configurations
    #5
    ankit250ec
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2016/06/23 20:22:14
    • Location: 0
    • Status: offline
    Re: Using MCP2517 with classic can bus (not FD) 2019/10/08 22:48:28 (permalink)
    0
    Hi JPortici,
     
    That's what I am trying to do. Till now no success.
    I am trying to figure out any setting which might be wrong.
    Following is my post:
    https://www.microchip.com/forums/m1114213.aspx
     
    Below is my code:
     
     
    void CAN2517_Init(void)
    {
        uint8_t i = 0;
        APP_CANFDSPI_Init(CAN_1000K_4M);

        txObj.bF.ctrl.IDE = 0; // Extended CAN ID false
        txObj.bF.id.SID = 0x7df; // CAN ID

        txObj.bF.ctrl.BRS = 0; // Switch Bitrate true (switch to 2Mbps)
        txObj.bF.ctrl.FDF = 0; // CAN FD true
        txObj.bF.ctrl.DLC = 8; // Data length. 15 is 64 bytes

        for(i = 0;i <8;i++)
        {
          txd[i] = 0;
        }
    }

    void loop()
    {

      txd[7] = can_msg_count >> 24;
      txd[6] = can_msg_count >> 16;
      txd[5] = can_msg_count >> 8;
      txd[4] = can_msg_count;

      can_msg_count++;

      APP_TransmitMessageQueue(); // Send out CAN FD frame

    // if(digitalReadFast(int1_pin) == 0) // Read int1 pin on MCP2517FD
    // {
    // // It is low read out the data
    // APP_ReceiveMessage_Tasks();
    // }

    // __delay_cycles(100);

    }


    void APP_CANFDSPI_Init(CAN_BITTIME_SETUP selectedBitTime)
    {
        bool ramInitialized;
        txFromFlash = true;
        payload.On = false;

        ramInitialized = false;
        
        CAN_OSC_STATUS oscStat;

        DRV_SPI_Initialize();


        // Reset device
        DRV_CANFDSPI_Reset(DRV_CANFDSPI_INDEX_0);

        // Enable ECC and initialize RAM
    // DRV_CANFDSPI_EccEnable(DRV_CANFDSPI_INDEX_0);

        if (!ramInitialized) {
            DRV_CANFDSPI_RamInit(DRV_CANFDSPI_INDEX_0, 0xff);
           ramInitialized = true;
        }

        // Configure device
        DRV_CANFDSPI_ConfigureObjectReset(&config);
        config.BitRateSwitchDisable = 1;
        config.IsoCrcEnable = 0;
        config.StoreInTEF = 0;

        DRV_CANFDSPI_Configure(DRV_CANFDSPI_INDEX_0, &config);

        // Setup TX FIFO
        DRV_CANFDSPI_TransmitChannelConfigureObjectReset(&txConfig);
        txConfig.FifoSize = 7;
        txConfig.PayLoadSize = CAN_PLSIZE_8;
        txConfig.TxPriority = 1;

        DRV_CANFDSPI_TransmitChannelConfigure(DRV_CANFDSPI_INDEX_0, APP_TX_FIFO, &txConfig);

        // Setup RX FIFO
    // DRV_CANFDSPI_ReceiveChannelConfigureObjectReset(&rxConfig);
    // rxConfig.FifoSize = 15;
    // rxConfig.PayLoadSize = CAN_PLSIZE_8;

    // DRV_CANFDSPI_ReceiveChannelConfigure(DRV_CANFDSPI_INDEX_0, APP_RX_FIFO, &rxConfig);
    //
    // // Setup RX Filter
    // fObj.word = 0;
    // fObj.bF.SID = 0xda;
    // fObj.bF.EXIDE = 0;
    // fObj.bF.EID = 0x00;

    // DRV_CANFDSPI_FilterObjectConfigure(DRV_CANFDSPI_INDEX_0, CAN_FILTER0, &fObj.bF);
    //
    // // Setup RX Mask
    // mObj.word = 0;
    // mObj.bF.MSID = 0x0;
    // mObj.bF.MIDE = 0; // Only allow standard IDs
    // mObj.bF.MEID = 0x0;
    // DRV_CANFDSPI_FilterMaskConfigure(DRV_CANFDSPI_INDEX_0, CAN_FILTER0, &mObj.bF);
    //
    // // Link FIFO and Filter
    // DRV_CANFDSPI_FilterToFifoLink(DRV_CANFDSPI_INDEX_0, CAN_FILTER0, APP_RX_FIFO, true);

        // Setup Bit Time
        DRV_CANFDSPI_BitTimeConfigure(DRV_CANFDSPI_INDEX_0, (CAN_BITTIME_SETUP) selectedBitTime, CAN_SSP_MODE_AUTO, CAN_SYSCLK_40M);
     // DRV_CANFDSPI_BitTimeConfigure(DRV_CANFDSPI_INDEX_0, selectedBitTime, CAN_SSP_MODE_AUTO, CAN_SYSCLK_20M);
        
        // Setup Transmit and Receive Interrupts
    // DRV_CANFDSPI_GpioModeConfigure(DRV_CANFDSPI_INDEX_0, GPIO_MODE_INT, GPIO_MODE_INT);
    // DRV_CANFDSPI_TransmitChannelEventEnable(DRV_CANFDSPI_INDEX_0, APP_TX_FIFO, CAN_TX_FIFO_NOT_FULL_EVENT);
    // DRV_CANFDSPI_ReceiveChannelEventEnable(DRV_CANFDSPI_INDEX_0, APP_RX_FIFO, CAN_RX_FIFO_NOT_EMPTY_EVENT);

    // DRV_CANFDSPI_ModuleEventEnable(DRV_CANFDSPI_INDEX_0, CAN_TX_EVENT | CAN_RX_EVENT);

        DRV_CANFDSPI_OscillatorStatusGet(DRV_CANFDSPI_INDEX_0, &oscStat);

        // Select Normal Mode
        DRV_CANFDSPI_OperationModeSelect(DRV_CANFDSPI_INDEX_0, CAN_CLASSIC_MODE);

    }

     
    My MCP2517FD click board is interfaced to a MSP430 through SPI.
    I am initializing my SPI at 1 MHz separately.
    My SPI transaction seems okay as I can verify from the Beagle SPI analyser.
    However, I have yet to receive a CAN2.0B frame at my Komodo CAN analyser/controller from my MCP2517FD.
    I think I am missing something in my settings.
     
     
    #6
    JPortici
    Super Member
    • Total Posts : 852
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: Using MCP2517 with classic can bus (not FD) 2019/10/09 00:31:38 (permalink)
    0
    mm..
    is your test network set up correctly (i.e at least two active nodes, and the two termination resistors present on two nodes)? <- problem could be in your network
    can you also check the activity on the bus using an oscilloscope? <- problem could be in a configuration mismatch between analyzer and controller, altough the analyzer should signal this with error frames
    In any case, have you tried checking the content of the various status registers in the can controller after you tell it to send a frame? <- problem is the configuration, or somewhere in the hardware
    #7
    ankit250ec
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2016/06/23 20:22:14
    • Location: 0
    • Status: offline
    Re: Using MCP2517 with classic can bus (not FD) 2019/10/09 03:06:48 (permalink)
    0
    Hi JPortici,
     
    Thanks for your response.
    There are actually three nodes. One is Komodo CAN controller/analyser, one MCP2515 and one MCP2517FD.
    My Komodo CAN controller/analyser is able to receive whatever MCP2515 is sending. So, I think hardware set-up may not be the problem. In my next reply, I will attach the SPI messages that I am sniffing through Beagle SPI analyser while configuring MCP2517FD and transmitting through it.
    #8
    ankit250ec
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2016/06/23 20:22:14
    • Location: 0
    • Status: offline
    Re: Using MCP2517 with classic can bus (not FD) 2019/10/10 18:54:54 (permalink)
    4 (1)
    Hi JPortici,
     
    On the MCP2517FD Click Board, I was providing only 3.3V.
    I forgot to provide 5V and that's why transceiver was not working.
    As soon as I provided 5V, transceiver started working and I could see my MCP2517FD transmitting Classical CAN messages to Komodo CAN analyser.
    Lesson learnt, must read the description 2-3 times while doing the circuit.
     
    On the brighter side, I had to dig in datasheet and user guide of MCP2517FD which helped me understand the register settings better.
    Thanks a lot!!
    #9
    Jump to:
    © 2019 APG vNext Commercial Version 4.5