Quantcast
Channel: Infineon Forums
Viewing all articles
Browse latest Browse all 9892

XMC 4500 - how to enter Hibernate mode?

$
0
0
Hi,

See an example below. You will see the HIB_IO_1 having a pulse of 5s, the duration of the hibernate.

Code:

#include <xmc_gpio.h>
#include <xmc_scu.h>
#include <xmc_rtc.h>

XMC_RTC_CONFIG_t rtc_config =
{
  .alarm.seconds = 5U,
  .prescaler = 0x7fffU
};

XMC_RTC_TIME_t rtc_time =
{
  .days = 0,
  .daysofweek = 0,
  .hours = 0,
  .minutes = 0,
  .month = 0,
  .seconds = 0,
  .year = 0
};

int main(void)
{
  XMC_SCU_HIB_EnableHibernateDomain();

  XMC_SCU_HIB_SetRtcClockSource(XMC_SCU_HIB_RTCCLKSRC_OSI);

  XMC_RTC_Init(&rtc_config);

  XMC_RTC_SetTime(&rtc_time);
  XMC_RTC_EnableHibernationWakeUp(XMC_RTC_WAKEUP_EVENT_ON_ALARM);

  XMC_SCU_HIB_ClearEventStatus(XMC_SCU_HIB_EVENT_WAKEUP_ON_RTC);
  XMC_SCU_HIB_EnableEvent(XMC_SCU_HIB_EVENT_WAKEUP_ON_RTC);

  XMC_SCU_HIB_SetPinOutputLevel(XMC_SCU_HIB_IO_1, XMC_SCU_HIB_IO_OUTPUT_LEVEL_LOW);
  XMC_SCU_HIB_SetPinMode(XMC_SCU_HIB_IO_1, XMC_SCU_HIB_PIN_MODE_OUTPUT_PUSH_PULL_HIBCTRL);

  XMC_SCU_RESET_ClearDeviceResetReason();
  XMC_SCU_HIB_ClearWakeupEventDetectionStatus();

  XMC_RTC_Start();

  XMC_SCU_HIB_EnterHibernateState();

  while(1U);
}


Viewing all articles
Browse latest Browse all 9892

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>