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.

TMS320F2800157: LockStep Functionality

Part Number: TMS320F2800157
Other Parts Discussed in Thread: C2000WARE

Software:
CCS Version: 12.7.0.00007 

C2000Ware_5_02_00_00

Hardware:

LAUNCHXL_F2800157

Hi,

I am trying to do POC of Lockstep feature of the board. I have gone through the Reference Manual, Safety Manual of the MCU and also looked at the lcm.c and lcm.h files in driverlib. I want ask a few questions about the Lockstep function and how I can integrate it into my software correctly.

I am just running the led_ex1_blinky example, which uses sysCfg to create board files and I am running all the code in DEBUG mode. (I know that LCM doesn't work on DEBUG mode)

1.

On the reference manual it says: 

  1. Lock the LSEN configuration using the following bit:
    • CPU_SYS_REGS[CPUSYSLOCK2.LSEN=1]
  2. Enable the comparator for the desired modules using the following bit:
    • LCM_REGS[LCM_CONTROL.CMPEN=1]
    • Lockstep compare will begin the immediate next cycle

By default, LCM should be enable on the example and that is what I saw on the example. On the Device_init function inside device.c file, I see 

that:

//
// Enable lockstep compare module
//
HWREG_BP(LCM_CPU1_BASE + LCM_O_CONTROL) |= LCM_CONTROL_CMPEN;

but I don't see where the LSEN configuration is being locked. I only see a similar marco LCM_STATUS_LSEN inside LCM_isLockStepEnabled function, which returns true when I call it inside my main function. Do I need to set any register or is this enough?


 

2.

I tried running the code below, and saw how we are doing self test/forcing error in debug mode and then clearing the flags at the end.

LCM_Status stat = LCM_runSelfTest(LCM_CPU1_BASE);
LCM_Status stat1 = LCM_runComp1ErrorForceTest(LCM_CPU1_BASE);
LCM_Status stat2 = LCM_runComp2ErrorForceTest(LCM_CPU1_BASE);

So, looking the code, I am assuming this is how I will use the LCM inside my code. After any critical algorithm that I need to compare, I will call LCM_getLockStepCompareStatus function, if it fails, then I need to do error handling and clear flag to continue. If it passes then, I can just continue and no need clear any Flags. Is this the correct way to use LCM functionality? or there is more that needs to be added?

uint16_t x = 10;
uint16_t y = 5;
uint16_t z = x+y;
    
if (LCM_getLockStepCompareStatus(LCM_CPU1_BASE) == LCM_FAIL) {
    // handle error and clear the flag
    LCM_clearFlags(LCM_STATUS_CLEAR_CMP_FAIL);
} else {
    // algorithm works fine
}

3. I read about how the LCM error will be generate an NMI interrupt, whether it is register parity or Lockstep compare. I have to enable the interrupt in my sysCfg and whenever there is an LCM error I will receive the __interrupt void Interrupt_nmiHandler(void). I can use SysCtl_getNMIFlagStatus() function to get what kind of error and do error handling.

My questions here are:
a. even if I call LCM_clearFlags(LCM_STATUS_CLEAR_CMP_FAIL) after receiving the LCM compare error, will I still get an interrupt? If yes, then I need to clear NMIFlags on interrupt.

b. When I get the Register Parity error NMI interrupt, then do I need to clear the flag using SysCtl_clearAllNMIFlags(void) or SysCtl_clearNMIStatus(uint16_t nmiFlags) to continue with program instead of ending the program?


4. I saw that to test the LCM errors there is section 3.5.3 Error Injection Tests to force errors. Are there any other ways to create LCM errors without injection? (like bombarding the hardware with alpha particles)

  • Hi Sheershak,

    even if I call LCM_clearFlags(LCM_STATUS_CLEAR_CMP_FAIL) after receiving the LCM compare error, will I still get an interrupt? If yes, then I need to clear NMIFlags on interrupt.

    > You would get an NMI as soon  as compare fail is generated no matter how fast you try to clear the cmp fail status..
    Yes you need to clear the NMI flags and system control registers flags in NMI ISR

    When I get the Register Parity error NMI interrupt, then do I need to clear the flag using SysCtl_clearAllNMIFlags(void) or SysCtl_clearNMIStatus(uint16_t nmiFlags) to continue with program instead of ending the program?

    Yes clear all flags after error and then continue rest of program

    I saw that to test the LCM errors there is section 3.5.3 Error Injection Tests to force errors. Are there any other ways to create LCM errors without injection? (like bombarding the hardware with alpha particles)

    Sure but I wouldn't advise that for obvious reasons.. Why would you prefer destructive/intrusive test vs a hardware based fault injection to generate LCM error ?

  • Awesome, thank you for clarification.

     Can you also answer the first and second part?

    Do I need to set any register or is this enough?
    Is this the correct way to use LCM functionality? or there is more that needs to be added?

    Please advise please any example on how can I use the LCM functions.

  • You would get an NMI as soon  as compare fail is generated no matter how fast you try to clear the cmp fail status

    I have the enable the global NMI Interrupt set as you see in the image, but I do not get any interrupts, when i run the code

    LCM_Status stat1 = LCM_runComp1ErrorForceTest(LCM_CPU1_BASE);
    LCM_Status stat2 = LCM_runComp2ErrorForceTest(LCM_CPU1_BASE);

    Can you also explain the reasoning behind it? I am not running in DEBUG mode. I am verifying that with the LCM_isDebuggerConnected(LCM_CPU1_BASE) function.

  • , Can you also explain me how you functions: LCM_lockRegister, LCM_unlockRegister and LCM_commitRegister? Because the Manual says "The parity scheme provides one parity bit per byte of data in the corresponding registers. Updates to any of the constantly-monitored registers causes an update to the parity bit."
    What are these constantly-monitored registers? 

    The code says

    //  \param regs is the logical OR of the registers to be locked
    //!             - LCM_LOCK_LCM_CONTROL
    //!             - LCM_LOCK_LCM_STATUS_CLEAR
    //!             - LCM_LOCK_PARITY_TEST

    Please advice how to use these functions because no examples have been provided.

  • What are these constantly-monitored registers? 

    These registers are parity protected stated very clearly in the manual.

  • I have the enable the global NMI Interrupt set as you see in the image, but I do not get any interrupts, when i run the code

    Do you have an NMI ISR set ?
    If yes please put a breakpoint and see if it reaches the NMI ISR

  • Yes, I have the NMI ISR Set as seen in the image below. I tried putting breakpoint at the interrupt but I never reach there.

     

  • I looked at the example sysctl_ex1_missing_clock_detection to see NMI was set. It is completely different then just enabling the Enable NMI Global Interrupt on the sysCfg file. The example is running fine but it is simulating Missing Clock Detect feature, which I don't want right now (since I am focusing LCM)

        stat = SysCtl_getNMIStatus();
    
        //
        // Simulate a missing clock detection
        //
        SysCtl_disconnectMCDClockSource();
    
        stat = SysCtl_getNMIStatus();

    One thing I notice in the example is before simulating the missing clock detection, the SysCtl_getNMIStatus() function returns false and after the SysCtl_disconnectMCDClockSource() function call, SysCtl_getNMIStatus() returns true. 

    I don't understand why NMI is not getting enabled. Can you please help?
    My code for enabling NMI is as follows:

    //
        // Re-map NMI signal to call the ISR function in this
        // example
        //
        SysCtl_clearAllNMIFlags();
        Interrupt_register(INT_NMI, &nmi_isr);
    
        //
        // Enabling the NMI global interrupt
        //
        SysCtl_enableNMIGlobalInterrupt();
    
        Interrupt_enable(INT_NMI);
    
        //
        // Enable Global Interrupt (INTM) and real time interrupt (DBGM)
        //
        EINT;
        ERTM;

  • Hi Sheershak,

    I looked at the example sysctl_ex1_missing_clock_detection to see NMI was set. It is completely different then just enabling the Enable NMI Global Interrupt on the sysCfg file

    Assuming that you have the NMI handler setup correctly taking MCD example as reference.

    On occurrence of a lockstep module compare error LCM_ERR_FLG register is set and NMI Flags should also be set can you set a break point and see the Registers view and check those.

    Also below is condition : 

    No further NMI's are fired until GERR flag is cleared.

    You can also check the NMISHDWFLG register. Below bit as soon as you force/trigger LCM error

  • Alright, I got it working. I set up everything right and cleared the GERR flag, after the interrupt.

    One last question regarding this topic.

    We are forcing the LCM errors using LCM_runComp1ErrorForceTest() function but in production, we won't force errors.
    The LCM is running continuously in the background and when we encounter any LCM error, we will get an NMI Interrupt (where we need to clear LCM Flags, NMI Flags and GERR Flag). I have put a sample code below of this implementation. Is this right way to go in production?

    __interrupt void nmi_isr(void)
    {
        uint16_t nmistatus = SysCtl_getNMIFlagStatus();
        SysCtl_clearAllNMIFlags();
        if ((nmistatus & SYSCTL_NMI_NMIINT) != 0U) {
            log("SYSCTL_NMI_NMIINT\n\0");
        }
        if ((nmistatus & SYSCTL_NMI_LSCMPERR) != 0U) {
            LCM_clearFlags(LCM_CPU1_BASE, LCM_STATUS_CLEAR_CMP_FAIL);
            uint32_t LCMErrorFlag = SysCtl_getLCMErrorFlag();
            SysCtl_clearLCMErrorFlag(LCMErrorFlag);
        }
    }

     Also, thank you so much for all your help.

  • Hi Sheershak,

    FYI : The SDL(Software Diagnostic Library) for F280015x is public. You can find it in C2000Ware under libraries/diagnostic/f280015x.
    If not already aware of it ?

    We are forcing the LCM errors using LCM_runComp1ErrorForceTest() function but in production, we won't force errors.

    Well thats upto your functional safety goal. That's actually a test for diagnostic if you are aware of functional safety terminologies

    The LCM is running continuously in the background and when we encounter any LCM error, we will get an NMI Interrupt (where we need to clear LCM Flags, NMI Flags and GERR Flag)

    If the actual LCM compare error occurs at runtime without forcing error you would normally go to NMI ISR and make sure you put the system in safe state
    Depending on your application you would want to take action to put system in safe state and decide if its safe to proceed further if lcm occurs we dont advise customers on those matters its responsibility of user system integrator

    If you want to proceed further than yes clear all flags (NMI flags, LCM error flags) and LCM CMP Err status and exit NMI ISR. If check for clearing the flags can be the LCM compare error status register instead of NMI status since the NMI status can get cleared on assertion of NMIWD.

    Thanks