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.

TDA4VM: Sequential execution of MCAN2 Tx and Rx

Part Number: TDA4VM

Hello,

We are working with TDA4 EVM and PSDK 6.1.x.x.

We have modified the app_tidl_avp demo application by:

(1) calling appRemoteServiceRun at the end of each frame

(2) adding code to sequentially transmit and then receive CAN messages on MCU2_1 (see below).

appInit()
{   ...

    /* Enable Interrupts */
    MCAN_enableIntr(gMcanModAddr, MCAN_INTR_MASK_ALL, (uint32_t)TRUE);
    MCAN_enableIntr(gMcanModAddr,
                    MCAN_INTR_SRC_RES_ADDR_ACCESS, (uint32_t)FALSE);

    /* Select Interrupt Line */
    MCAN_selectIntrLine(gMcanModAddr,
                        MCAN_INTR_MASK_ALL,
                        MCAN_INTR_LINE_NUM_0);
...
}

MCAN2RemoteServiceHandler
{
       /* Enable Interrupt Line */
       MCAN_enableIntrLine(gMcanModAddr,
                           MCAN_INTR_LINE_NUM_0,
                           1U);
       /* Enable Transmission interrupt */
       status = MCAN_txBufTransIntrEnable(gMcanModAddr,
                                              1U,
                                              (uint32_t)TRUE);

      /* code to transmit CAN message */

      /* Select Interrupt Line */
      MCAN_selectIntrLine(gMcanModAddr,
                        MCAN_INTR_MASK_ALL,
                        MCAN_INTR_LINE_NUM_1);
      /* Enable Interrupt Line */
      MCAN_enableIntrLine(gMcanModAddr,
                        MCAN_INTR_LINE_NUM_1,
                        1U);

     /* code to receive CAN message */
}

This code is referred from the MCAN EVM Loopback example.

In this application, if we only enable Tx or Rx at a time, the app works fine.

But if we enable both, as shown below, then for the very first frame, the CAN messages are transmitted properly, but CAN Rx does not proceed and app hangs.

Is it possible to run both Tx and Rx on the same MCAN2 module in this fashion?

