As far as location of the code is concerned ideally you should run the code from FLASH memory as you are going to test the RAM itself. This can be achieved with the help of linker scripts. unfortunately exact method is different across different compilers.