Skip to main content
Pavel A.
Oct 2, 2019 11:50 PM UTC
Solved

STM32H753 eval board. Cannot write to backup RAM

I call HAL_PWR_EnableBkUpAccess() but writes to backup RAM (4K in battery backed domain) won't stick. Data always remains 0. No error or fault on write.

What else can be missing??

RTC backup registers write test on same board is successful (means, tamper not active).

But what is notable, it is successfull even without enabling backup domain access! (HAL_PWR_EnableBkUpAccess)

The board is STM32H753 Eval-2.

Attached is example project for Atollic. Anyone wants to look?

Regards,

-- pa

This topic has been closed for replies.
waclawek.jan
waclawek.janBest answer
Super User
Oct 3, 2019 6:56 AM UTC

PWR and BKPRAM clocks are enabled in RCC?

I don't Cube nor 'H7.

JW

3 replies

Pavel A.
Pavel A.Author
Oct 3, 2019 12:00 AM UTC

This is the code basically.

#define BACKUP_RAM_BASE 0x38800000 // from RM
 
struct BK_test_s {
	uint16_t x1;
	uint16_t x2;
	uint32_t w1;
};
 
void batt_ram_test(void)
{
	__HAL_RCC_BACKUPRESET_RELEASE();
	__DSB();
	__DMB();
 __HAL_RCC_BKPRAM_CLK_ENABLE(); /**** this was missing ***/
	HAL_PWR_EnableBkUpAccess();
	__DSB();
 
	volatile struct BK_test_s *bp = (struct BK_test_s *)(BACKUP_RAM_BASE + 32); 
	bp->x1 = 0x42;
	bp->w1 = 0xAABBCCDD;
	__DSB();
	__DMB();
 while (bp->x1 != 0x42) {}
	printf("Backup memory checked\n"); // NEVER REACHED
}

waclawek.jan
waclawek.janBest answer
Super User
Oct 3, 2019 6:56 AM UTC

PWR and BKPRAM clocks are enabled in RCC?

I don't Cube nor 'H7.

JW

Pavel A.
Pavel A.Author
Oct 3, 2019 8:39 PM UTC

Yep. It was clock in RCC. Thank you Jan.

__HAL_RCC_BKPRAM_CLK_ENABLE() was missing.

> I don't Cube nor 'H7

And hate Eclipse :)

Interesting, the backup domain access is enabled after reset.

Check for the PWR bit set by HAL_PWR_EnableBkUpAccess shows it is already set.

If this isn't artifact of the debugger, this contradicts the manual.

-- pa