问题标签 [isr]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
assembly - ISR 后程序不断返回同一行。(组件 8086)
我正在处理中断,并且在运行代码时遇到了这个问题:
程序从 IRET 指令从 ISR(这里是 INT_PROC)返回后
它正在执行该行:
一次又一次,而它应该去:
我在论坛上发现了这个,它也说同样的:
为什么会发生这种情况,我该如何解决?请帮忙。
c - 通过中断或类似方法异步退出循环 (MSP430/C)
我遇到了一个让我很困惑的问题,因为我能想到的每个解决方案都有一个问题,导致它无法完全发挥作用。我正在 MSP430FF529 上开发一款游戏,当首次通电时,使用循环和循环延迟将两个图像无限地绘制到屏幕上。我想要它,这样当用户按下开始按钮(端口上的一个简单的高沿触发器)时,程序会立即停止绘制这些屏幕,无论它在进程的哪个部分,并开始执行其余部分运行游戏的代码。
我可以将把图像放在屏幕上的函数放在一个 do while 循环中,但它不会是异步的,因为当前正在绘制的图像必须在它继续之前完成。
我会使用 break 命令,但我认为这在 ISR 中不起作用,只有当它直接在循环中时才起作用。
我可以将整个程序的其余部分放在用于按下开始按钮的 ISR 中,这样屏幕绘图基本上就不会返回,但这确实很混乱,编码不佳,并且会在以后引起很多问题。
本质上,我想让它在按下按钮时立即跳转到程序的实际游戏部分,而忘记在屏幕上绘制这些图像。执行例程中的代码后,是否有可能以某种方式使 ISR 无法返回当前发生的情况?基本上,一旦程序开始前进(按下开始按钮),我不想回到绘制图像的函数,除非我再次明确调用它。
我唯一能想到的是 goto 命令,我觉得在这种特殊情况下实际上并不算太糟糕,尽管我想避免使用它,因为担心它会成为一种习惯,因为它在大多数情况下是一个糟糕的解决方案. 但是,这甚至可能行不通,因为我觉得在 ISR 中使用 goto 真的会弄乱堆栈。
有任何想法吗?任何建议表示赞赏。
stack - Does ISR (Interrupt Service Routine) have a separate stack?
When using an RTOS (ex FreeRTOS), we have separate stack spaces for each thread. So what about ISR (Interrupt Service Routines), does they have a separate stack in the memory? Or is this configurable?
If they don't have a stack where the local variables declared in ISR get stored?
arduino - UART传输完成后如何让Arduino切换变量?
在 Serial.write(buf, len) 发出的 UART 传输完成后,我想执行一些代码(比如切换标志变量)。
我尝试了几件事都没有成功。有人可以建议最好的方法吗?
谢谢。米
c - MSP430 中断开销
我正在为 MSP430 编写 ISR。它读取 volatile PxIFG 寄存器并在第一条指令上将其复制到堆栈变量中。ISR 跳转是否有任何开销,或者我可以期待吗
编译成类似的东西
我知道如果 ISR 跳转后的第一条指令是寄存器加载,我的 ISR 将按预期工作。我的理解是MSP430保证跳转后一条指令可以再次中断。如果加载不是跳转后的第一条指令,我会遇到一个问题,即在读取 P4IFG 寄存器之前我可能会再次被中断,并且它的值可能会更改为不同的值,这将是一个问题。
我期望编译器在跳转之后立即放置我的加载指令是否合理,从而确保我总是能在另一个中断可以更改它之前获得该寄存器的副本?
谢谢
c - 在 ISR 中使用全局变量标记执行是否安全
我知道不同的架构可能会提供不同的方法让开发人员检测 CPU 现在是否在 ISR 中运行,例如读取寄存器。
但是我确实发现在一些 BSP 代码中,他们使用了一个全局变量,它被称为g_in_isr
,作为指示 cpu 是否在 ISR 中运行的标志。当发生中断时,中断处理程序将在进入和退出时执行g_in_isr++
操作。g_in_isr--
我想知道这种方式在允许嵌套中断的架构上是否安全。在大多数架构中,g_in_isr++
或者g_in_isr--
不是原子操作(对吗?),如果现有中断处理程序正在执行g_in_isr++
操作时出现高优先级中断怎么办?它不会引起问题吗?
更新 (2016-03-27)
是的,我知道它依赖于架构,但我想知道一般情况。让我们假设它g_in_isr++
不是原子的,在大多数架构上它确实不是原子的,对吗?当然,我们也没有使用任何编译器魔法来使其具有原子性。
现在在这种情况下,它会引起问题吗?
linux-kernel - 如何在内核驱动程序 ISR 中使用延迟
我知道我当然不能使用 msleep 或 usleep 或任何此类函数在内核 ISR 例程中引入延迟。
我有一个内核驱动程序,其中定义了某些 ISR。在其中一个 ISR 块中,我必须插入一定的毫秒级延迟。让我们说:
我可以使用类似的东西:
假设我的处理器以 1Gbps 的速度执行,上面的 for 循环会给我 1000 微秒的延迟,即 1 毫秒吗?
assembly - 每个 IRQ 和 ISR 都会导致一个 GPF
我正在开发一个操作系统。我的 GDT 有三个条目。我创建了 IDT 并实现了 ISR 和 IQR。我还重新映射了图片。问题是在每个中断处理程序都遵循一般保护错误之后。这是调用中断的汇编代码:
我发现了一些奇怪的东西。当我使用 QEMU 作为磁盘映像运行操作系统时.iso
,它不起作用。但是当我通过指定选项将其称为内核时-kernel
,它按预期工作。我决定更改以下代码:
我将上面的代码更改为:
我仍然得到GPF。难道我做错了什么?有什么建议么?
embedded - 如何使用 Microchip Harmony Configurator (MHC) 为 PIC32MZ2048ECH144 的同一端口上的 2 个引脚编写 ISR 宏?
我正在使用 PIC32MZ2048ECH144。我有两个开关连接到 RH8(引脚 81)和 RH9(引脚 82)。我在 MHC 中没有看到任何在引脚级别设置中断的选项,因此我得到了为端口 H 生成的 ISR。我需要单独调用每个引脚的 ISR。因此,在“system_init.c”中,在“SYS_Initialize”函数中,我添加了以下几行,
PLIB_PORTS_PinChangeNoticePerPortEnable(PORTS_ID_0, PORT_CHANNEL_H, PORTS_BIT_POS_8); PLIB_PORTS_PinChangeNoticePerPortEnable(PORTS_ID_0, PORT_CHANNEL_H, PORTS_BIT_POS_9);
MHC在“system_interrupt.c”中生成的ISR:
我用以下几行替换了上面的 ISR 宏:
这没有成功。我提到了链接http://microchip.wikidot.com/faq:78。我觉得从“/pic32mx/include/proc/p32mz2048ech144.h”中选择 ISR 宏的向量号是错误的。(我使用 _ADC1_DATA22_VECTOR 和 _ADC1_DATA23_VECTOR 认为针对它们的值 81 和 82 是引脚编号,这同样不起作用。)关于如何设置引脚电平中断(同一端口上的 2 个引脚)的任何帮助或提示都会非常棒!请为我帖子中的任何错误道歉。
提前致谢。
assembly - Cortex M0+ (SAMD21) not executing pending interrupt
I discovered this issue when I tried to put the microcontroller to sleep and then wake it up, as an interrupt driven application. I noticed that my code did not resume from the line of code that was after my 'sleep' instruction.
When I manually trigger an interrupt while stepping through my code with a debugger it takes multiple steps (sometimes 2, sometimes 50 depending on the code) before it jumps to the ISR.
While trying to debug this issue I wrote this very simple piece of code which exhibits the issue:
I'm debugging using an external interrupt that I trigger myself with a jumper wire so that I know when it should have been triggered. What I'm noticing is that while I debug the code and step through it, if I trigger the external interrupt manually then it doesn't jump to the ISR straight away. The interrupt becomes 'pending' in the NVIC but exception entry isn't carried out until later in the code.
I've read a lot about interrupts and exceptions in the SAMD21 datasheet, the Cortex M0+ Generic User Guide and the ARM Architecture manual. Supposedly the the Cortex M series has low latency interrupts with no instruction overhead and so it seems like the code should jump to the ISR relatively quickly after triggering an interrupt.
I've read 2.3.6 of the Cortex M0+ Generic Guide multiple times as well as B1.3.2 of the ARM Architecture manual, which both cover exception entry in quite a bit of detail. The SAMD21 datasheet doesn't seem to have much low level information.
I've tried to isolate the problem and identify any patterns in the device's behavior and I've noticed a few things.
It only jumps to the ISR at specific lines of code. For example in the code above, if the external interrupt is triggered at start of 'loop()' it will jump to the ISR when it reaches the String declaration, regardless of how many iterations in the 'for' loop. If I move the String declaration up above the 'for' loop then it will jump to the ISR almost immediately (after 2 or 3 debugging steps).
I've tried inserting delays, NOPs and ISBs which don't effect how long it takes or make it jump instantly. When I set a pending interrupt in software through the ISPR register in the NVIC the same problem occurs. I've kept track of the base FLASH memory in Atmel Studio and noticed that "stack" onto which the processor's current 'state' is pushed, doesn't change immediately either. It only changes when I get to the first line of code in the ISR.
Other pieces of code that I've noticed act similar to a String declaration and cause the code to jump to the ISR is the endTransmission function of the Wire library, some functions in the SD card library, the Arduino delay function.
Could it be related to the fact that I'm using a debugger in the first place which interferes / doesn't play nice with interrupts? I'm fairly sure the problem occurred before I got the debugger out though. Edit: reading through the Cortex M0+ Technical Reference Manual and ARMv6 Manual I've found a register called DHCSR which allows the debugger to mask interrupts, but I can't work out how to access these registers.
Main Question: Aside from PRIMASK and global/individual enable register bits, what else could be preventing a pending interrupt from being executed?
Edit: left out an important piece of information, although I'm working in Atmel Studio the project uses the Arduino core.
EDIT: I have noticed that after I manually trigger an interrupt, it becomes pending in the NVIC->ISPR register during my next debugging step. This leads me to believe the interrupts are being masked somewhere (I've checked PRIMASK, global enable and individual enable so far with no luck).