Code gets stuck after enableInterrupts() and it does not function as per the logic.
#include "stm8l15x.h"
#include "stm8l15x_gpio.h"
#include "stm8l15x_exti.h"
#include "stm8l15x_rtc.h"
#include "stm8l15x_itc.h"
#include "stm8l15x_clk.h"
#define WAKEUP_GPIO_PORT GPIOE
#define WAKEUP_GPIO_PORT GPIOE
#define ICC_WAKEUP_GPIO_PIN GPIO_Pin_6
static void RTC_Config(void)
{
/* Configures the RTC */
CLK_RTCClockConfig(CLK_RTCCLKSource_LSE, CLK_RTCCLKDiv_1);
CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);
RTC_WakeUpClockConfig(RTC_WakeUpClock_CK_SPRE_16bits);
RTC_ITConfig(RTC_IT_WUT, ENABLE);
/* Enable Interrupts*/
}
void Delay(__IO uint32_t nCount)
{
for (; nCount != 0; nCount--);
}
void main(void)
{
GPIO_Init(GPIOC, GPIO_Pin_7, GPIO_Mode_Out_PP_Low_Slow);
GPIO_Init( WAKEUP_GPIO_PORT, ICC_WAKEUP_GPIO_PIN, GPIO_Mode_In_FL_IT);
/* Enable Rising edge port PE6 for wake up conter */
EXTI->CR2 = 0x10;
/* RTC configuration -------------------------------------------*/
RTC_Config();
enableInterrupts();
/* Infinite loop */
while (1)
{
GPIO_SetBits(GPIOC, GPIO_Pin_7);
//Delay(0xFFFF);
/* RTC will wake-up from halt every 5second */
RTC_SetWakeUpCounter(5);
RTC_WakeUpCmd(ENABLE);
/* Enter Wait for interrupt mode*/
wfi();
GPIO_ResetBits(GPIOC, GPIO_Pin_7);
Delay(60000);
RTC_WakeUpCmd(DISABLE);
}
}
