/* is used to stop code execution for specified time  */
void GUI_X_Delay(int ms)
/* is used to stop code execution for specified time  */
void GUI_X_Delay(int ms)
{
  uint32_t rtc_counter;
  rtc_counter = RTC_CounterGet();
  _checkForAEM();
  _serveJoystick();
  RTC_IntClear(RTC_IF_COMP0);
  rtcFlag = true;
  RTC_CompareSet(0, (rtc_counter + ((RTC_FREQ * ms ) / 1000))& _RTC_COMP0_COMP0_MASK);
  RTC_Enable(true);
  RTC_IntEnable(RTC_IF_COMP0);
  if( (RTC_CompareGet(0)<= RTC_CounterGet()) ||
      (RTC_CompareGet(0) > (RTC_CounterGet()+RTC_FREQ*10)) )
    rtcFlag = false;
  while (rtcFlag)
  {
     EMU_EnterEM2(true);
  }
}