I am using CY62256 SRAM in my project. I use approx 30K of this 32K RAM for xdata. Upon system startup, RAM check is done by the following piece of code. Is it the right way to do, or more and more techniques have to be followed?
#define xbyte ((unsigned char volatile xdata*)0) unsigned char RAMCheck(void) { unsigned char i,j; unsigned int no; for(no=0;no<0x8000;no++) //check the RAM 0x8000 locations (0-32K) { i=xbyte[no]; xbyte[no]=0x55; //write 0x55 & read it & check whether correctly written j = xbyte[no]; if(j != 0x55) return 1; //if no then return 1 which will cause CPU to stop here and resets the controller xbyte[no]=0xaa; //similarly write 0xaa & check by reading it j = xbyte[no]; if(j != 0xaa) return 1; xbyte[no]=i; }//HERE, 1 IS RETURNED IF A SPECIFIED LOCATION FAILS TO READ THE VALUE WRITTEN }
kindly advise..
Simply writing a value and immediately reading it back can pass even with no RAM chips fitted! (capacitances can be sufficient that the signal levels remain on the bus wires)
You code does not check any other possible faults - such as addressing errors.
For a detailed discussion of the types of errors that commonly occur in memory systems, and how to test for them, search for the aticle "Software-Based Memory Testing" by Michael Barr:
www.embedded.com/.../master.htm
Excellent link! Thank you!
have YOU got the file?
i can not get it :(