AM263P4-Q1: CAN External read write Tx

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

Tool/software:

I am working with the CAN FD external read/write example on the AM263Px device using MCU+SDK 10.02.00.15.

I modified the example to:

  • transmit and receive data at 1mbps baud rate.            

  • Transmit CAN FD messages every 1 second using a timer-based ISR.

  • Receive data using interrupt mode, with data sent from the PCAN-View application.

However, after making these changes:

  • No data is being transmitted or received.

  • Even when I bypass the timer and place the CAN_transmitMsg() function inside an infinite while(1) loop, the data is still not transmitted or received.

  • PCAN-View is configured correctly for CAN 1mbps

I have attached screenshots of the modified code for reference.

  • .

  • Hi,
    I have received your query. Please give me some time to look into it.

    Best Regards,
    Aswathi

  • Can you please follow these steps and check if your application is working with this fix. There was a bug in the driver that will be fixed by this patch.

    1. Paste the below file in this path: {SDK}/source/drivers/mcan/v0/

    3527.canfd.c

    2. Import this updated canfd_external_read_write project to CCS

    canfd_external_read_write_am263px-cc_r5fss0-0_nortos_ti-arm-clang.zip

    Make your changes on top of this updated and examples, build and try again. Let me know if it works.

    Thanks,
    Aswathi

  • Hi Aswathi,

    I have followed the procedure as mentioned above. However, during execution, the loop is getting stuck at the MCAN_enableTransceiver function.

    Regards

    Sravanthi


  • Hi Sravanthi,

    What AM263Px board revision do you have? Also please show me where exactly is the execution stuck at inside the function. CCS step in snippet or any error message from the console will be helpful. 

    Thanks,
    Aswathi

  • Hii Aswathi,

    I am using AM263P4ACOMF ZCZ board. It is getting stuck at board version selection(attached the image). Which version i should choose.

    Regards,

    Sravanthi R.

  • Hi Sravanthi,

    What is the value of the array "boardVer" after it executes line 124? Because the MCAN transceiver needs to be turned awake using an STB signal. For different board revisions this signal comes from a different IO expander. That is the logic used in the image you shared.

    Also are you able to observe any signals on the MCAN header pins while executing the program? That will help understand if the transceiver was turned awake successfully or not.

    Thanks
    Aswathi

  • Hi Aswathi,

    What is the value of the array "boardVer" after it executes line 124
    1. Line 124 is not being excuted.Since the execution is halted in the I2C_transfer function( line 480 at SemaphoreP_pend( )). Attached the image.

    Regards

    Sravanthi R.

  • Hi aswathi

    Just a remainder for the above query.

    Regards

    Sravanthi R.

  • Hi Sravanthi,
    Apologies for the delay. Could you please share your modified program as a zip file? Let me test it out on my end and get back to you.

    Best Regards,
    Aswathi

  • Hi Aswathi,

    I haven’t made any modifications to the code. I have tested it exactly as provided by you.

    Regards

    Sravanthi R.

  • Hi Aswathi,

    Hope all is good :) Thanks for helping Sravanthi on this issue. Can you please guide us on testing the code that you shared? 

    Best Regards,

    Madhurya 

  • Hi Madhurya,

    Can you confirm if the board is AM263Px control card or launchpad? The program I attached is for control card, it will not work on LP as the transceiver enable logic in CC has an extra step that looks for board revision and calls the respective IO expander. 

    Best Regards,
    Aswathi

  • Hi Aswathi,

    I am using AM263P4 LP.

    Regards

    Sravanthi R.

  • Hi Sravanthi,

    The issue was what I suspected. Please follow these steps

    1. Replace canfd.c at {SDK}/source/drivers/mcan/v0/ with the file I attached earlier
    2. Replace the canfd_external_read_write.c at C:\ti\mcu_plus_sdk_am263px_installers\mcu_plus_sdk_am263px_10_02_00_15\examples\drivers\mcan\canfd_external_read_write with this file:
      1. /*
         *  Copyright (C) 2024 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.
         */
        
        /* This example demonstrates the CAN message communication to external CAN
         * controller in with the following configuration.
         * CAN FD Message Format.
         * Message ID Type is Standard, Msg Id 0xC0.
         * MCAN is configured in Interrupt Mode.
         * MCAN Interrupt Line Number 0.
         * Arbitration Bit Rate 1Mbps.
         * Data Bit Rate 5Mbps.
         * Buffer mode is used for Tx and RX to store message in message RAM.
         * Instance MCAN0 is set as a Commander in Transmit Mode. Message is transmitted and received
         * back from external CAN controller. Once message is transmitted the example will wait for
         * recieving the messages from external PC. Have to manually transmit ten messages from external
         * PC for test to finish. When the received message id and the data matches with the transmitted
         * one, then the example is completed.
         */
        
        #include <string.h>
        #include <kernel/dpl/SemaphoreP.h>
        #include "ti_drivers_config.h"
        #include "ti_drivers_open_close.h"
        #include "ti_board_open_close.h"
        
        /** \brief Number of messages sent */
        #define MCAN_APP_TEST_MESSAGE_COUNT         10U
        
        /** \brief Number of messages sent */
        #define MCAN_APP_TEST_DATA_SIZE             64U
        
        CANFD_MessageObject         txMsgObject;
        CANFD_MessageObject         rxMsgObject;
        volatile uint32_t           iterationCount = 0U;
        static SemaphoreP_Object    gMcanTxDoneSem, gMcanRxDoneSem;
        uint8_t                     rxData[MCAN_APP_TEST_DATA_SIZE] = {0};
        uint8_t                     txData[128U] =
                                       {0xA1, 0x1A, 0xFF, 0xFF, 0xC1, 0x1C, 0xB1, 0x1B,
                                        0xA2, 0x2A, 0xFF, 0xFF, 0xC2, 0x2C, 0xB2, 0x2B,
                                        0xA3, 0x3A, 0xFF, 0xFF, 0xC3, 0x3C, 0xB3, 0x3B,
                                        0xA4, 0x4A, 0xFF, 0xFF, 0xC4, 0x4C, 0xB4, 0x4B,
                                        0xA5, 0x5A, 0xFF, 0xFF, 0xC5, 0x5C, 0xB5, 0x5B,
                                        0xA6, 0x6A, 0xFF, 0xFF, 0xC6, 0x6C, 0xB6, 0x6B,
                                        0xA7, 0x7A, 0xFF, 0xFF, 0xC7, 0x7C, 0xB7, 0x7B,
                                        0xA8, 0x8A, 0xFF, 0xFF, 0xC8, 0x8C, 0xB8, 0x8B,
                                        0xA1, 0x1A, 0xFF, 0xFF, 0xC1, 0x1C, 0xB1, 0x1B,
                                        0xA2, 0x2A, 0xFF, 0xFF, 0xC2, 0x2C, 0xB2, 0x2B,
                                        0xA3, 0x3A, 0xFF, 0xFF, 0xC3, 0x3C, 0xB3, 0x3B,
                                        0xA4, 0x4A, 0xFF, 0xFF, 0xC4, 0x4C, 0xB4, 0x4B,
                                        0xA5, 0x5A, 0xFF, 0xFF, 0xC5, 0x5C, 0xB5, 0x5B,
                                        0xA6, 0x6A, 0xFF, 0xFF, 0xC6, 0x6C, 0xB6, 0x6B,
                                        0xA7, 0x7A, 0xFF, 0xFF, 0xC7, 0x7C, 0xB7, 0x7B,
                                        0xA8, 0x8A, 0xFF, 0xFF, 0xC8, 0x8C, 0xB8, 0x8B
                                        };
        
        void mcanEnableTransceiver(void);
        
        void canfd_external_read_write_main(void *args)
        {
            CANFD_MsgObjHandle          txMsgObjHandle;
            CANFD_MsgObjHandle          rxMsgObjHandle;
            int32_t                     status = SystemP_SUCCESS;
        
            /* Open drivers to open the UART driver for console */
            Drivers_open();
            Board_driversOpen();
        
            mcanEnableTransceiver();
        
            status = SemaphoreP_constructBinary(&gMcanTxDoneSem, 0);
            DebugP_assert(SystemP_SUCCESS == status);
            status = SemaphoreP_constructBinary(&gMcanRxDoneSem, 0);
            DebugP_assert(SystemP_SUCCESS == status);
        
            DebugP_log("\r\n[MCAN] CANFD External read - write test, application started ...\r\n");
        
            /* Setup the transmit message object */
            txMsgObject.direction = CANFD_Direction_TX;
            txMsgObject.msgIdType = CANFD_MCANXidType_29_BIT;
            txMsgObject.dataLength = MCAN_APP_TEST_DATA_SIZE;
            txMsgObject.args       = NULL;
            status = CANFD_createMsgObject (gCanfdHandle[CONFIG_MCAN0], &txMsgObject);
            if (status != SystemP_SUCCESS)
            {
                DebugP_log ("Error: CANFD create Tx message object failed\r\n");
                return;
            }
            txMsgObjHandle = &txMsgObject;
        
            /* Setup the receive message object */
            rxMsgObject.direction = CANFD_Direction_RX;
            rxMsgObject.msgIdType = CANFD_MCANXidType_29_BIT;
            rxMsgObject.args       = (uint8_t*) rxData;
            rxMsgObject.dataLength = MCAN_APP_TEST_DATA_SIZE;
            status = CANFD_createMsgObject (gCanfdHandle[CONFIG_MCAN0], &rxMsgObject);
            if (status != SystemP_SUCCESS)
            {
                DebugP_log ("Error: CANFD create Rx message object failed\r\n");
                return;
            }
            rxMsgObjHandle = &rxMsgObject;
        
            DebugP_log(" After transmitting the messages, it will wait to recieve %d messages for test to pass ...\r\n", MCAN_APP_TEST_MESSAGE_COUNT);
        
            while (iterationCount != MCAN_APP_TEST_MESSAGE_COUNT)
            {
                /* Send data over Tx message object */
                status += CANFD_write (txMsgObjHandle,
                                       txMsgObject.startMsgId,
                                       CANFD_MCANFrameType_FD,
                                       0,
                                       &txData[0]);
        
                /* Wait for Tx completion */
                SemaphoreP_pend(&gMcanTxDoneSem, SystemP_WAIT_FOREVER);
        
                /* Wait for Rx completion */
                SemaphoreP_pend(&gMcanRxDoneSem, SystemP_WAIT_FOREVER);
        
                status += CANFD_read(rxMsgObjHandle, MCAN_APP_TEST_MESSAGE_COUNT, &rxData[0]);
                if (status != SystemP_SUCCESS)
                {
                    DebugP_log ("Error: CANFD read in interrupt mode failed\r\n");
                    return;
                }
        
                /* Compare data */
                for(int32_t i = 0U; i < MCAN_APP_TEST_DATA_SIZE; i++)
                {
                    if(txData[i] != rxData[i])
                    {
                        status = SystemP_FAILURE;   /* Data mismatch */
                        DebugP_log("Data Mismatch at offset %d\r\n", i);
                        break;
                    }
                }
        
                if (status != SystemP_SUCCESS)
                {
                    DebugP_log ("Error: CANFD transmit data for iteration %d failed\r\n", iterationCount);
                    return;
                }
        
                iterationCount++;
            }
        
            SemaphoreP_destruct(&gMcanTxDoneSem);
            SemaphoreP_destruct(&gMcanRxDoneSem);
        
            status = CANFD_deleteMsgObject(txMsgObjHandle);
            if (status != SystemP_SUCCESS)
            {
                DebugP_log ("Error: CANFD delete Tx message object failed\r\n");
                return;
            }
        
            status = CANFD_deleteMsgObject(rxMsgObjHandle);
            if (status != SystemP_SUCCESS)
            {
                DebugP_log ("Error: CANFD delete Rx message object failed\r\n");
                return;
            }
        
            if (status == SystemP_SUCCESS)
            {
                DebugP_log("[MCAN] CANFD Internal loopback testing for %d iterations Passed\n\r", iterationCount);
                DebugP_log("All tests have passed\r\n");
            }
            else
            {
                DebugP_log("[MCAN] CANFD Internal loopback testing for %d iterations Failed\n\r", iterationCount);
                DebugP_log("Some tests have Failed\r\n");
            }
        
            Board_driversClose();
            Drivers_close();
        
            return;
        }
        
        void App_CANFDTransferCallback(void *args, CANFD_Reason reason)
        {
            if (reason == CANFD_Reason_TX_COMPLETION)
            {
                SemaphoreP_post((SemaphoreP_Object *)&gMcanTxDoneSem);
            }
            if (reason == CANFD_Reason_RX)
            {
                SemaphoreP_post((SemaphoreP_Object *)&gMcanRxDoneSem);
            }
        }
        
        void App_CANFDErrorCallback(void *args, CANFD_Reason reason)
        {
            /* Do nothing. */
        }
        
    3. Import the am263px-lp project to CCS: mcu_plus_sdk_am263px_installers\mcu_plus_sdk_am263px_10_02_00_15\examples\drivers\mcan\canfd_external_read_write\am263px-lp\
    4. Build the project with replaced file

    Let me know if this works.

    Best Regards,
    Aswathi

  • Hi Aswathi,

    I have made the following changes and when i am trying to transmit the data for every 1ms using Timer and simultaneously receiving the data from the other node for every 10ms . Only the transmission is working but reception is not happening.In the same code if i disabled transmission and kept only for reception , then data is being received.

    Why transmission and reception is not working simultaneously.

    Attached the images of the code and system configuration.

    IMG_20250806_172139237-1.pdf

    Regards

    Sravanthi R.

  • Hi Aswathi,

    Only the transmission is working but reception is not happening.In the same code if i disabled transmission and kept only for reception , then data is being received.

    In this case also i am receiving only 5 to 10 frames .. again no receive is happening. I have observed this for CLASSIC CAN at 1Mbps speed and CAN FD at 2 to 5 Mbps speed also.

    CCS: mcu_plus_sdk_am263px_installers\mcu_plus_sdk_am263px_10_02_00_15\examples\drivers\mcan\canfd_external_read_write\am263px-lp\

    I have used this code and modified main.c and canfd_external_read_write.c file as in above attached pdf.

    Regards

    Sravanthi R.

  • Hi Sravanthi,


    It will be helpful if you could share the program as zip file. It is difficult to read/debug using images. Also please share your PCAN side bit rate configurations. The sampling point should match between the application and the PC.

    Best Regards,

    Aswathi

  • Hi Aswathi,

    It will be helpful if you could share the program as zip file. It is difficult to read/debug using images.

    Actually we open our codes in system which doesn't have extranet access, so that is the reason i have shared the images.

    I have selected sample point at 75% in CAN pcan application.Attached the image for both CAN and CAN FD PCAN side bit rate.

    Regards

    Sravanthi R.

  • Hii Aswathi,

    I have executed the example code by:

    1. Commenting CANFD_Write() function 

    2.kept a variable in App_CANFD_TransferCallback() function( in reason == CANFD_Receive) to know the number of frames received.

    3.And kept the while loop as infinite loop.

    4. Commented comaprision of Tx and Rx frame( since i am only receiving the frames).

    I am sending data from peak Can view application for every 100msec, but i have received only one frame.Attached the image of 4 changes i have made in application and peak can view application settings and number of frames received in controller (in expression window as rx variable)  vs frames transmitted from peak can view application.

    I have tried MCAN_External_ReadWrite Example also , It is getting stuck at the point of interrupt creation( at the line 143 of attached image).

    Could you please find solution for these issues as soon as possible.

    Regards

    Sravanthi R.

  • Hii Aswathi,

    Is there any update. 

    I have even tried MCAN_external_read_write example by commenting write function and kept read function in while loop. But I am not receiving any data. At some times i even observed interrupt of receive fifo0 message lost in MCAN_external_read_write example .

    Regards

    Sravanthi R.

  • Hi Srivanthi,

    I am picking up this thread for Aswathi.

    I am struggling to follow the history here. Can you provide a status of your latest testing and the issue you are experiencing?

    Are you using the latest version of the MCU+SDK?

    Thanks and Regards,

    Zackary Fleenor

  • Hii Fleenor

    I am using Canfd_external_read_write example and modified main.c file and canfd_external_read_write.c file acording to my application.I am sending data at every 1msec and trying to receive the data simultaneously using interrupt. But I am receiving only few frames.

    If i disabled transmission and kept only for reception using interrupt ,in this case also i am receiving only 5 to 10 frames .. again no receive is happening. I have observed this for CLASSIC CAN at 1Mbps speed and CAN FD at 2 to 5 Mbps speed also.

    Attached the images of the code and system configuration.

    Canfd_external_read_write.pdf

    Regards

    Sravanthi R.

  • Hello,

    Thank you for providing these details. A few follow up questions:

    Can you provide a description of the physical test setup?

    I see you have a CAN reader device connected to the bus, how are the devices all wired together?

    Are you able to probe the CAN_H/CAN_L and MCAN_TX/MCAN_RX signals during operation to determine if possible signal integrity issues might be at play?

    Best Regards,

    Zackary Fleenor

  • Hii Fleenor,

    Can you provide a description of the physical test setup?

    I am Using AM263P4 launchpad

    . MCU+SDK 10.02.15 .

    CAN reader device as PCAN tool.

    I see you have a CAN reader device connected to the bus, how are the devices all wired together?

    I am connecting CAN3( available with transceiver in LP)  high to 7th pin and and low to 2nd pin of DB9 connector of PCAN tool.

    Are you able to probe the CAN_H/CAN_L and MCAN_TX/MCAN_RX signals during operation to determine if possible signal integrity issues might be at play?

    I have probed the CANH and CANL signal during transmission and verified.

    Reagrds

    Sravanthi R.

  • Hii Fleenor,

    Can you provide a description of the physical test setup?

    I am Using AM263P4 launchpad

    . MCU+SDK 10.02.15 .

    CAN reader device as PCAN tool.

    I see you have a CAN reader device connected to the bus, how are the devices all wired together?

    I am connecting CAN3( available with transceiver in LP)  high to 7th pin and and low to 2nd pin of DB9 connector of PCAN tool.

    Are you able to probe the CAN_H/CAN_L and MCAN_TX/MCAN_RX signals during operation to determine if possible signal integrity issues might be at play?

    I have probed the CANH and CANL signal during transmission and verified.

    Reagrds

    Sravanthi R.

  • Hi Sravanthi,

    Thank you for confirming this information.

    Can you provide us with scopeshots of both CAN_H/CAN_L and and MCAN_RX/MCAN_TX for reference?

    Can you provide the exact model of PCAN tool you are using?

    You should have a ground connection between the Launchpad and the PCAN tool, can you confirm?

    Best Regards,

    Zackary Fleenor

  • Hi Fleenor,

    Can you provide the exact model of PCAN tool you are using?

    I am using PCAN-USB FD (CAN and CANFD Interface for High-Speed USB 2.0).

    You should have a ground connection between the Launchpad and the PCAN tool, can you confirm?

    Yes I have made the ground connection.

    I modified the MCAN external read/write example so that it only receives frames, to check if transmitting causes any disturbance. I observed that the interrupt flags in CAN_IR are being set, but the interrupt callback configured for interrupt line 36( interrupt for MCAN)  is never called.

    Inside the callback I placed a function mcan_read() ( In this function, when a frame is received the FIFO level updates to 1 when data is received, so by polling it I can read the data using MCAN_readMsgRam()) ,to read the FIFO and acknowledge it. However, the callback itself is not triggered, even though the interrupt flags (CFG_IR ) are set when events occur (as configured in CFG_IE) and and RxFIFO0_status shows fifolevel as 1 and fifo full as 1.

    To test further, I moved the mcan_read() function into the while loop. With breakpoints, I see the FIFO level (updated in fifoStatus variable)  updates and the function executes correctly. But without breakpoints, MCAN_readMsgRam() is not executing since the fifolevel is not getting updated.

    I’ve attached both code versions for reference:

    • mcan_external_read_write_am263px-lp_r5fss0-0_nortos_ti-arm-clangmcan_read() inside interrupt callback

    • mcan_external_read_write_interrupt_am263px-lp_r5fss0-0_nortos_ti-arm-clangmcan_read() inside while loop.

      I am using MCU+SDK 10.02.15 , System Config 1.23.0 and AM263P4 LP.
    • AM263P4_MCAN.zip

    Regards

    Sravanthi R.

  • Hello Sravanthi,

    We appologize that you are still dealing with issue and want to thank you for your patience. Our experts are looking into the issue further and will try to provide some feedback before the end of the week.

    Best Regards,

    Zackary Fleenor