跳转到主内容
Knowledgebase
Home
Renesas Electronics China - Knowledgebase

What happens if USP is designated as the stack pointer in user mode?

Latest Updated:06/20/2013

Question:

I wish to designate the USP as the stack pointer in user mode. Are there any problems associated with doing this, and is there anything I need to be careful of?

Answer:

If the program is for generating interrupts, in addition to setting the USP register you also need to set the ISP register before an exception occurs.
When an exception occurs, the processor will automatically switch to supervisor mode (PM bit in PSW register = 0). In addition, while the exception handler is executing, the ISP is automatically designated as the stack pointer (U bit in PSW register = 0). This is why, for interrupt programs, you should make initial settings for the ISP register before an exception occurs.
Note that if the processor is in user mode prior to receiving the exception, after returning from the exception the PM bit of the PSW register will be automatically set to 1. The U bit of the PSW register will also automatically be set to 1 (USP designated).
For more information on the stack pointer designation bits (U) of the ISP, USP, and PSW registers, please refer to the "Register Set" section in the "CPU" chapter of the hardware manual.
For more information on processor modes, please refer to the "Processor Mode" section in the "CPU” chapter of the hardware manual.
For more information on exception sequences, please refer to the "Exceptions" chapter of the hardware manual."
Suitable Products
RX62N, RX621
RX62T
RX610
RX62G
RX630
RX63N, RX631
RX63T
RX210
RX220
RX110
RX111