Reputation: 2092
I have an 8051 microcontroller with external ram attached to it and I want to test the ram to see that it can store and load data correctly (which I think it currently does not).
In my program, I have it where the value 80h is written to 1st byte of memory and the value increments as each memory address is incremented but the value rolls over to zero every 256 bytes starting with the 128th byte.
This is my function:
;extended memory test. C=1=memory fault
memtest:
mov DPTR,#0h
mov R7,#80h
;fill with incrementing values
post1:
mov A,R7
movx @DPTR,A
inc R7
inc DPTR
mov A,DPH
orl A,DPL
jnz post1
;Test for incrementing values
mov DPTR,#0h
mov R7,#80h
post2:
clr C
movx A,@DPTR
subb A,R7
setb C
jnz isbadram
movx @DPTR,A
mov A,R7
inc R7
inc DPTR
mov A,DPH
orl A,DPL
clr C
jnz post2
isbadram:
ret
But I think I need to do more of a rigorous test. I think I need to write and read different values multiple times to the same locations but I don't know how many times to test a location and I don't know the best values to try.
I'm just afraid if I test a location too many times, then my program will spend forever testing memory before it begins doing anything useful.
Luckily I own some microcontrollers that can execute instructions at about 40nS each. I have others of the same family that execute instructions at about 0.5uS each.
So whats the best way to test a ram chip already installed in the system without spending too much time on the testing?
Upvotes: 3
Views: 1087
Reputation: 12610
The number of repetitions of a RAM test depends on what you like to check and when in the life cycle of your product you check.
If you're checking the output of the production line, you could repeat the test "for ever" to check under different environment conditions like temperature. But one run should suffice for most cases.
If you want to test one specific board, you could also test "for ever" until you switch off. This is helpful to probe the wiring with an oscilloscope, too.
If you want to test in the field while running the application software, you can use a high priorised timer interrupt to test one byte at a time. This runs "for ever", too, of course. And make sure that your test restores the old value.
But first you have to decide what kind of errors you are looking for:
For the first kind I would test like this:
If a check fails, you could abort the test loop and report the error. The tested data bit or address bit gives some hint for the actual error. If you like to probe the wiring, just report and keep going.
This is really fast and reveals many permanent errors. For transient errors you need to repeat the test.
For the second kind you need more sophisticated tests. Some of these depend on the real physical organization in the RAM, concerning rows and columns of bits. You might like to search the web for "factory RAM tests" like "galloping patterns" ("galpat").
Unfortunately these tests take a long time, as you noticed. But I'm afraid that there is no way around.
A very simple test will write a sequence of pseudo-random numbers into the RAM and then check the sequence. Make sure that your number generator produces a period at least as long as the size of the RAM, for example by using a number wide enough. You will use just the lower 8 bits of it, however. You could use a LFSR.
Upvotes: 1