This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM263P4-Q1: Required changes to run MCAN example in AM263Px Control Card with ASSY: PROC159A (001)

Part Number: AM263P4-Q1
Other Parts Discussed in Thread: TCA6424

Tool/software:

Dear Sir/Mam,

                      While running the mcan_external_read_write example from MCU+SDK Version 10.0.0.35 on the AM263Px Control Card with ASSY: PROC159E2(001), the example functions correctly. However, it fails on the ASSY: PROC159A(001) card. Upon reviewing the code, I observed that in mcan_transceiver.c, lines 56 to 58 contain the relevant definitions (attached code snippet). The CAN transceiver used in both card versions is identical, as confirmed by the BOM and a visual inspection.

/*
 *  Copyright (C) 2023-24 Texas Instruments Incorporated
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *    Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 *    Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the
 *    distribution.
 *
 *    Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/* ========================================================================== */
/*                             Include Files                                  */
/* ========================================================================== */
#include <stdint.h>
#include <board/ioexp/ioexp_tca6424.h>
#include <board/eeprom.h>
#include <drivers/i2c.h>
#include "ti_drivers_open_close.h"
#include "ti_board_open_close.h"

/* ========================================================================== */
/*                           Macros & Typedefs                                */
/* ========================================================================== */

/* PORT 0, PIN 4         -> ioIndex : 0*8 + 4 = 4*/
#define IO_MUX_MCAN_SEL                             (4U)
/* PORT 2, PIN 1         -> ioIndex : 2*8 + 1 = 17 */
#define IO_MUX_MCAN_STB                             (17U)
/* MCAN_SEL PIN OUTPUT   -> 0 */
#define TCA6424_IO_MUX_MCAN_SEL_PORT_LINE_STATE     (TCA6424_OUT_STATE_LOW)
/* MCAN_STB PIN OUTPUT   -> 1 */
#define TCA6424_IO_MUX_MCAN_STB_PORT_LINE_STATE     (TCA6424_OUT_STATE_HIGH)

#define EEPROM_OFFSET_READ_PCB_REV                  (0x0022U)
#define EEPROM_READ_PCB_REV_DATA_LEN                (0x2U)
#define BOARD_VERSION_E2                            ('2')

/* ========================================================================== */
/*                            Global Variables                                */
/* ========================================================================== */

static TCA6424_Config  gTCA6424_Config;

/* ========================================================================== */
/*                          Function Definitions                              */
/* ========================================================================== */

int32_t TCA6424_Transceiver(void)
{
    int32_t             status = SystemP_SUCCESS;
    TCA6424_Params      tca6424Params;

    TCA6424_Params_init(&tca6424Params);
    status = TCA6424_open(&gTCA6424_Config, &tca6424Params);
    DebugP_assert(SystemP_SUCCESS == status);

    /* For MCAN_SEL */
    status = TCA6424_setOutput(
                    &gTCA6424_Config,
                    IO_MUX_MCAN_SEL,
                    TCA6424_IO_MUX_MCAN_SEL_PORT_LINE_STATE);
    DebugP_assert(SystemP_SUCCESS == status);

    status += TCA6424_config(
                    &gTCA6424_Config,
                    IO_MUX_MCAN_SEL,
                    TCA6424_MODE_OUTPUT);
    DebugP_assert(SystemP_SUCCESS == status);


    /* For MCAN_STB*/
    status += TCA6424_setOutput(
                    &gTCA6424_Config,
                    IO_MUX_MCAN_STB,
                    TCA6424_IO_MUX_MCAN_STB_PORT_LINE_STATE);
    DebugP_assert(SystemP_SUCCESS == status);

    status += TCA6424_config(
                    &gTCA6424_Config,
                    IO_MUX_MCAN_STB,
                    TCA6424_MODE_OUTPUT);

    if(status != SystemP_SUCCESS)
    {
        DebugP_log("Transceiver Setup Failure !!");
        TCA6424_close(&gTCA6424_Config);
    }

    TCA6424_close(&gTCA6424_Config);
    return status;
}

