Creating Fault on Active TWI Bus and Recording its behavior
Figure-1: TWi Bus connection between UNO and 24C512 EEPROM with control on Vcc
Register level programming allows us to have access to bit value; therefore, we can control the operation of the TWI Bus in a way we want having maintained full compliance with the data sheets.
Fault is created in an active (operational) TWI Bus by removing Vcc supply from the EEPROM. In Fig-1, we have placed Q1 and Q2 which work as switch to cut-off Vcc supply of the EEPROM.
The TWI Logic is a programmable State Machine, and it generates sequencing timing functions as per instructions given by the user (attached file: multibyteRW-1.ino). The program instructions are cooked by the user to see result what he has wanted before. For example: After reading two byte data from the EEPROM, the user has removed the power (creating a fault) from EEPROM (digitalWrite(12, LOW)) at the beginning of the 3rd Transmission. The user knows that the EEPROM is dead now, and there is no need for the Master to communicate with the EEPROM. The usr has simply made a return to the Control Program (the Operating System). So, what is the achievement of this Experimental Setup? Not much except of enjoying the ego that the idea could be tried!
Searching for Wire.requestFrom() behavior under fault condition
Hardwsre Setup: Figure-1
Program: attached file: multibyteRW-2 (Functional at TWI Speed: 2 Hz to 200 KHz)
clkSYS = 62500 Hz
TWI Bus Speed =~ 2Hz
Execution Time of byte n = Wire.requestFrom(deviceaddress, 7); =~ 30 sec (manual counting)
Fault Simulation: Manual asynchronous removal of the Vcc supply from EEPROM.
1. At the beginning of the execution of requestFrom(), the built-in LED (L) becomes ON.
2. After 10-12 seconds, fault is created with the EEPROM by switching off its Vcc supply (manually).
3. The requestFrom() falls in an infinite loop. (Thanks to Watchdog Timer which will bring the MCU out-of-infinite loop in the field applications.)
4. Vcc is connected back. The requestFrom() comes out-of-loop and switches off L.
5. Both requestFrom() and available() return 7; but the received data are close to garbage except few bytes at the beginning!
Many many thanks to pylon and others whose interest and guidance have encouraged me to carry out this experiment.
multibyteRW-1.ino (7.82 KB)
multibyteRW-2.ino (2.79 KB)