STM32 RTC alarm not configuring for the second time
We faced the same problem while working with RTC on my STM32F030 Controller.
Our alarm interrupt triggered once, but it would never trigger again.

The problem was as follows:


We needed to put the system in low power mode when not in use
To enable the low power mode, we had to call this function
RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE);
This function prevents write access to the DBP bit of register
PWR_CR and it makes DBP bit = 0. This bit must be set before we can
change any values of RTC registers (as mentioned in reference
manual)


Reference manual RM0360 for STM32F030 and STM32F070 states that:


  After system reset, the RTC registers are protected against
  parasitic write access by clearing the DBP bit in the PWR_CR register
  (refer to the power control section). DBP bit must be set in order to
  enable RTC registers write access. After RTC domain reset, all the RTC
  registers are write-protected. Writing to the RTC registers is enabled
  by writing a key into the Write Protection register, RTC_WPR. The
  following steps are required to unlock the write protection on all the
  RTC registers except for RTC_TAFCR and RTC_ISR[13:8].
  
  
  Write ‘0xCA’ into the RTC_WPR register.
  Write ‘0x53’ into the RTC_WPR register. 
  Writing a wrong key reactivates the write protection. The protection mechanism is not
  affected by system reset.
  


We solved the problem by making following changes to the IRQ handler of RTC:

void RTC_IRQHandler(void)
{
   /*  Check line 17 has triggered the IT */
   if ((EXTI-&gt;PR &amp; 0x20000) != 0)  
   {  
      /* Makes the DBP bit of PWR_CR register write accessible */
      RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, DISABLE);

      /* Writes 1 in the DBP bit of PWR_CR register */
      PWR_BackupAccessCmd(ENABLE);



      /* Your code here ... */


      /* RTC registers are made write accessible */
      RTC_WriteProtectionCmd(DISABLE);

      /* Clear the RTC Alarm-A Flag */
      RTC_ClearFlag(RTC_FLAG_ALRAF);


      /* Makes the RTC registers read only */
      RTC_WriteProtectionCmd(ENABLE);

      /* Locks the DBP bit of PWR_CR register again */
      RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE);

      /* Clear the EXTI Line 17 Pending bit (Connected internally to RTC Alarm) */
      EXTI-&gt;PR |= 0x20000;
  }
}