Hi,
In this case, it seems that there are two things that could be changed in order to ensure the proper functionality of your test application.
The first one consists on the loop, which according with the ASM instructions, it decrements the R2 until zero for getting out of the “loop” and continuing the execution until the branch to the main, isn’t it? However, the “SUB” instruction has a missing operand, as the correct usage includes 3 operands (destination, source1, source2); seems it should be “SUB R2, R2, #1” (to decrement 1 from R2, and store the result on R2). This seems to be the cause why the application is blocked on the loop, and also may be the cause of the incorrect PC modifications, if the compiler “optimizes” the incorrect instruction, skipping it.
The second factor consists on using a reliable RAM, in order to verify that the memory will not be the issue, ensuring first that the code is right, and then testing the correct code on the implemented RAM.
Hope this will be useful for you.
Best regards!
/Carlos
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------