2023-05-16 12:50 AM
Hi team, can anyone help me what is wrong im doing in the code, ihave used the SRAM(1/2/3) or part of SRAM which is SRAM1, the data is getting erased or written to the specified address but at the end its getting hard fault, can anyone help me to rectify this.
#define SRAM1_BASE_ADDR 0x20000000
#define SRAM_SIZE 786000 // SRAM size in bytes
#define SRAM1_SIZE 912000 // SRAM size in bytes
if (HAL_RAMCFG_StartECC(&hramcfg_SRAM1) != HAL_OK)
{
Error_Handler();
}
Fill_wMemory((uint32_t*)sram_addr, SRAM1_SIZE , DATA_VALUE1);
}
and other approch is with API function
void erase_sram(void)
{
uint32_t *sram_addr = (uint32_t*)SRAM1_BASE_ADDR; //Pointer to SRAM base address
//Erase SRAM memory
for(uint32_t i = 0; i < SRAM_SIZE; i+=4)
{
// *(sram_addr + i/4) = 0; //Erase data in SRAM memory
*sram_addr = 0; //Write data to SRAM memory
sram_addr+=1;
}
}
2023-05-16 12:56 AM
Look at registers when it actually faults.
Make sure clocks for additional SRAM are enabled.
Check MPU configuration.
2023-05-16 02:32 AM