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.

TMS320F28377S: about CAN_INT

Part Number: TMS320F28377S
Other Parts Discussed in Thread: CONTROLSUITE, C2000WARE

Hi,

In spruhm8g.pdf, CAN_INT--INT1ID show that

0x01-0x20 Number of message object (mailbox) which caused the interrupt.

 I send a message to CANA mailbox1 from CANB.

It has a interrupt and the receive data is correct.

I just see the INT0ID=0x8000,

How to do and  know which mailbox cause the interrupt in CAN_INT?

best regards,

Simen

  • Simen,

                You are saying the interrupt itself is asserted correctly and the correct data is received, but INT1ID = 0. Where in the ISR do you set the breakpoint? Could you set it at the very first line of the ISR?

  • Simen,
    Any update on this?
  • Hareesh,

    You are right when IF3 disable.

    When I set the breakpoint at the very first line of the ISR,CAN_IPEN_21 can point out which mailbox receiced the data. (as figure 1)

    After excute "ulStatus = CANStatusGet(CANA_BASE, CAN_STS_CONTROL); " in the ISR function , the CAN_INT also show which mailbox ISR.(as figure 2)

    But if  IF3 enable as with below code setup, CAN_IPEN_21 & CAN_INT have no response with CAN_IPEN_21 & CAN_INT. (as figure 3 & 4)

        HWREGH(CANA_BASE + CAN_O_IF3UPD) = 0xFFFF;
        HWREGH(CANA_BASE + CAN_O_IF3OBS) = CAN_IF3OBS_ARB | CAN_IF3OBS_DATA_A | CAN_IF3OBS_DATA_B;

    Please give some suggestions again. Thanks.

    figure1

    figure2

    figure3

    figure4

    best regards,

    Simen

  • When the ISR is executed the first time (upon reception of data), CAN_INT register = 0x8000 since CAN_ES != 0x07. Upon exiting the ISR, an interrupt is asserted again because of the pending Mailbox interrupt. This time INT0ID should correctly reflect the ID of the Mailbox asserting the interrupt. Now CAN_ES == 0x07. From this point on, INT0ID reflects the Mailbox that asserted the interrupt.

    Is the behavior any different when you use IF1 or IF2 register set?
  • I tried the can_ex2_loopback_interrupts from the Driverlib examples. Agree it uses IF2, but I see the interrupt registers getting updated correctly. I am working on using IF3 now.

     

     

  • Hareesh,

    The behavior of both IF1 and IF2 is the same.


    best regards,
    Simen
  • Hareesh,


    Do you have any update with using IF3?

    best regards,
    Simen
  • Simen,
    Sorry, I have been unable to spend time on this. I will resume my debug today.
  •  In your first post, you mention “I send a message to CANA mailbox1 from CANB.” But in figure 1 of your second post, CAN_IPEN_21 shows 0x00000008, meaning MBX4 interrupt got asserted. Please clarify which MBX is being used and whether that is the only MBX being used. Also clarify which interrupt line (CANINT0 or CANINT1) that mailbox is configured for.

  • Simen,
    When you say “The behavior of both IF1 and IF2 is the same.”, exactly what do you mean? Are you saying the interrupt status is updated correctly when IF1/IF2 are used or are you saying IF1/IF2 behavior is the same as IF3 with which you are having problems? Could you please summarize your problem clearly?
  • Hareesh,

    Let me re-align the question,
    Attach file is my code which modify by controlsuite V210 "can_loopback_interrupts" example.
    My code example is sending a message to CANA from CANB.
    When debug expressions-CANRxID fill CANA message ID (CANRxID=0x101 => CANA mailbox1), and let expressions-Enable=1 ,then send a message  to CANA mailbox1 from CANB.
    Below behavior is during CANA receiving a message and causing a ISR.

    The behavior of IF1 ,
    1. breakpoint on line 83    =>CAN_IPEN_21= 0x0000 0001, CAN_INT== 0x0000 8000.It respects that mailbox1 has message and has a CAN ISR.
    2. After excuting line 111  =>CAN_IPEN_21= 0x0000 0001, CAN_INT== 0x0000 0001.It respects that mailbox1  caused the interrupt.
    3. After excuting line 171  =>CAN_IPEN_21= 0x0000 0000, CAN_INT== 0x0000 0000.


    The behavior of IF2 is the same with IF1
    1. breakpoint on line 83    =>CAN_IPEN_21= 0x0000 0001, CAN_INT== 0x0000 8000.It respects that mailbox1 has message and has a CAN ISR.
    2. After excuting line 111  =>CAN_IPEN_21= 0x0000 0001, CAN_INT== 0x0000 0001.It respects that mailbox1  caused the interrupt.
    3. After excuting line 170  =>CAN_IPEN_21= 0x0000 0000, CAN_INT== 0x0000 0000.


    The difference between IF1 and IF2 behaviors are that CANMessageGet() function configurate IF1 or IF2 registers.


    IF3 configures at line 421 and 422.
    1. breakpoint on line 83    =>CAN_IPEN_21= 0x0000 0000, CAN_INT== 0x0000 8000.
    2. After excuting line 111  =>CAN_IPEN_21= 0x0000 0000, CAN_INT== 0x0000 0000.
    3. After excuting line 170  =>CAN_IPEN_21= 0x0000 0000, CAN_INT== 0x0000 0000.

    Base on the experiment result,
    IF3 behavior is different with IF1/IF2.
    When enter ISR, CAN_IPEN_21 have no value after IF3 setup. (breakpoint on line 83)
    Therefore,INT0ID also have no value after excuting line 111.

    Why CAN_IPEN_21 can not work after IF3 setup?

    Do you have the same situation after IF3 setup?

    //###########################################################################
    // FILE:   can_loopback_interrupts.c
    // TITLE:  Example to demonstrate basic CAN setup and use.
    //
    //! \addtogroup cpu01_example_list
    //! <h1>CAN External Loopback with Interrupts (can_loopback_interrupts)</h1>
    //!
    //! This example shows the basic setup of CAN in order to transmit and receive
    //! messages on the CAN bus.  The CAN peripheral is configured to transmit
    //! messages with a specific CAN ID.  A message is then transmitted once per
    //! second, using a simple delay loop for timing.  The message that is sent is
    //! a 4 byte message that contains an incrementing pattern.  A CAN interrupt
    //! handler is used to confirm message transmission and count the number of
    //! messages that have been sent.
    //!
    //! This example sets up the CAN controller in External Loopback test mode.
    //! Data transmitted is visible on the CAN0TX pin and can be received with
    //! an appropriate mailbox configuration.
    //!
    //! This example uses the following interrupt handlers:\n
    //! - INT_CANA0 - CANIntHandler
    //!
    //
    //###########################################################################
    // $TI Release: F2837xD Support Library v180 $
    // $Release Date: Fri Nov  6 16:19:46 CST 2015 $
    // $Copyright: Copyright (C) 2013-2015 Texas Instruments Incorporated -
    //             http://www.ti.com/ ALL RIGHTS RESERVED $
    //###########################################################################
    
    #include "F28x_Project.h"     // Device Headerfile and Examples Include File
    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_types.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_can.h"
    #include "driverlib/can.h"
    #include "driverlib/debug.h"
    #include "F2837xD_can.h"
    
    
    //*****************************************************************************
    // A counter that keeps track of the number of times the TX interrupt has
    // occurred, which should match the number of TX messages that were sent.
    //*****************************************************************************
    volatile unsigned long g_ulTxMsgCount = 0;
    volatile unsigned long g_ulRxMsgCount = 0;
    
    unsigned long u32CanAErrorStatus;
    
    //*****************************************************************************
    // A flag to indicate that some transmission error occurred.
    //*****************************************************************************
    volatile unsigned long g_bErrFlag = 0;
    
    tCANMsgObject sTXCANMessage;
    tCANMsgObject sRXCANMessage;
    unsigned char ucTXMsgData[8] ={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    unsigned char ucRXMsgData[8];
    
    unsigned long u32CntTXMsgData = 0x12345678;
    uint32_t	CANRxID=101,EnableFlag=0,EnableFlag2=0,EnableFlag3=0;
    uint32_t	CANRxISRCnt=0;
    uint32_t IF3_DAT_A_Tmp=0;
    uint32_t IF3_DAT_B_Tmp=0;
    uint32_t CAN_IF3OBS_ARB_Tmp=0;
    uint16_t    temp[4]={0,0,0,0};
    uint16_t    temp1[4]={0,0,0,0};
    uint16_t    temp2[4]={0,0,0,0};
    uint16_t    *test;
    
    
    uint32_t TestVar;
    //----------------------------------------------------
    //void CANMessageGet_IF1(uint32_t ui32Base, uint32_t ui32ObjID, tCANMsgObject *pMsgObject, bool bClrPendingInt);
    //*****************************************************************************
    // This function is the interrupt handler for the CAN peripheral.  It checks
    // for the cause of the interrupt, and maintains a count of all messages that
    // have been transmitted.
    //*****************************************************************************
    interrupt void
    CANIntHandler(void)
    {
        unsigned long ulStatus;
        unsigned long ClrIntTmp;
    
        CANRxISRCnt++;
    //    IF3_DAT_A_Tmp= HWREG(CANA_BASE + CAN_O_IF3DATA);
    //    IF3_DAT_B_Tmp= HWREG(CANA_BASE + CAN_O_IF3DATB);
    //    CAN_IF3OBS_ARB_Tmp= HWREG(CANA_BASE + CAN_O_IF3ARB);
    
    //    HWREGH(CANA_BASE + CAN_O_IF3UPD) = 0x00;
    //    HWREGH(CANA_BASE + CAN_O_IF3UPD) = 0x03;
    //    HWREGH(CANA_BASE + CAN_O_IF3OBS) = CAN_IF3OBS_ARB | CAN_IF3OBS_DATA_A | CAN_IF3OBS_DATA_B;
    
    
        // Read the CAN interrupt status to find the cause of the interrupt
        ulStatus = CANIntStatus(CANA_BASE, CAN_INT_STS_CAUSE);
    
        // If the cause is a controller status interrupt, then get the status
        if(ulStatus == CAN_INT_INT0ID_STATUS)
        {
            // Read the controller status.  This will return a field of status
            // error bits that can indicate various errors.  Error processing
            // is not done in this example for simplicity.  Refer to the
            // API documentation for details about the error status bits.
            // The act of reading this status will clear the interrupt.  If the
            // CAN peripheral is not connected to a CAN bus with other CAN devices
            // present, then errors will occur and will be indicated in the
            // controller status.
            ulStatus = CANStatusGet(CANA_BASE, CAN_STS_CONTROL);
    
            //Check to see if an error occurred.
            if(((ulStatus  & ~(CAN_ES_TXOK | CAN_ES_RXOK)) != 7) &&
            		((ulStatus  & ~(CAN_ES_TXOK | CAN_ES_RXOK)) != 0)){
            	// Set a flag to indicate some errors may have occurred.
            	g_bErrFlag = 1;
            }
        }
    
        // Check if the cause is message object 1, which what we are using for
        // sending messages.
        else if(ulStatus == 1)
        {
            // Getting to this point means that the TX interrupt occurred on
            // message object 1, and the message TX is complete.  Clear the
            // message object interrupt.
            CANIntClear(CANA_BASE, 1);
    
            // Increment a counter to keep track of how many messages have been
            // sent.  In a real application this could be used to set flags to
            // indicate when a message is sent.
    //        g_ulTxMsgCount++;
    
            // Since the message was sent, clear any error flags.
            g_bErrFlag = 0;
        }
    
        // Check if the cause is message object 1, which what we are using for
        // receiving messages.
        else if(ulStatus == 2)
        {
    
        	// Get the received message
            CANMessageGet(CANA_BASE, 2, &sRXCANMessage, true);
    //        CANMessageGet_IF1(CANA_BASE, 2, &sRXCANMessage, true);
            // Getting to this point means that the TX interrupt occurred on
            // message object 1, and the message TX is complete.  Clear the
            // message object interrupt.
            CANIntClear(CANA_BASE, 2);
    
            // Increment a counter to keep track of how many messages have been
            // sent.  In a real application this could be used to set flags to
            // indicate when a message is sent.
    //        g_ulRxMsgCount++;
    
            // Since the message was sent, clear any error flags.
            g_bErrFlag = 0;
        }
    
        // Otherwise, something unexpected caused the interrupt.  This should
        // never happen.
        else
        {
             // Spurious interrupt handling can go here.
       }
        if(ulStatus == 0x00000010)
        {
        	ClrIntTmp=CANRxID-100;
            CANMessageGet(CANA_BASE, ClrIntTmp, &sRXCANMessage, true);
    //        CANMessageGet_IF1(CANA_BASE, ClrIntTmp, &sRXCANMessage, true);
            CANIntClear(CANA_BASE, ClrIntTmp);
        }
    
        //canaRegs.CAN_GLB_INT_CLR.bit.INT0_FLG_CLR = 1;
        CANGlobalIntClear(CANA_BASE, CAN_GLB_INT_CANINT0);
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;
    }
    
    //*****************************************************************************
    // Configure the CAN and enter a loop to transmit periodic CAN messages.
    //*****************************************************************************
    
    int main(void)
    {
        // Step 1. Initialize System Control:
        // PLL, WatchDog, enable Peripheral Clocks
        // This example function is found in the F2837xD_SysCtrl.c file.
    	InitSysCtrl();
    
        // Step 2. Initialize GPIO:
        // This example function is found in the F2837xD_Gpio.c file and
        // illustrates how to set the GPIO to its default state.
    	InitGpio();
    
    	//GPIO 73 - XCLKOUT
    	GPIO_SetupPinMux(73, GPIO_MUX_CPU1, 3);
    	GPIO_SetupPinOptions(73, GPIO_OUTPUT, GPIO_PUSHPULL);   // -> SYSCLOCK/8 = 25MHz
    
    #if 1
    	//GPIO30 - CANRXA
    	GPIO_SetupPinMux(30, GPIO_MUX_CPU1, 1);
    	//GPIO31 - CANTXA
    	GPIO_SetupPinMux(31, GPIO_MUX_CPU1, 1);
    	GPIO_SetupPinOptions(30, GPIO_INPUT, GPIO_ASYNC);
    	GPIO_SetupPinOptions(31, GPIO_OUTPUT, GPIO_PUSHPULL);
    #else
    	//GPIO30 - CANRXA
    //	GPIO_SetupPinMux(30, GPIO_MUX_CPU1, 1);
    	GPIO_SetupPinMux(36, GPIO_MUX_CPU1, 6);
    	//GPIO31 - CANTXA
    //	GPIO_SetupPinMux(31, GPIO_MUX_CPU1, 1);
    	GPIO_SetupPinMux(37, GPIO_MUX_CPU1, 6);
    	GPIO_SetupPinOptions(36, GPIO_INPUT, GPIO_ASYNC);
    	GPIO_SetupPinOptions(37, GPIO_OUTPUT, GPIO_PUSHPULL);
    
    #endif
    
    
    
        // internal CAN
        //GPIO20 - CANTXB
        GPIO_SetupPinMux(20, GPIO_MUX_CPU1, 3);
        GPIO_SetupPinOptions(20, GPIO_OUTPUT, GPIO_PUSHPULL);
        //GPIO21 - CANRXB
        GPIO_SetupPinMux(21, GPIO_MUX_CPU1, 3);
        GPIO_SetupPinOptions(21, GPIO_INPUT, GPIO_ASYNC);
    
    
        // Initialize the CAN controller
        CANInit(CANA_BASE);
        CANInit(CANB_BASE);
    
        // Setup CAN to be clocked off the M3/Master subsystem clock
        CANClkSourceSelect(CANA_BASE, 0);
        CANClkSourceSelect(CANB_BASE, 0);
    
        // Set up the bit rate for the CAN bus.  This function sets up the CAN
        // bus timing for a nominal configuration.  You can achieve more control
        // over the CAN bus timing by using the function CANBitTimingSet() instead
        // of this one, if needed.
        // In this example, the CAN bus is set to 500 kHz.  In the function below,
        // the call to SysCtlClockGet() is used to determine the clock rate that
        // is used for clocking the CAN peripheral.  This can be replaced with a
        // fixed value if you know the value of the system clock, saving the extra
        // function call.  For some parts, the CAN peripheral is clocked by a fixed
        // 8 MHz regardless of the system clock in which case the call to
        // SysCtlClockGet() should be replaced with 8000000.  Consult the data
        // sheet for more information about CAN peripheral clocking.
        CANBitRateSet(CANA_BASE, 200000000, 125000);
        CANBitRateSet(CANB_BASE, 200000000, 125000);
    
        // Enable interrupts on the CAN peripheral.  This example uses static
        // allocation of interrupt handlers which means the name of the handler
        // is in the vector table of startup code.  If you want to use dynamic
        // allocation of the vector table, then you must also call CANIntRegister()
        // here.
        CANIntEnable(CANA_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
    
        // Step 3. Clear all interrupts and initialize PIE vector table:
        // Disable CPU interrupts
    	DINT;
    
        // Initialize the PIE control registers to their default state.
        // The default state is all PIE interrupts disabled and flags
        // are cleared.
        // This function is found in the F2837xD_PieCtrl.c file.
    	InitPieCtrl();
    
        // Disable CPU interrupts and clear all CPU interrupt flags:
    	IER = 0x0000;
    	IFR = 0x0000;
    
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        // This will populate the entire table, even if the interrupt
        // is not used in this example.  This is useful for debug purposes.
        // The shell ISR routines are found in F2837xD_DefaultIsr.c.
        // This function is found in F2837xD_PieVect.c.
        InitPieVectTable();
    
        // Interrupts that are used in this example are re-mapped to
        // ISR functions found within this file.
        // Register interrupt handler in RAM vector table
        EALLOW;
        PieVectTable.CANA0_INT = CANIntHandler;
        EDIS;
    
        // Enable the CAN interrupt on the processor (PIE).
        PieCtrlRegs.PIEIER9.bit.INTx5 = 1;
        IER |= 0x0100;   /* M_INT9 */
        EINT;
    
        // Enable test mode and select external loopback
    //    HWREG(CANA_BASE + CAN_O_CTL) |= CAN_CTL_TEST;
    //    HWREG(CANA_BASE + CAN_O_TEST) = CAN_TEST_EXL;
    
        // Enable the CAN for operation.
        CANEnable(CANA_BASE);
    
        CANGlobalIntEnable(CANA_BASE, CAN_GLB_INT_CANINT0);
    //    CANGlobalIntEnable(CANA_BASE, CAN_GLB_INT_CANINT1);
    
        // Initialize the message object that will be used for sending CAN
        // messages.  The message will be 4 bytes that will contain an incrementing
        // value.  Initially it will be set to 0x12345678.
        ucTXMsgData[0] = (u32CntTXMsgData>>24) & 0xFF;
        ucTXMsgData[1] = (u32CntTXMsgData>>16) & 0xFF;
        ucTXMsgData[2] = (u32CntTXMsgData>>8) & 0xFF;
        ucTXMsgData[3] = (u32CntTXMsgData) & 0xFF;
    //    sTXCANMessage.ui32MsgID = 1;                      // CAN message ID - use 1
        sTXCANMessage.ui32MsgID = CANRxID;                      // CAN message ID - use 1
    
        sTXCANMessage.ui32MsgIDMask = 0;                  // no mask needed for TX
    //    sTXCANMessage.ui32Flags = MSG_OBJ_TX_INT_ENABLE;  // enable interrupt on TX
        sTXCANMessage.ui32Flags = MSG_OBJ_NO_FLAGS;  // enable interrupt on TX
        sTXCANMessage.ui32MsgLen = sizeof(ucTXMsgData);   // size of message is 8
        sTXCANMessage.pucMsgData = ucTXMsgData;           // ptr to message content
    
        // Initialize the message object that will be used for receiving CAN
        // messages.
        *(unsigned long *)ucRXMsgData = 0;
    //    sRXCANMessage.ui32MsgID = 1;                      // CAN message ID - use 1
        sRXCANMessage.ui32MsgID = CANRxID;                      // CAN message ID - use 1
        sRXCANMessage.ui32MsgIDMask = 0;                  // no mask needed for TX
        sRXCANMessage.ui32Flags = MSG_OBJ_RX_INT_ENABLE;  // enable interrupt on RX
        sRXCANMessage.ui32MsgLen = sizeof(ucRXMsgData);   // size of message is 8
        sRXCANMessage.pucMsgData = ucRXMsgData;           // ptr to message content
    
    	// Setup the message object being used to receive messages
    
    
    
        sRXCANMessage.ui32MsgID = 100;                      // CAN message ID
    	CANMessageSet(CANA_BASE,  0, &sRXCANMessage, MSG_OBJ_TYPE_RX);
    	sRXCANMessage.ui32MsgID = 101;                      // CAN message ID
    	CANMessageSet(CANA_BASE,  1, &sRXCANMessage, MSG_OBJ_TYPE_RX);
    	sRXCANMessage.ui32MsgID = 102;                      // CAN message ID
    	CANMessageSet(CANA_BASE,  2, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 103;                      // CAN message ID
    	CANMessageSet(CANA_BASE,  3, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 104;                      // CAN message ID
    	CANMessageSet(CANA_BASE,  4, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 105;                      // CAN message ID
    	CANMessageSet(CANA_BASE,  5, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 106;                      // CAN message ID
    	CANMessageSet(CANA_BASE,  6, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 107;                      // CAN message ID
    	CANMessageSet(CANA_BASE,  7, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 108;                      // CAN message ID
    	CANMessageSet(CANA_BASE,  8, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 109;                      // CAN message ID
    	CANMessageSet(CANA_BASE,  9, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 110;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 10, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 111;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 11, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 112;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 12, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 113;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 13, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 114;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 14, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 115;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 15, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 116;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 16, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 117;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 17, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 118;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 18, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 119;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 19, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 120;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 20, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 121;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 21, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 122;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 22, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 123;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 23, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 124;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 24, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 125;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 25, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 126;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 26, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 127;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 27, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 128;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 28, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 129;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 29, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 130;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 30, &sRXCANMessage, MSG_OBJ_TYPE_RX);
        sRXCANMessage.ui32MsgID = 131;                      // CAN message ID
    	CANMessageSet(CANA_BASE, 31, &sRXCANMessage, MSG_OBJ_TYPE_RX);
    
    
    
    
    	// Send the CAN message using object number 1 (not the same thing as
    	// CAN ID, which is also 1 in this example).  This function will cause
    	// the message to be transmitted right away.
    	ucTXMsgData[0] = (u32CntTXMsgData>>24) & 0xFF;
    	ucTXMsgData[1] = (u32CntTXMsgData>>16) & 0xFF;
    	ucTXMsgData[2] = (u32CntTXMsgData>>8) & 0xFF;
    	ucTXMsgData[3] = (u32CntTXMsgData) & 0xFF;
    
        // Enter loop to send messages.  A new message will be sent once per
        // second.  The 4 bytes of message content will be treated as an unsigned
        // long and incremented by one each time.
    
    
    //	CanaRegs.CAN_IF3UPD|= 0x03;
    //	CanaRegs.CAN_IF3OBS.bit.Data_A = 1;
    //	CanaRegs.CAN_IF3OBS.bit.Data_B = 1;
    //	CanaRegs.CAN_IF3OBS.bit.Arb = 1;
    
    
    //    HWREGH(CANA_BASE + CAN_O_IF3UPD) = 0xFFFF;
    //    HWREGH(CANA_BASE + CAN_O_IF3OBS) = CAN_IF3OBS_ARB | CAN_IF3OBS_DATA_A | CAN_IF3OBS_DATA_B;
    //    HWREGH(CANA_BASE + CAN_O_IF3OBS) = CAN_IF3OBS_DATA_A ;
    
    	for(;;)
    	{
            // Check the error flag to see if errors occurred
            if(g_bErrFlag)
            {
     //       	asm("   ESTOP0");
            }
    
    //        if(g_ulTxMsgCount == g_ulRxMsgCount){
    ////            CANMessageSet(CANA_BASE, 1, &sTXCANMessage, MSG_OBJ_TYPE_TX);
    //        	sTXCANMessage.ui32MsgID = CANRxID;                      // CAN message ID - use 1
    //            CANMessageSet(CANB_BASE, 1, &sTXCANMessage, MSG_OBJ_TYPE_TX);
    //        }else{
    //        	g_bErrFlag = 1;
    //        }
    
            if(EnableFlag)
            {
            	EnableFlag=0;
                ucTXMsgData[0] = (u32CntTXMsgData>>24) & 0xFF;
                ucTXMsgData[1] = (u32CntTXMsgData>>16) & 0xFF;
                ucTXMsgData[2] = (u32CntTXMsgData>>8) & 0xFF;
                ucTXMsgData[3] = (u32CntTXMsgData) & 0xFF;
    
            sTXCANMessage.pucMsgData = ucTXMsgData;           // ptr to message content
        	sTXCANMessage.ui32MsgID = CANRxID;                      // CAN message ID - use 1
            CANMessageSet(CANB_BASE, 1, &sTXCANMessage, MSG_OBJ_TYPE_TX);
            }
    
            if(EnableFlag2)
            {
            	EnableFlag2=0;
                EALLOW;
    
                 // Check the arguments.
        //        ASSERT(CANBaseValid(CANB_BASE));
    
                HWREGH(CANB_BASE + CAN_O_CTL) = CAN_CTL_INIT;
                HWREGH(CANB_BASE + CAN_O_CTL) = CAN_CTL_INIT+CAN_CTL_SWR;
    
                // Clear the init bit in the control register.
                HWREGH(CANB_BASE + CAN_O_CTL) = HWREGH(CANB_BASE + CAN_O_CTL) &
                                               ~CAN_CTL_INIT;
    
                EDIS;
            }
    
    //        if(EnableFlag3)
    //        {
    //            temp[0]=*(Uint16 *)0x00048130;
    //            temp[1]=*(Uint16 *)0x00048131;
    //            temp[2]=*(Uint16 *)0x00048132;
    //            temp[3]=*(Uint16 *)0x00048133;
    //
    //
    //
    //            TestVar=*(Uint32 *)0x00048130;
    //            temp1[0]=TestVar  & 0xFF;
    //            temp1[1]=(TestVar>>8)  & 0xFF;
    //            temp1[2]=(TestVar>>16)  & 0xFF;
    //            temp1[3]=(TestVar>>24)  & 0xFF;
    //
    //
    //        }
    
            // Now wait 1 second before continuing
            DELAY_US(1000*1000);
    //        CANRxID++;
            if(CANRxID>131){
            	CANRxID=101;
            }
            DELAY_US(1000*1000);
    
    		// Increment the value in the transmitted message data.
    		//(*(unsigned long *)ucTXMsgData)++;
        }
    }
    
    
    
    
    

    best regards,

    Simen

  • Simen,
    It is expected that IF3 behavior will be different compared to IF1/IF2, since IF3 is for Receive only. Furthermore, this device lacks DMA which IF3, in some measure, relies on. Will update you on what I find.
  • On a different note, you may want to move to C2000Ware, since no updates are being made to ControlSUITE.
  • Hareesh,


    Thank you very much for your kind answers and recommands.


    best regards,
    Simen