This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PCF2123实时时钟

Other Parts Discussed in Thread: MSP430FR5723

用的是MSP430FR5723的硬件SP1口与PCF2123实时时钟芯片通信,现在问题是读不出时间,不知道在哪出来问题。
SP1主要通信如下:unsigned char SPITransfer(unsigned char aout)
{
    unsigned char data1;
    while (!(UCB0IFG&UCTXIFG));
    UCB0TXBUF=aout;
    while (!(UCB0IFG&UCRXIFG));
    data1= UCB0RXBUF;
    return(data1);
}
unsigned char RTCReadReg(unsigned char aReg)
{
    unsigned char result;
    P2OUT |=  BIT4;                           //ce=1;
    SPITransfer(aReg|0x90);                  //读数据指令
    result=SPITransfer(0xff);               //度一字节返回数据
    P2OUT &=  ~BIT4;                       //ce=0;
    return(result);
}
void RTCWriteReg(unsigned char aReg,unsigned char aValue)
{
    P2OUT |=  BIT4;              //ce=1;
    SPITransfer(aReg|0x10);     //写指令
    SPITransfer(aValue);   
    P2OUT &=  ~BIT4;            //ce=0;
}

时钟配置:
void RTCConfigure()
{           
    RTCWriteReg(0x00,0x00);
    RTCWriteReg(0x01,0x00);

    RTCWriteReg(0x02,0x04);
    RTCWriteReg(0x04,0x02);
    RTCWriteReg(0x03,0x03);


    RTCWriteReg(0x07,0x01);
    RTCWriteReg(0x05,0x01);
    RTCWriteReg(0x08,0x00);
   // RTCWriteReg(0x00,0x00);
}


int main(void)
{

  WDTCTL = WDTPW + WDTHOLD;                          // Stop watchdog timer to prevent time out reset
  sys_clock();
  GPIO_Init();
  SPI_Init();
  RTCConfigure();

//__enable_interrupt() ;
  while(1)
  {
    sec=RTCReadReg(0x02);
    min=RTCReadReg(0x03);
    hou=RTCReadReg(0x04);
    day=RTCReadReg(0x05);
    mon=RTCReadReg(0x07);
    year=RTCReadReg(0x08);

   }