unsigned int i = 0;
unsigned char second[];
unsigned char minute[];
unsigned char hour[];
unsigned char day;
unsigned char date[];
unsigned char month[];
unsigned char year[];

void GetTime(void)
{
  U0CTL &= ~I2CEN;                                  // Disable the I2C module (Recommended I2C init procedure)
  I2CNDAT = 0x01;                                   // Write 1 byte (byte = 8 bits)
  U0CTL |= I2CEN;                                   // Enable I2C using a 7-bit address
  while ((I2CDCTL & I2CBUSY) == I2CBUSY)            // If I2C is still busy do nothing
  {
  }
  I2CIFG &= ~TXRDYIFG;
  U0CTL |= MST;                                 // Master mode
  I2CIFG &= ~ARDYIFG;                           // Reset ARDYIFG bit
  I2CTCTL |= I2CTRX + I2CSTT + I2CSTP;          // Transmit, ST, SP (clears MST)
  while ((I2CIFG & ARDYIFG) != ARDYIFG)         // Check if all data has been sent
  {
    while (( I2CIFG & TXRDYIFG) != TXRDYIFG)      // Do nothing if I2C is not ready to transmit data
    {
    }
    I2CDRB = 0x00;                                // Reset register pointer to read seconds first
    I2CIFG |= ARDYIFG;                            // All data has been read
  }
  while ((I2CDCTL & I2CBUSY) == I2CBUSY)          // If I2C is still busy do nothing
  {
  }
  while ( i < 7)
  {
    I2CIFG &= ~ARDYIFG;                           // Reset ARDYIFG bit
    I2CTCTL &= ~I2CTRX;                           // Reset I2CTRX bit
    U0CTL |= MST;                                 // Master mode
    I2CTCTL |= I2CSTT + I2CSTP;                   // Read, ST, SP (clears MST)
    while ((I2CIFG & ARDYIFG) != ARDYIFG)         // Check if all data has been read
    {
      while (( I2CIFG & RXRDYIFG) != RXRDYIFG)      // Do nothing if I2C is not ready to read data
      {
      }
      switch (i)
      {
	case 0:
	  second[] = I2CDRB;
          I2CIFG |= ARDYIFG;
	  break;
	case 1:
	  minute[] = I2CDRB;
          I2CIFG |= ARDYIFG;
	  break;
	case 2:
	  hour[] = I2CDRB;
          I2CIFG |= ARDYIFG;
	  break;
	case 3:
	  day = I2CDRB;
          I2CIFG |= ARDYIFG;
	  break;
	case 4:
	  date[] = I2CDRB;
          I2CIFG |= ARDYIFG;
	  break;
	case 5:
	  month[] = I2CDRB;
          I2CIFG |= ARDYIFG;
	  break;
	case 6:
	  year[] = I2CDRB;
          I2CIFG |= ARDYIFG;
	  break;
      }
      i++;
    }
  }
  i = 0;
}