I am using STM32F105RC microcontroller on a custom designed board, the microcontroller runs at 72MHz, no crystal (& its decoupling caps) is connected for RTC, CR2032 3V battery is connected to Vbat directly (no other circuit like diode between Vbat & Vdd is present). I am using IAR embedded workbench.
The code is as follows:
/* Set the Vector Table base location at 0x20000000 */
#else /* VECT_TAB_FLASH */
/* Set the Vector Table base location at 0x08000000 */
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
/* if (BKP_ReadBackupRegister(BKP_DR1) != 0xA5A5)
if (BKP_ReadBackupRegister(BKP_DR1) == 0xA5A5)
I test it as follows:
When the commented code is uncommented (the code beginning with if (BKP_ReadBackupRegister(BKP_DR1) != 0xA5A5)), then program is compiled & run in debug mode, the LED connected to GPIO_Pin_0 glows. When the board is not powered off, code is commented again (as shown above) & code is run in debug mode, the LED still glows. But if the board is powered off & turned on again, the LED does not glow. It seems the backup registers are not working.
Can you please help me to solve this problem?
Thanks in advance!