void EIM_InjectSramEccError(EIM_MemoryType mem, EIM_ErrorType errType, volatile uint32 *testAddr)
{
uint8 channel = (uint8)mem;
*(volatile uint32 *) EICHEN_BASE_ADDR =0x80000000;
*(volatile uint32 *) EIMCR_BASE_ADDR =0x00000001;
//(void)*(volatile uint32 *) EIMCR_BASE_ADDR;
/* Step 1: Clear previous configuration */
*(volatile uint32 *)EICHD0_WORD0_ADDR = 0x00000000;
*(volatile uint32 *)EICHD0_WORD1_ADDR = 0x00000000;
/* Step 2: Configure ECC injection */
if (errType == EIM_ERROR_SINGLE_BIT)
{
/* Flip 1 data bit → correctable */
*(volatile uint32 *)EICHD0_WORD1_ADDR = 0x00000001;
}
else
{
/* Flip 2 data bits → uncorrectable error */
*(volatile uint32 *)EICHD0_WORD1_ADDR = 0x00000003;
}
/* Step 3: Dummy write (ensure valid ECC exists) */
*testAddr = 0xA5A5A5A5;
/* Step 4: Read back → triggers ECC error */
volatile uint32 readVal = *testAddr;
(void)readVal; /* جلوگیری optimization */
*(volatile uint32 *) EICHEN_BASE_ADDR =0x80000000;
}
void test_ecc()
{
volatile uint32 *addr = (uint32 *)0x20400000; // Example SRAM_L address
/* Test single-bit error (correctable) */
EIM_InjectSramEccError(EIM_MEM_SRAM_L, EIM_ERROR_SINGLE_BIT, addr);
/* Test double-bit error (uncorrectable) */
EIM_InjectSramEccError(EIM_MEM_SRAM_L, EIM_ERROR_DOUBLE_BIT, addr);
}
could you please correct me if something is wrong here in procedure or understanding
if anything more needs to be added then also please let me know .
But for SRAM0 , i am able to inject fault for ECC and observe in ERM register that the fault is set.
Thanks in Advance !