SRAM Memory write or erase getting a hardfault
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-16 12:56 AM
Look at registers when it actually faults.
Make sure clocks for additional SRAM are enabled.
Check MPU configuration.​
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-16 2:32 AM
Thanku for the response,
[cid:image003.jpg@01D98807.6ED45CA0]
This is the Reg contents after I get an hard fault, clock is configured,
Now my que is the address what is for SRAM2 is 0X2000000 but here it shows 0X4000000 series, can you pls help with his.