Thank you.

  • Hi Sagar,

    You should be able to use MCAN Tx and Rx simultaneously. Above shown code only shows interrupt related configurations.

    Can you please also share/provide the code for Tx and Rx handling? 

    Thanks & Regards,
    Vivek Dhande.

    Texas Instruments (India) Pvt Ltd

  • Hello Vivek,

    The code for Tx and Rx handling has been shared through our TI contact.

    We did not come across any example in the SDK where MCAN Tx and Rx have been used simultaneously.

    Can you point us to such examples?

    Thank you.

  • Hi Sagar,

    After reviewing your code, I found one issue with Rx and TX use-case being run simultaneously.

    Please check and confirm the following points:

    • You are handling Tx and Rx cases differently. It is polling on global variable for Tx case while you are using semphore for Rx case. Both should be handled in same manner.
    • You always assign all the interrupts (let it be Tx or Rx) to a single interrupt line (it is done through 'MCAN_selectIntrLine()' API). This causes failures while running Tx and Rx use cases together since it is getting overwritten every time it is called for Tx and Rx. Either, Rx and Tx interrupts should be mapped to separate interrupt lines or ISR for both should be the same.

    Thanks & Regards,
    Vivek Dhande.

    Texas Instruments (India) Pvt Ltd

  • Hi Vivek,

    -- Main application is triggering in Synchronous MCAN Tx test application to transmit messages periodically after every alternate frame 66ms (since baud rate is 500kbps).
    Rx test is asynchronously created using "Task" to receive messages sent at every 66ms using IG generator.
    For same reason semaphores are used only in RX test and polling on global variable used in Tx test.
    So kindly advice if any issue w.r.t design of the mcan application.

    -- Already thread for invoking timer is still in discussion as below:-
    e2e.ti.com/.../3282632
    So using infinite while loop "appMcanRxRun" for Rx test is triggered continuosly.

    -- For Tx ,MCAN_INTR_LINE_NUM_0 is used and for Rx ,MCAN_INTR_LINE_NUM_1 is used.
    Also MCAN_selectIntrLine and MCAN_enableIntrLine is done seperately for both Rx and Tx in MCAN2_setup and appRemoteServiceMCAN2Handler respectively.


    -- Interrupt for Tx is registered as below in App_mcanXBarConfig():-
    App_mcanRegisterInterrupt(APP_MAIN_MCAN_2_INT0, &App_mcanIntr0ISR);

    Interrupt for Rx is registered as below in appConfigureMcan():-
    App_mcanRegisterInterrupt (APP_MAIN_MCAN_2_INT1, &App_mcanIntr1ISR);

    Kindly let me know in case of any clarifications needed frommy end.

    Thanks and Regards

    Pooja Krishna

  • Hi Sagar/Pooja,

    Can you please take care of the issues which I have pointed out in my previous reply? Those can be summarized as follows (please refer to earlier mail for more details):

    • Handle Tx and Rx interrupts in the same manner.
    • "Either use a single interrupt line for both Tx and Rx & assign all interrupts to this line" OR "use separate lines for Tx and Rx & assign respective interrupts to the respective line". 

    Thanks & Regards,
    Vivek Dhande.

    Texas Instruments (India) Pvt Ltd

  • Hi Vivek,

    1. Currently modified Rx and Tx to poll on global variable  gMcanIsrIntr1Flag, gMcanIsrIntr0Flag respectively.

         Removed semaphore related calls from Rx test.Now both interrupts are handled in same manner.

    2. Already my application is using separate lines for Tx and Rx & assigned respective interrupts to the respective line.

    TX

    • App_mcanRegisterInterrupt(APP_MAIN_MCAN_2_INT0, &App_mcanIntr0ISR);
    • MCAN_selectIntrLine(gMcanModAddr,MCAN_INTR_MASK_ALL,MCAN_INTR_LINE_NUM_0);

    RX

    • App_mcanRegisterInterrupt (APP_MAIN_MCAN_2_INT1, &App_mcanIntr1ISR);
    • MCAN_selectIntrLine(APP_MCAN2_BASEADDR,MCAN_INTR_MASK_ALL,MCAN_INTR_LINE_NUM_1);

    3. Same behaviour exists -> Tx happens to hang once message is received from IG generator.

    Thanks and Regards

    Pooja Krishna

  • Hello Vivek,

    Gentle Reminder !!!

    Thanks and Regards

    Pooja Krishna

  • Hi Pooja,

    Can you please try the following:

    • Move Tx and Rx processing to the same ISR, try this and see if this works.

    The above should solve your problem.

    Once this works we can look at the separate ISR for Rx and Tx.

    Thanks & Regards,
    Vivek Dhande.

    Texas Instruments (India) Pvt Ltd

  • Hello Vivek,

    1. We register interrupt using "App_mcanRegisterInterrupt" API for Tx and Rx. So does it mean we can register "App_mcanIntr01ISR"as shown below  to both  APP_MAIN_MCAN_2_INT1(RX) and APP_MAIN_MCAN_2_INT0(TX).

    Kindly confirm the above modification.

    Thanks and Regards

    Pooja Krishna

  • Hi Pooja,

    The above ISR implementation looks fine. Can you make both ISRs identical and try? 

    Thanks & Regards,
    Vivek Dhande.

    Texas Instruments (India) Pvt Ltd

  • Hello Vivek,

    As discussed the following ISR was used common for both TX , RX

    2. Registered single interrupt line common for both Rx , Tx

    configStatus = App_mcanRegisterInterrupt (APP_MAIN_MCAN_2_INT0, &App_mcanIntr01ISR);

    /* Select Interrupt Line */
    MCAN_selectIntrLine(APP_MCAN2_BASEADDR,MCAN_INTR_MASK_ALL,MCAN_INTR_LINE_NUM_0);

    /* Enable Interrupt Line */
    MCAN_enableIntrLine(APP_MCAN2_BASEADDR,MCAN_INTR_LINE_NUM_0,1U);

    3. The following code has been used to trigger TX and RX inside infinite while loop as below:-

    Observation

    For initial frames,it works properly but by the time boot process reaches root login page, its stopped inside Txtest()

    Kindly let me know in case of any modifications needed from my side.

    Thanks and Regards

    Pooja Krishna

     

  • Hi Pooja,

    At this point where it is stuck at 'Txtest()', can you please look at MCAN registers and see if it is triggering interrupt or not? 

    Thanks & Regards,
    Vivek Dhande.

    Texas Instruments (India) Pvt Ltd