Tool/software:
In the code line below, I can read the DS1307 time chip without any problems, but in case of any hangup or sudden processor reset, while (DL_I2C_isControllerRXFIFOEmpty(I2C_INST)); It is waiting within the function, which stops my system. In this case, what software scenario would you recommend?
uint8_t readDS1307Register(uint8_t regAddr) { uint8_t data; DL_I2C_fillControllerTXFIFO(I2C_INST, ®Addr, 1); /* 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, DS1307_ADDRESS, DL_I2C_CONTROLLER_DIRECTION_TX, 1); /* 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(100); /* Send a read request to Target */ DL_I2C_startControllerTransfer(I2C_INST, DS1307_ADDRESS, DL_I2C_CONTROLLER_DIRECTION_RX, 1); while (DL_I2C_isControllerRXFIFOEmpty(I2C_INST)); data = DL_I2C_receiveControllerData(I2C_INST); if (DL_I2C_getControllerStatus(I2C_INST) & DL_I2C_CONTROLLER_STATUS_ERROR) { printf("I2C Okuma Hatasi!\n"); } return bcdToDec(data); }