cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743-EVAL2, why battery-backed RAM doesn't hold data?

Pavel A.
Evangelist III

I start from any simple Cube example, such as UART_Printf,

enable access to the backup RAM and write some data.

After reset by the reset button or NVIC_System_Reset data in the backup RAM is retained.

But after powering off the data is lost.

Do I miss some configuration steps to make the backup domain use the battery? Any jumper?

The battery ML1220 voltage is 2.75V when the board is disconnected from power.

Is this too low voltage? Googling shows that minimal voltage can be as low as 2.5V.

Apologize for a silly question but I cannot find solution in the board manual.

-- pa

1 ACCEPTED SOLUTION

Accepted Solutions

Do you have PWR_CR2.BREN set?

JW

View solution in original post

6 REPLIES 6
Uwe Bonnes
Principal II

Carefully check how the mackup RAM is handled in the bootup process. Perhaps it is initialized during bootup. How is BKUP RAM listed in the linker?

Hi @Uwe Bonnes​ thank you for the reply.

My init code does not change the data if it sees a "magic" already written.

Since a pin reset (EVB reset button) does not disturb the data when a power supply is connected, I think my init code is ok.

> How is BKUP RAM listed in the linker?

Not listed at all, accessed thru a pointer.

Here is the code to enable access:

void unlock_bkp_RAM(void)
{
    __HAL_RCC_BKPRAM_CLK_ENABLE();
    __DSB();
   bool y =  READ_BIT(PWR->CR1, PWR_CR1_DBP) == (PWR_CR1_DBP);
    if (!y)    {
      HAL_PWR_EnableBkUpAccess();
      __DSB();
    }
}

#define BACKUP_RAM_BASE 0x38800000 
 
bool open_backup_store(void)
{
    unlock_bkp_RAM();
    struct my_backup_struct *ps = (struct my_backup_struct*) ((uintptr_t)BACKUP_RAM_BASE);
    if (ps->magic != MY_MAGIC) {
        printf("backup magic bad\n");
        goto reinit;
    }
    return true;
   reinit:
   .......................
}

-- pa

Do you have PWR_CR2.BREN set?

JW

Jan,

No, PWR_CR2.BREN was not set.

Now I'm playing with it and don't understand what goes on there.

  • After POR reset, I set CR1.DBP and CR2.BREN and also CR3.VBE to charge the battery.

CR2.BRRDY becomes 1.

Write data to the backup RAM.

  • Then do NVIC_System_Reset or press the black reset button:

CR2 = 00010001 (BREN, BRRDY); CR3 = 00000142 (LDOEN, some reserved bit, VBE).

Data in backup RAM is present.

  • Then do power cycle.

RCC->RSR = 00FE0000: POR set

Set PWR->CR1.DBP and... CR2=00000000 CR3=00000042

So these bits do not survive power cycle.... what's the point to set them? What else is missing?

--pa

Pavel,

I'd recommend you to get rid of Cube and at least for the experiments, use bare register access, where you know exactly what are you doing.

Other than that, check if VBAT has always voltage within the bounds. Start with a true non-rechargeable battery (a CR2032 perhaps), without attempting to recharge it.

JW

Thanks Jan,

With PWR_CR2.BREN set the backup memory keeps the data.

It was a silly mistake on my part ((

Overlooked a jumper on the eval. board that connects the battery (JP11).

OTOH now I know to tell if the jumper is put and the battery installed, so can give a helpful message to the user.

Thanks,

-- pa