diff --git a/src/MFRC522.cpp b/src/MFRC522.cpp index ca1fc2d..b9b34d5 100644 --- a/src/MFRC522.cpp +++ b/src/MFRC522.cpp @@ -232,11 +232,11 @@ void MFRC522::PCD_Reset() { // The datasheet does not mention how long the SoftRest command takes to complete. // But the MFRC522 might have been in soft power-down mode (triggered by bit 4 of CommandReg) // Section 8.8.2 in the datasheet says the oscillator start-up time is the start up time of the crystal + 37,74μs. Let us be generous: 50ms. - delay(50); - // Wait for the PowerDown bit in CommandReg to be cleared - while (PCD_ReadRegister(CommandReg) & (1<<4)) { - // PCD still restarting - unlikely after waiting 50ms, but better safe than sorry. - } + uint8_t count = 0; + do { + // Wait for the PowerDown bit in CommandReg to be cleared (max 3x50ms) + delay(50); + } while ((PCD_ReadRegister(CommandReg) & (1 << 4)) && (++count) < 3); } // End PCD_Reset() /**