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.

F29H850TU: Recommendation for Disable/RestoreInt on C29 device

Part Number: F29H850TU


Tool/software:

Hello TI Experts,

On C28 devices, I have been using the following functions, implemented in assembly, to disable and restore interrupts around critical sections.

Could you please recommend an equivalent for the C29 devices?

Thank you in advance!

Beat

extern uint16_t DisableInt(void);
extern void RestoreInt(uint16_t Stat0);

_DisableInt:
    PUSH  ST1
    SETC  INTM,DBGM
    MOV   AL, *--SP
    LRETR

_RestoreInt:
    MOV   *SP++, AL
    POP   ST1
    LRETR

  • Hi Beat,

    Are you using INT or RTINT?

    In terms of enabling / disabling interrupts...

    As you may know, we do not support assembly instructions in C29x, but we do have two sets of interrupt enable/disable that would be relevant.

    We have the ENINT and DISINT for enabling and disabling INT at the CPU level (modifying DSTS.INTE). Note that RTINT are not disableable. 

    More importantly, there is the PIPE global enable / disable for forwarding of INT and RTINT. 

    In terms of restoring interrupts...

    As RTINT has its own RTINT HW stack, these interrupts are not only serviced with lower latency, but they also have automated context save and restore of CPU registers. For INT, the registers need to be saved / restored in software by the user. 

    The TRM and CPU user guide has more information and diagrams on the same as well.

    Best Regards,

    Aishwarya

  • Hello Aishwarya,

    Thank you for your response. 

    I am aware of the global switch, but this is not what I am looking for.

    The original Disable/Restore pair behaves differently, in that RestoreInt() will only restore the enable of interrupts that were already enabled at the time DisableInt() was called.

    By calling DISINT, followed by ENINT, the global enable always occurs, even if it was disabled before.

    Thus, I would need some atomic means to save the state of DSTS.INTE and clear it simultaneously.

    Does the C29 Clang compiler support such atomic operations?

    Kind regards,

    Beat

  • Beat,

    Thank you for clarifying. Let me look into this further and get back to you.

    Best Regards,

    Aishwarya

  • Beat,

    In C29, DISNT and ENINT can be used within an atomic block to handle disable/enable of INT. The 2.9. Built-In Functions and Intrinsics — C29 Clang Compiler Tools User's Guide introduces the atomic entry / leave intrinsic (C29-specific) as well as the enable/disable intrinsic (present on C28x as well).

    However, since atomic instructions are present in C29, I would suggest to simply place the atomic blocks around any and all critical sections of code and let the hardware automatically take care of blocking INT/RTINT interrupts from entering the CPU pipeline. User does not need to worry about where in code it's allowed or not allowed to enable/disable INT/RTINT. Refer to the snippet below from the C29x CPU Reference Guide for more details. 

    Best Regards,

    Aishwarya

  • Aishwarya - this is super helpful! Thank you for pointing me to those new intrinsics.
    Kind regards,

    Beat