Exception interrupt returns EXC_RETURN in Cortex-M3

Publisher:chwwdchLatest update time:2022-04-24 Source: eefocusKeywords:Cortex-M3 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

After entering the exception service routine, the hardware automatically updates the value of LR to the special EXC_RETURN.

When the program returns from the exception service routine and sends the EXC_RETURN value to the PC, the processor's exception interrupt return sequence is started.

Because the value of LR, EXC_RETURN, is automatically set by the hardware, do not change it unless there is a special requirement.

The upper 28 bits of RETURN are all 1, and only the value of bit[3:0] has a special meaning. The bit segment is as follows:


There are three legal EXC_RETURN values, as follows:


If the main program is running in thread mode and is interrupted while using MSP, LR=0xFFFFFFF9 in the service program (LR was automatically pushed onto the stack before the main program was interrupted).

If the main program is running in thread mode and is interrupted while using the PSP, LR=0xFFFFFFFD in the service program (LR was automatically pushed onto the stack before the main program was interrupted).

If the main program runs in Handler mode, LR=0xFFFFFFF1 in the service program (LR is automatically pushed into the stack before the main program is interrupted). This is the so-called "main program", which is more likely to be the interrupt service program that is preempted. In fact, when nested, the LR seen by the deeper ISR is always 0xFFFFFFF1.

[The value of LR is set to EXC_RETURN during an exception (thread mode uses the main stack)]


[The value of LR is set to EXC_RETURN during an exception (thread mode uses the process stack)]


【Notice】


The value of LR is automatically set by the CPU when entering an interrupt, so there is no mistake. Why is it possible that the value of LR becomes illegal when exiting an interrupt? There is only one reason: the interrupt routine modifies the value of LR and makes a wrong change.

From the format of EXC_RETURN, we can see that we cannot use the address between 0xFFFFFFF0 and 0xFFFFFFFF as any return address. In fact, there is no need to worry about making a mistake, because Cortex-M3 has marked this range as "instruction fetching unavailable area".

Keywords:Cortex-M3 Reference address:Exception interrupt returns EXC_RETURN in Cortex-M3

Previous article:TQ2440 Study Notes - 2. Network settings for pinging between Win7PC and virtual machine Ubuntu
Next article:TQ2440 Study Notes —— 1. Development tool installation and environment establishment under Windows platform

Recommended ReadingLatest update time:2024-11-16 21:40

Causes and solutions for Flash download failed-Cortex-M3
First of all, this type of error is basically encountered by STM32 chips, and basically all of them use the JLINK emulator. In fact, the following methods may not necessarily help you solve the problem. We have not disclosed the real cause of the problem in this post. If you need to solve it, please contact the JLI
[Microcontroller]
Causes and solutions for Flash download failed-Cortex-M3
Transplantation of μCOS-II on ARM Cortex-M3 Processor
0 Introduction Embedded systems have been widely infiltrated into various fields of people's work and life. Embedded processors have accounted for 94% of the market share of decentralized processors, among which ARM is the most widely used. Processors based on ARM cores have become one of the most widely used pr
[Microcontroller]
Transplantation of μCOS-II on ARM Cortex-M3 Processor
Several important block diagrams of Cortex-M3
Cortex-M3 processor core Cortex-M3 Processor System Block Diagram Cortex ‐ M3 bus connection example Register Group The Cortex-M3 processor has a register set of R0-R15. R13 is used as the stack pointer SP. There are two SPs, but only one can be seen at the same time, which is the so-called "banked" register.
[Microcontroller]
Several important block diagrams of Cortex-M3
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号