This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SRAM Test

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..

0