/* Startup routine for 32kHz Cristal on LFXT1 with timeout counter  */
uint16_t LFXT_Start_Timeout(uint16_t xtdrive, uint16_t timeout)
/* Startup routine for 32kHz Cristal on LFXT1 with timeout counter  */
uint16_t LFXT_Start_Timeout(uint16_t xtdrive, uint16_t timeout)
{
  UCSCTL6_L |= XT1DRIVE1_L+XT1DRIVE0_L;
  while ((SFRIFG1 & OFIFG) && timeout--){
    UCSCTL7 &= ~(DCOFFG+XT1LFOFFG+XT1HFOFFG+XT2OFFG);
    SFRIFG1 &= ~OFIFG;
  }
  UCSCTL6 = (UCSCTL6 & ~(XT1DRIVE_3)) |(xtdrive);
  if (timeout)
    return (UCS_STATUS_OK);
  else
    return (UCS_STATUS_ERROR);
}