Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/19/03 18:08
Read: times


 
#48847 - RE: command interpreter - write to RAM space
Responding to: ???'s previous message

Take a trip to the Embedded Systems Academy ,
they have the memtestlib.zip by Michael Barr that has been ported to the 8051...


/**********************************************************************
*
* 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 non-zero 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 xdata *memTestDevice(volatile datum xdata * 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 xdata *) &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 xdata *) &baseAddress[offset]);
}

baseAddress[offset] = 0;
}

return (NULL);

} /* memTestDevice() */

/**********************************************************************
*
* Function: memTest()
*
* Description: Test an 8-k chunk of RAM.
*
* Notes:
*
* Returns: 0 on success.
* Otherwise -1 indicates failure.
*
**********************************************************************/
int memTest(void)
{
#define BASE_ADDRESS (volatile datum xdata *) 0x00000000
#define NUM_BYTES 8 * 1024

if ((memTestDataBus(BASE_ADDRESS) != 0) ||
(memTestAddressBus(BASE_ADDRESS, NUM_BYTES) != NULL) ||
(memTestDevice(BASE_ADDRESS, NUM_BYTES) != NULL))
{
return (-1);
}
else
{
return (0);
}

List of 8 messages in thread
TopicAuthorDate
command interpreter - write to RAM space            01/01/70 00:00      
   RE: command interpreter - write to RAM space            01/01/70 00:00      
   RE: command interpreter - write to RAM space            01/01/70 00:00      
      RE: command interpreter - write to RAM space            01/01/70 00:00      
         RE: command interpreter - write to RAM space            01/01/70 00:00      
            RE: command interpreter - write to RAM space            01/01/70 00:00      
               RE: command interpreter - write to RAM space            01/01/70 00:00      
                  RE: command interpreter - write to RAM space            01/01/70 00:00      

Back to Subject List