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: The HwiP_disable() function does not work

Part Number: TDA4VM

Hello TI Experts,

According to the requirements of our project, we need to add a critical section protection mechanism to the code, after querying the sys/BIOS user's guide document, we determine that the critical section protection is achieved by calling the Hwip_disable() to close all interrupts when entering the critical section, and using the Hwip_restore() to open all interrupts when leaving the critical section, as shown in the following code:

uintptr_t gatekey;

gatekey = HwiP_disable();

/*critical section code*/

HwiP_restore(gatekey);

But during the validation process, we found that interrupt can still run after calling the Hwip_disable() function.

In addition, it is possible to close a specific interrupt by calling the function HwiP_disableInterrupt (int32_t interruptNum).

I wonder why the HwiP_disable() function doesn't work, and how to fix it.Thank you in advance!

  • Hi Xiang,

    What SDK are you using? TI SYS/BIOS is no longer supported with the latest TDA4VM SDKs

    regards

    Suman

  • Hi Suman,

    Thanks for your reply.

    The SDK we use is  pdk_jacinto_07_03_00_29,and the version is indeed signtly older.

    regards

    Xiang

  • Hi Xiang,

    Sys/BIOS has been descoped for a while now, will need some time to look into this.

    Can you please share a sample code which I can quickly try to reproduce this issue on my end?

    Regards,
    Parth

  • Hi Parth,

    Thanks for your reply. 

    We modified the file in the SDK, the path and name is /pdk_jacinto_0703_00_29/packages/ti/drv/i2c/src/v1/I2C_v1.c, and the modified sample code is as follows:


    uintptr_t gatekey;

    /* generate start */
    gatekey = HwiP_disable();
    I2CMasterStart(hwAttrs->baseAddr);

    while ((object->writeCountIdx != 0U) && (timeout != 0))
    {
    /* wait for transmit ready or error */
    while(((I2CMasterIntRawStatusEx(hwAttrs->baseAddr, I2C_INT_TRANSMIT_READY) == 0U) && \
    (I2CMasterIntRawStatusEx(hwAttrs->baseAddr, I2C_INT_ARBITRATION_LOST | \
    I2C_INT_NO_ACK | \
    I2C_INT_ACCESS_ERROR | \
    I2C_INT_STOP_CONDITION ) == 0U)) && \
    (timeout != 0))
    {
    I2C_v1_udelay(I2C_DELAY_USEC);
    if (I2C_checkTimeout(&uSecTimeout))
    {
    timeout--;
    }
    }

    errStat = I2CMasterIntRawStatusEx(hwAttrs->baseAddr, I2C_INT_ARBITRATION_LOST | \
    I2C_INT_NO_ACK | \
    I2C_INT_ACCESS_ERROR);

    /* if we get an error, do a stop and return failure */
    if (errStat != 0U)
    /* if we get an error, do a stop and return failure */
    {
    fatalError = 1U;
    break;
    }
    /* write byte and increase data pointer to next byte */
    I2CMasterDataPut(hwAttrs->baseAddr, *(object->writeBufIdx));
    (object->writeBufIdx)++;

    /* clear transmit ready interrupt */
    I2CMasterIntClearEx(hwAttrs->baseAddr, I2C_INT_TRANSMIT_READY);

    /* update number of bytes written */
    object->writeCountIdx--;
    }
    HwiP_restore(gatekey);

    The above is where we have made changes, and the full document is attached.3302.I2C_v1.c

    Regards,

    Xiang Gao

  • Hi Xiang,

    Thanks for the details, will try this once and provide the feedback

    Regards,
    Parth

  • Hi Xiang,

    Looked into this, the changes seems fine. I see it being used at multiple places in SDK.
    Can you please share the details on how you are validating this? 

    In addition, it is possible to close a specific interrupt by calling the function HwiP_disableInterrupt (int32_t interruptNum).

    Also, yes, this should be possible to disable specific interrupts using this API

    Regards,
    Parth

  • Hi Parth,

    Our verification steps are as follows:

    1. Add a test variable in the interrupt function of CAN communication, which will increase 1 when receiving a CAN message;

    2.Add a delay in the critical section code, and the delay time is two cycles of CAN message;

    3.Print out the test variable when entering and exiting critical section code;

    We expect that all interrupts should be closed after executing the HwiP_disable() function to enters the critical section code, and the test variable will not increase, so the printed result should be the same. But in the actual test, whether the HwiP_disable() function is executed or not, we get the same result. The test variable still increase after we execute the HwiP_disable() function. So we think HwiP_disable() function does not work and the global interrupt cannot be closed.

    Regards,

    Xiang Gao

  • Hi Parth,

    Please ask if you have verified the steps I provided? And whether you have obtained the same results as me?We urgently need to address this issue as soon as possible.

    Hope to reply soon,thanks.

    Regards,

    Xiang Gao

  • Hi Xiang & Parth,

    I have am facing a very similar issue with HwiP_disable() and HwiP_restore() functions. I have registered a callback function for a hardware interrupt using the function HwiP_create(). After disabling the interrupt I tried to generate a hardware interrupt using HwiP_post(). But I am still able to go to the callback function. Have you been able to find the reason or a potential solution for it? 

    Regards

    Rajaram

  • Hi Xiang, Rajaram,

    I believe this issue was resolved in another discussion.

    In a short summary, please refer to the osal test in the SDK for reference. We can see the interrupts getting disabled there after HwiP_disable.

    Regards,
    Parth