interrupt

How to implement a timer with interruption in C++?

喜欢而已 提交于 2019-12-06 07:28:49
I'm using the GCC compiler and C++ and I want to make a timer that triggers an interruption when the countdown is 0. Any Ideas? Thanks in advance. EDIT Thanks to Adam, I know how to do it. Now. What about multiple timers running in parallel? Actually, these timers are for something very basic. In NCURSES, I have a list of things. When I press a key, one of the things will change colors for 5 seconds. If I press another key, another thing in the list will do the same. It's like emphasize strings depending on the user input. Is there a simpler way to do that? One way to do it is to use the alarm

Should my interrupt handler disable interrupts or does the ARM processor do it automatically?

假如想象 提交于 2019-12-06 07:19:46
问题 Our group is using a custom driver to interface four MAX3107 UARTs on a shared I2C bus. The interrupts of the four MAX3107's are connected (i.e. shared interrupt via logic or'ing)) to a GPIO pin on the ARM9 processor (LPC3180 module). When one or more of these devices interrupt, they pull the GPIO line, which is configured as a level-sensitive interrupt, low. My question concerns the need, or not, to disable the specific interrupt line in the handler code. (I should add that we are running

Install timer/clock ISR on Windows - Asynchronous call in a single threaded environment

﹥>﹥吖頭↗ 提交于 2019-12-06 05:26:10
I'm refining some code which simulated a context-switching scheduler on x86 Windows systems. The program compiles on Windows XP (Edit: probably not Windows 7) with some ancient Borland C compiler, and is being ported to being MSVC compilable. At one point, the code installs ISRs through these unavailable functions in dos.h : void (*)() getvect(int) void setvect(int, void (*)()); Specifically, the code installs an ISR for a (cyclic) timer interrupt. The calls are: tick_isr_old = getvect(0x08); setvect(0xF2, tick_isr_old); setvect(0x08, (void interrupt (*)(void)) tick_isr); setvect(0xF1, (void

Java Hardware Interrupt Handling

我是研究僧i 提交于 2019-12-06 05:25:14
问题 I would like to know if it is possible to automatically invoke a Java method when a hardware interrupt is raised. 回答1: There may be an alternative. I'm doing something similar: In an application I monitor 4 mice for clicks. Those clicks generate interrupts but I'm happy enough not to deal with them directly from Java. Under Linux, it turns out there are device files ( /dev/input/mouse# ) that spew a bunch of characters when something happens with the mouse. I have a Thread for each one with a

How to call DOS Interrupts within a C/C++ program using Inline Assembly?

て烟熏妆下的殇ゞ 提交于 2019-12-06 04:40:41
I need to call some DOS interrupts (Services) from a C/C++ program, I tried the following inline asm code: (Read a character) int main() { asm( "movb $0x01, %ah;" "int $0x21" ); system("PAUSE"); } But it did not work ! I would like to know what have i done wrong here ! Also if there is another way to call dos interrupts ! Thank You ! You can only use DOS interrupts from DOS programs, so to make this work, you'd need a really ancient C++ compiler like Visual C++ 1.0 or 1.5, or Turbo C++/Borland C++ up through something like 4.5 or possibly 5.0. Then you'd have to fix your assembly code -- what

How to disable interrupts for one instruction?

微笑、不失礼 提交于 2019-12-06 03:26:26
Is there any other way to disable interrupts for the duration of only one instruction in x86 than using the CLI instruction? Yes, loading SS with a MOV will inhibit external interrupts for the next instruction. This is what the instruction set reference says: Loading the SS register with a MOV instruction inhibits all interrupts until after the execution of the next instruction. This operation allows a stack pointer to be loaded into the ESP register with the next instruction (MOV ESP, stack-pointer value) before an interrupt occurs. This code snippet does the trick: pushf pop ax and ax, FDFFh

Android: how cancel/interrupt/break pending SQLite query?

走远了吗. 提交于 2019-12-06 03:09:50
In my Android application user can fill database with imported data, then perform predefined, complex SQL query. With some data pattern, query will take very long (minutes and more on HTC Hero), while common usage will not exceed 10-15 seconds. Is there any way to cancel pending SQLite query on Android? Timeout would be as good as well, partial results are not required. I'm performing query within AsyncTask.doInBackground() I know best way is optimize query or change app logic, but in this case results depends on user knowledge anyway, so I'd like to help those who enter troublesome pattern.

SPI Slave setup on STM32F4 board

泄露秘密 提交于 2019-12-06 02:30:01
问题 I am trying to communicate between two STM32F4 discovery boards via SPI in Master & Slave configuration. I already have the code for the master but I am a bit confused on the changes I need to make on the SPI initialisation for the slave. I would also like to implement an interrupt whenever the master is sending data, rather than having the slave poll the RXNE register all the time. However, I am unsure of the exact configurations for the NVIC for the SPI. Below is the master's configuration

arm sleep mode entry and exit differences WFE, WFI

a 夏天 提交于 2019-12-05 19:01:48
问题 I am reasonably new to the ARM architectures and I am trying to wrap my head around the wake up mechanism. So first of all I am finding it difficult to find good info on this. ARM's documentation seems to be very terse on the topic. What I'd like to understand is when the Cortex (particularly the M0 as that's what I am working with) will wake up. For reference, I have also consulted the following: What is the purpose of WFI and WFE instructions and the event signals? Why does the processor

Lua / Java / LuaJ - Handling or Interrupting Infinite Loops and Threads

帅比萌擦擦* 提交于 2019-12-05 18:54:31
I'm using LuaJ to run user-created Lua scripts in Java. However, running a Lua script that never returns causes the Java thread to freeze. This also renders the thread uninterruptible. I run the Lua script with: JsePlatform.standardGlobals().loadFile("badscript.lua").call(); badscript.lua contains while true do end . I'd like to be able to automatically terminate scripts which are stuck in unyielding loops and also allow users to manually terminate their Lua scripts while they are running. I've read about debug.sethook and pcall , though I'm not sure how I'd properly use them for my purposes.