Interrupting an assembly instruction while it is operating

Yes all “normal” ISAs including 8080 and x86 guarantee that instructions are atomic with respect to interrupts on the same core. Either an instruction has fully executed and all its architectural effects are visible (in the interrupt handler), or none of them are. Any deviations from this rule are generally carefully documented. For example, Intel’s … Read more

C# read only Serial port when data comes

You will have to add an eventHandler to the DataReceived event. Below is an example from msdn.microsoft.com, with some edits: see comments!: public static void Main() { SerialPort mySerialPort = new SerialPort(“COM1”); mySerialPort.BaudRate = 9600; mySerialPort.Parity = Parity.None; mySerialPort.StopBits = StopBits.One; mySerialPort.DataBits = 8; mySerialPort.Handshake = Handshake.None; mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); mySerialPort.Open(); Console.WriteLine(“Press any key … Read more

What are the various ways to disable and re-enable interrupts in STM32 microcontrollers in order to implement atomic access guards?

Multiple ways to enable/disable interrupts in STM32 mcus: 1. Via ARM-core CMSIS: 1.A. For global interrupts __enable_irq() // enable all interrupts __disable_irq() // disable all interrupts // Returns the current state of the priority mask bit from the Priority Mask // Register. [0 if global interrupts are **enabled** and non-zero if they // are **disabled**] … Read more

dma vs interrupt-driven i/o

I’m a little unclear on differences between DMA and interrupt I/O Differences between DMA and interrupts are bogus because they are not opposing concepts. DMA and interrupts are orthogonal concepts, and both concepts are typically used together. The alternative to DMA is programmed I/O, aka PIO. The alternative to interrupts is polling. Interrupt-driven You need … Read more

Best way to read from a sensor that doesn’t have interrupt pin and requires some time before the measurement is ready

How to do high-resolution, timestamp-based, non-blocking, single-threaded cooperative multi-tasking This isn’t a “how to read a sensor” problem, this is a “how to do non-blocking cooperative multi-tasking” problem. Assuming you are running bare-metal (no operating system, such as FreeRTOS), you have two good options. First, the datasheet shows you need to wait up to 9.04 … Read more

Methods that Clear the Thread.interrupt() flag

Part of the problem has been that I do not know every method call out there that clears the interrupt flag. It is important to clarify that the following methods clear the interrupt flag by just calling them: Thread.interrupted() Thread.isInterrupted(true) — added to your list For this reason Thread.currentThread().isInterrupted() should always be used instead. The … Read more