void mcanEnableTransceiver()
{
    int32_t status = SystemP_SUCCESS;
    uint8_t boardVer[2] = "";

    Board_eepromOpen();

    status = EEPROM_read(gEepromHandle[CONFIG_EEPROM0], EEPROM_OFFSET_READ_PCB_REV, boardVer, EEPROM_READ_PCB_REV_DATA_LEN);
    if(status == SystemP_SUCCESS)
    {
        if(boardVer[1] == BOARD_VERSION_E2)
        {
            /* boardVer is E2 */
            status = TCA6424_Transceiver();
        }
        else
        {
            /* boardVer is E1 */
            /* MCAN Transceiver is enabled by default in E1*/
        }
    }

    DebugP_assert(status == SystemP_SUCCESS);
    Board_eepromClose();
}
Thanks & Regards,
Tarun
  • Hi Tarun,

    This is a valid bug. I have filed it internally and it will be fixed for the next SDK release.
    Until then please use this updated mcan_transceiver.c file.

    /*
     *  Copyright (C) 2023-24 Texas Instruments Incorporated
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /* ========================================================================== */
    /*                             Include Files                                  */
    /* ========================================================================== */
    #include <stdint.h>
    #include <board/ioexp/ioexp_tca6424.h>
    #include <board/eeprom.h>
    #include <drivers/i2c.h>
    #include "ti_drivers_open_close.h"
    #include "ti_board_open_close.h"
    
    /* ========================================================================== */
    /*                           Macros & Typedefs                                */
    /* ========================================================================== */
    
    /* PORT 0, PIN 4         -> ioIndex : 0*8 + 4 = 4*/
    #define IO_MUX_MCAN_SEL                             (4U)
    /* PORT 2, PIN 1         -> ioIndex : 2*8 + 1 = 17 */
    #define IO_MUX_MCAN_STB                             (17U)
    /* MCAN_SEL PIN OUTPUT   -> 0 */
    #define TCA6424_IO_MUX_MCAN_SEL_PORT_LINE_STATE     (TCA6424_OUT_STATE_LOW)
    /* MCAN_STB PIN OUTPUT   -> 1 */
    #define TCA6424_IO_MUX_MCAN_STB_PORT_LINE_STATE     (TCA6424_OUT_STATE_HIGH)
    
    #define EEPROM_OFFSET_READ_PCB_REV                  (0x0022U)
    #define EEPROM_READ_PCB_REV_DATA_LEN                (0x2U)
    #define BOARD_VERSION_E2                            ('2')
    #define BOARD_VERSION_REV_A                         ('A')
    
    /* ========================================================================== */
    /*                            Global Variables                                */
    /* ========================================================================== */
    
    static TCA6424_Config  gTCA6424_Config;
    
    /* ========================================================================== */
    /*                          Function Definitions                              */
    /* ========================================================================== */
    
    int32_t TCA6424_Transceiver(void)
    {
        int32_t             status = SystemP_SUCCESS;
        TCA6424_Params      tca6424Params;
    
        TCA6424_Params_init(&tca6424Params);
        status = TCA6424_open(&gTCA6424_Config, &tca6424Params);
        DebugP_assert(SystemP_SUCCESS == status);
    
        /* For MCAN_SEL */
        status = TCA6424_setOutput(
                        &gTCA6424_Config,
                        IO_MUX_MCAN_SEL,
                        TCA6424_IO_MUX_MCAN_SEL_PORT_LINE_STATE);
        DebugP_assert(SystemP_SUCCESS == status);
    
        status += TCA6424_config(
                        &gTCA6424_Config,
                        IO_MUX_MCAN_SEL,
                        TCA6424_MODE_OUTPUT);
        DebugP_assert(SystemP_SUCCESS == status);
    
    
        /* For MCAN_STB*/
        status += TCA6424_setOutput(
                        &gTCA6424_Config,
                        IO_MUX_MCAN_STB,
                        TCA6424_IO_MUX_MCAN_STB_PORT_LINE_STATE);
        DebugP_assert(SystemP_SUCCESS == status);
    
        status += TCA6424_config(
                        &gTCA6424_Config,
                        IO_MUX_MCAN_STB,
                        TCA6424_MODE_OUTPUT);
    
        if(status != SystemP_SUCCESS)
        {
            DebugP_log("Transceiver Setup Failure !!");
            TCA6424_close(&gTCA6424_Config);
        }
    
        TCA6424_close(&gTCA6424_Config);
        return status;
    }
    
    void mcanEnableTransceiver()
    {
        int32_t status = SystemP_SUCCESS;
        uint8_t boardVer[2] = "";
    
        Board_eepromOpen();
    
        status = EEPROM_read(gEepromHandle[CONFIG_EEPROM0], EEPROM_OFFSET_READ_PCB_REV, boardVer, EEPROM_READ_PCB_REV_DATA_LEN);
        if(status == SystemP_SUCCESS)
        {
            if((boardVer[1] == BOARD_VERSION_E2) || (boardVer[1] == BOARD_VERSION_REV_A))
            {
                /* boardVer is E2 or REV_A */
                status = TCA6424_Transceiver();
            }
            else
            {
                /* boardVer is E1 */
                /* MCAN Transceiver is enabled by default in E1*/
            }
        }
    
        DebugP_assert(status == SystemP_SUCCESS);
        Board_eepromClose();
    }

    Thanks.

  • Hi Aswathi,

                     I have tried with above mentioned mcan_transciever.c file but still MCAN is not working in my ASSY: PROC159A(001) AM263Px control card.

    Regards,

    Tarun

  • Hi Tarun,
    I do not have this board on site. Give me time so I can get hold of one. Meanwhile can you tell me where is it failing this time? Is it not going into TCA6424_Transceiver() function?

  • Also please tell me what is the value of boardVer[1] at line 126 after EEPROM_read() is executed.

  • Hi Aswathi,

    The value in boardVer[1] is 0 as you can see in the below attached image

    As you can see the application is getting started but there is no data at the output while tapping CAN lines with CANalyst even though the external loopback mode is selected

    Regards,

    Tarun

  • Thanks for the details, Tarun. Please give me time to check with the HW team on this as I do not have the board for immediate debugging.

  • Sure, and thanks Aswathi.......

  • Hi Tarun,
    I got the response from HW team. Looks like the PCB_REV value is 'A0'. Please update line 126 to read index 0 of boardVer instead of index 1 for REV_A condition. 
    if((boardVer[1] == BOARD_VERSION_E2) || (boardVer[0] == BOARD_VERSION_REV_A))

    We will provide the proper fix in the next SDK release. Let me know if this works.

  • Hi Aswathi,

    It is working now....... 

    Thanks for your help

    Regards,

    Tarun