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.

[参考译文] MSPM0G1106:ds1307 Rx 错误

Guru**** 1788580 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1403022/mspm0g1106-ds1307-rx-error

器件型号:MSPM0G1106

工具与软件:

当我使用德州处理器更改了 DS1307数据并使用 Arduino 进行了检查时、我​​向正确的寄存器分配了正确的值。 但当我想在德克萨斯学习时,我遇到了下图。

uint8_t readSecondsFromDS1307 (void){
 uint8_t 秒;
  uint8_t regAddr =秒;

// DS137den saniye register'ının ó n adresini gönder ñ o.
DL_I2C_fillControllerTXFIFO (I2C_INST、&regAddr、1);

while (! (DL_I2C_getControllerStatus (I2C_INST)和 DL_I2C_CONTROLLER_STATUS_IDLE);

// 1 baytlık veri (Saniyeler) okumak için kontrolcü transferini başlat
DL_I2C_startControllerTransfer (I2C_INST、DS1307_ADDRESS、DL_I2C_CONTROLLER_DIRECTION_RX、1);


// Veri FIFo'ya gelene kadar bekle ve Oku
while (DL_I2C_isControllerRXFIFOEMpty (I2C_INST));
秒= DL_I2C_receiveControllerData (I2C_INST);


if (DL_I2C_getControllerStatus (I2C_INST)和 DL_I2C_CONTROLLER_STATUS_ERROR){
printf ("I2C Okuma Hatası!\n");
}

// Okunan saniyeleri Bcd'den çevir formata ondalık ve döndür
//返回 bcdToDec (秒);
返回秒数;
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您为什么要开始一个新主题?

    您必须告诉 DS1307要读取的寄存器。 fillControllerTXFIFO 不发送任何字节。 以下是 TI 示例中的相关代码:

    /*
         * Fill FIFO with data. This example will send a MAX of 8 bytes since it
         * doesn't handle the case where FIFO is full
         */
        DL_I2C_fillControllerTXFIFO(I2C_INST, &gTxPacket[0], I2C_TX_PACKET_SIZE);
    
        /* Wait for I2C to be Idle */
        while (!(
            DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_IDLE))
            ;
    
        /* Send the packet to the controller.
         * This function will send Start + Stop automatically.
         */
        DL_I2C_startControllerTransfer(I2C_INST, I2C_TARGET_ADDRESS,
            DL_I2C_CONTROLLER_DIRECTION_TX, I2C_TX_PACKET_SIZE);
            
        /* Trap if there was an error */
        if (DL_I2C_getControllerStatus(I2C_INST) &
            DL_I2C_CONTROLLER_STATUS_ERROR) {
            /* LED will remain high if there is an error */
            __BKPT(0);
        }
    
        /* Wait for I2C to be Idle */
        while (!(
            DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_IDLE))
            ;
    
        /* Add delay between transfers */
        delay_cycles(1000);
    
        /* Send a read request to Target */
        DL_I2C_startControllerTransfer(I2C_INST, I2C_TARGET_ADDRESS,
            DL_I2C_CONTROLLER_DIRECTION_RX, I2C_RX_PACKET_SIZE);

    此外、确保屏蔽掉 CH 位。