Other Parts Discussed in Thread: HALCOGEN
Hi,
I want to perform periodically a RAM ECC self-test in my application. I started from self-test functions generated by Halcogen in sys_selftest.c file. Since 2-bit error causes an abort, I need to remove the 2-bit error injection in the functions. I attach the two modified functions that I’m calling. There are two different results:
- If I call the checkRAMECC()_mod function periodically, everything is fine. Every time I inject 1-bit error, both tcram1ErrStat and tcram2ErrStat flags are set as expected.
- If I call the checkB0RAMECC()_mod function periodically, tcram1ErrStat is set just the first time I call the function. From the second time that I call the function, the flag is not set anymore as if the error is not corrected.
There is a reason for this behavior? How can I proceed?
Thanks
bool checkRAMECC_mod() { bool error = false; volatile SIS_U64 ramread = 0U; volatile SIS_U32 regread = 0U; SIS_U32 tcram1ErrStat, tcram2ErrStat = 0U; SIS_U64 tcramA1_bk = tcramA1bit; SIS_U64 tcramB1_bk = tcramB1bit; /* Clear RAMOCUUR before setting RAMTHRESHOLD register */ tcram1REG->RAMOCCUR = 0U; tcram2REG->RAMOCCUR = 0U; /* Set Single-bit Error Threshold Count as 1 */ tcram1REG->RAMTHRESHOLD = 1U; tcram2REG->RAMTHRESHOLD = 1U; /* Disable single bit error generation */ tcram1REG->RAMINTCTRL = 0U; tcram2REG->RAMINTCTRL = 0U; /* Enable writes to ECC Memory, enable ECC error response */ tcram1REG->RAMCTRL = 0x0005010AU; tcram2REG->RAMCTRL = 0x0005010AU; /* Force a single bit or double bit error in both the banks */ /* corrupting RAM ECC 1-bit cause a corrected 1-bit ECC error and SERR flag set if threshold is 1 */ _coreDisableRamEcc_(); tcramA1bitError ^= 1U; tcramB1bitError ^= 1U; _coreEnableRamEcc_(); /* Read the corrupted data to generate single bit error */ ramread = tcramA1bit; ramread = tcramB1bit; /* Check for error status */ tcram1ErrStat = tcram1REG->RAMERRSTATUS & mcECC_SERR_FLAG_MASK; tcram2ErrStat = tcram2REG->RAMERRSTATUS & mcECC_SERR_FLAG_MASK; if ((tcram1ErrStat == 0U) || (tcram2ErrStat == 0U)) // SERR not set in TCRAM1 or TCRAM2 modules { error = true; // TCRAM module does not reflect 1-bit error reported by CPU } else { /* Clear SERR flag by writing 1, otherwise it stays set and an error is detected even if no error are present! */ tcram1REG->RAMERRSTATUS = 0x1U; tcram2REG->RAMERRSTATUS = 0x1U; } regread = tcram1REG->RAMUERRADDR; regread = tcram2REG->RAMUERRADDR; /* Restore backup value, disabling writes to ECC RAM */ tcram1REG->RAMCTRL = 0x0005000AU; tcram2REG->RAMCTRL = 0x0005000AU; /* Compute correct ECC */ tcramA1bit = tcramA1_bk; tcramB1bit = tcramB1_bk; tcramA2bit = tcramA2_bk; tcramB2bit = tcramB2_bk; return error; } bool checkB0RAMECC_mod() { bool error = false; volatile SIS_U64 ramread = 0U; volatile SIS_U32 regread = 0U; SIS_U32 tcram1ErrStat, tcram2ErrStat = 0U; SIS_U64 tcramA1_bk = tcramA1bit; /* Clear RAMOCUUR before setting RAMTHRESHOLD register */ tcram1REG->RAMOCCUR = 0U; tcram2REG->RAMOCCUR = 0U; /* Set Single-bit Error Threshold Count as 1 */ tcram1REG->RAMTHRESHOLD = 1U; /* It must be set to 1 for a correct test, otherwise SERR flag will never set to 1 in this test*/ tcram2REG->RAMTHRESHOLD = 1U; /* Disable single bit error generation */ tcram1REG->RAMINTCTRL = 0U; tcram2REG->RAMINTCTRL = 0U; /* Enable writes to ECC Memory, enable ECC error response */ tcram1REG->RAMCTRL = 0x0005010AU; tcram2REG->RAMCTRL = 0x0005010AU; /* Force a single bit or double bit error in both the banks */ _coreDisableRamEcc_(); tcramA1bitError ^= 1U; _coreEnableRamEcc_(); /* Read the corrupted data to generate single bit error */ ramread = tcramA1bit; /* Check for error status */ tcram1ErrStat = tcram1REG->RAMERRSTATUS & mcECC_SERR_FLAG_MASK; tcram2ErrStat = tcram2REG->RAMERRSTATUS & mcECC_SERR_FLAG_MASK; if ((tcram1ErrStat == 0U) && (tcram2ErrStat == 0U)) // SERR not set in TCRAM1 or TCRAM2 modules { error = true; // TCRAM module does not reflect 1-bit error reported by CPU } else { /* Clear SERR flag by writing 1, otherwise it stays set and an error is detected even if no error are present! */ tcram1REG->RAMERRSTATUS = 0x1U; tcram2REG->RAMERRSTATUS = 0x1U; } regread = tcram1REG->RAMUERRADDR; regread = tcram2REG->RAMUERRADDR; /* Restore backup value, disabling writes to ECC RAM */ tcram1REG->RAMCTRL = bkRAMCTRL1; tcram2REG->RAMCTRL = bkRAMCTRL2; /* Compute correct ECC */ tcramA1bit = tcramA1_bk; return error; }