I plug in a program that checks a set of wires for open or short circuits. A program that runs on AVR controls the test vector (walking "1") on the wires and returns the result back. It compares this resulting vector with the expected data that is already stored on the SD card or external EEPROM.
Here is an example, suppose we have a set of 8 wires, all of which are straight, i.e. do not have transitions. Therefore, if we drive 0b00000010, we should get 0b00000010.
Suppose we get 0b11000010. This implies a short circuit between wire 7.8 and wire 2. I can detect which bits interest me 0b00000010 ^ 0b11000010 = 0b11000000. This tells me that it is clear that wires 7 and 8 are at fault, but how can I find the position of these β1sβ effectively in a large bitmap. It is easy to do this in just 8 wires using bit masks, but the system I am developing should process up to 300 wires (bits). Before I started using macros, as shown below, and tested every bit in an array of 300 * 300 bits, I wanted to ask here if there was a more elegant solution.
Just to show how to detect an open circuit. Expected data: 0b00000010, received data: 0b00000000 (the wire does not pull high). 0b00000010 ^ 0b00000000 = 0b0b00000010 - wire 2 is open.
. , 300 - , RAM AVR Mega 1281, , .. 50 , , , .