We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am writing an assembly FIQ ISR using GCC complier. I want to change return address in FIQ ISR so that after ISR, it returns to the requested address. the reason for doing that is because i am writing a RTOS.
what are the instruction for ISR return in assembly? is it
SUBS PC, R14, #4
? i know in 8051, noraml function call return is RET, ISR return is RETI.
Look at the assembler output of the compiler to see what instructions that are used by fast and normal interrupt handlers.
Remember that a RTOS doesn't just switch return address - you have to switch to a different stack and make sure that all registers (and other important thread states) gets restored to the values of the other task. That can be quite a lot of hard work, if you are not familiar with the processor instructions.
Sure, that will cause a return from an FIQ ISR.
Does it mean when use
sub PC, R14, #4
, it will return to the interrupted task, and CPSR resumes from SPSR_fiq automatically? Is it the only way for CPSR to resume from SPSR_fiq automatically?
will cause CPSR to be replaced by SPSR_FIQ
SUB PC, R14, #4
will cause CPSR to remain the same (not be replaced by SPSR_IRQ)
an LDM instruction that references the PC will cause CPSR to be replaced by SPSR_FIQ.
If you are doing a task switch, you definately want to set the CPSR to the correct value, and not what it currently is in the FIQ routine (this usually means that you will need to put into SPSR_FIQ the value that you would like CPSR to be after the return).
thanks, Robert.
You mean if it is
LDMFD R13!, {R0-R7,R14}
the CPSR will remain the same.
But if it is:
LDMFD R13!, {R0-R7,PC}
the CPSR will replaced by SPSR_IRQ.
I have tried the second one, CPSR still remains the same, still in FIQ mode.
Change
to
LDMFD R13!, {R0-R7,PC}^