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

How to execute a memory test?

Hi,

I'm using the STM32F103ZE uC developping in C and asked to implement a full internal ram memory test.
The memory runs from address 0x2000 0000 up to 0x2000 FFFF.

When main() is started allready the stackpointer and data are initialized so some memory locations are occupied.

Just my thoughts: I could create some assembler function that checks/writes/reads the non occupied free memory, then copy the occupied memory to the allready tested free memory, then test the occupied memory, then restore the occupied memory from the free memory.

Is there some other way to test the memory before the uC initializes the memory?

Thanks

Henk

  • > Is there some other way to test the memory before the uC initializes the memory?

    Execute the test within the reset handler, after initializing memory controllers and before branching to __main(). Since you don't use memory at this point, it is possible to use destructive tests which makes the process a lot faster. What type of errors are you looking for specifically? For a catch-all kind of thing I recommend googling "cocktail march" or "marchcw" tests.

    --
    Marcus
    http://www.doulos.com/arm/

  • Hi,

    I think executing the memory test in the reset handler would be a good idea.

    My first concern is not what type of memory test pattern to use but how to implement the memory test in my C application.

    Let me think:
    I like to write the memory test in C but C uses variables so the test will destroy itself unless I can instruct C to only use registers for variables but I don't know if or how that's possible. If not, I have to write the memory test in assembler, but then I don't know how to pass the test result to the application, maybe I can use some unused interrupt handlers for it?

    Just let me know what thoughts of mine are correct or incorrect...

    Thanks

    Henk

  • > I like to write the memory test in C but C uses variables so the test will destroy
    > itself unless I can instruct C to only use registers for variables but I don't know
    > if or how that's possible.

    Memory tests are rather simple, so the C compiler should be able to allocate register for all local variables, but of course there is no guarantee. Why don't you give it a try?

    > If not, I have to write the memory test in assembler, but then I don't know how to
    > pass the test result to the application, maybe I can use some unused interrupt
    > handlers for it?

    Look up "embedded assembler" in the documentation. BTW, the return value ends up in register r0.
    I don't know how any of this is related to an interrupt handler, though. Just write a function and call it from within the reset handler.

    --
    Marcus