на главную | войти | регистрация | DMCA | контакты | справка | donate |      

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Э Ю Я


моя полка | жанры | рекомендуем | рейтинг книг | рейтинг авторов | впечатления | новое | форум | сборники | читалки | авторам | добавить



6.2.2.3 Device test

Once you know that the address and data bus wiring are correct, it is necessary to test the integrity of the memory device itself. The thing to test is that every bit in the device is capable of holding both and 1. This is a fairly straightforward test to implement, but it takes significantly longer to execute than the previous two.

For a complete device test, you must visit (write and verify) every memory location twice. You are free to choose any data value for the first pass, so long as you invert that value during the second. And because there is a possibility of missing memory chips, it is best to select a set of data that changes with (but is not equivalent to) the address. A simple example is an increment test.

The data values for the increment test are shown in the first two columns of Table 6-3. The third column shows the inverted data values used during the second pass of this test. The second pass represents a decrement test. There are many other possible choices of data, but the incrementing data pattern is adequate and easy to compute.


Table 6-3. Data Values for an Increment Test

Memory Offset Binary Value Inverted Value
000h 00000001 11111110
001h 00000010 11111101
002h 00000011 11111100
003h 00000100 11111011
0FEh 11111111 00000000
0FFh 00000000 11111111

The function memTestDevice implements just such a two-pass increment/decrement test. It accepts two parameters from the caller. The first parameter is the starting address, and the second is the number of bytes to be tested. These parameters give the user a maximum of control over which areas of memory will be overwritten. The function will return NULL on success. Otherwise, the first address that contains an incorrect data value is returned.

/**********************************************************************

*

* Function:    memTestDevice()

*

* Description: Test the integrity of a physical memory device by

*              performing an increment/decrement test over the

*              entire region.  In the process every storage bit

*              in the device is tested as a zero and a one.  The

*              base address and the size of the region are

*              selected by the caller.

*

* Notes:      

*

* Returns:     NULL if the test succeeds.  Also, in that case, the

*              entire memory region will be filled with zeros.

*

*              A nonzero result is the first address at which an

*              incorrect value was read back.  By examining the

*              contents of memory, it may be possible to gather

*              additional information about the problem.

*

**********************************************************************/

datum * memTestDevice(volatile datum * baseAddress, unsigned long nBytes) {

 unsigned long offset;

 unsigned long nWords = nBytes / sizeof(datum);

 datum pattern;

 datum antipattern;

 /*

 * Fill memory with a known pattern.

 */

 for (pattern = 1, offset = 0; offset < nWords; pattern++, offset++) {

  baseAddress[offset] = pattern;

 }

 /*

 * Check each location and invert it for the second pass.

 */

 for (pattern = 1, offset = 0; offset < nWords; pattern++, offset++) {

  if (baseAddress[offset] != pattern) {

   return ((datum *) &baseAddress[offset]);

  }

  antipattern = ~pattern;

  baseAddress[offset] = antipattern;

 }

 /*

 * Check each location for the inverted pattern and zero it.

 */

 for (pattern = 1, offset = 0; offset < nWords; pattern++, offset++) {

  antipattern = ~pattern;

  if (baseAddress[offset] != antipattern) {

   return ((datum *) &baseAddress[offset]);

  }

  baseAddress[offset] = 0;

 }

 return (NULL);

} /* memTestDevice() */


6.2.2.2 Address bus test | Programming Embedded Systems in C and C++ | 6.2.2.4 Putting it all together