Basic Interrupt Behavior

On an ASIC, my ISR had to write a 1 in one place and a 0 in another place to acknowledge (ack) the interrupt. The hardware engineer I talked to tried to explain how one was an interrupt bit so that is why it needed a 1, but the other bit is a status bit it needed a 0 to clear the status. It was a little confusing; my ISR had to clear both bits before it could exit. In most ASICs I had dealt with, I wrote 1s to ack. In a few others, I wrote 0s. To come across one where I had to use both a 1 and a 0 was a new one.

Interrupts are a fundamental part of chips, but there is no standard way of implementing them. This leads to several problems:

  • A chip with blocks leveraged from several sources could have mixed interrupt methods.
  • Firmware drivers leveraged from one chip to another, or from one block to another, are prone to introducing defects.
  • Firmware engineers must first study the documentation to determine which method is being used.

Having firmware write a 1 to ack an interrupt is the best method to use. Most chips use it so it is more commonly known by firmware engineers. When the hardware issues an interrupt causing firmware to read the value in the interrupt register, there are 1s in the appropriate positions indicating which interrupt or interrupts occurred. So it is an easy step to use that value to ack the interrupt. Otherwise, firmware has to take a 1’s compliment of the value before writing it out. And firmware engineers have to remember to take that 1’s compliment everywhere the acking is done, whether acking with the value read from the interrupt register or using a constant (such as a #define) to specify which bit to use.

Best Practice: Design the interrupt module so that a 1 written to the interrupt register acks the interrupt.

Interrupt modules also have the ability to let firmware control whether or not a specific interrupt is allowed to propagate. I have seen this register called the “Enable” register for some chips and the “Mask” register for other chips. And I have also seen the “Mask” register in some chips use a 1 as a mask for allowing interrupts to propagate and other chips use a 0 to mask out the interrupt. Every time I come across an Interrupt “Mask” register, I have to first study the documentation to see if I should use a 0 or a 1.

The best term to use is “Enable” because it is clear in the reader’s mind that to “Enable” an interrupt, you write a 1.

Best Practice: Use “Enable” as the name of the register that controls which interrupts will propagate.

These are just a couple of aspects regarding interrupts that should be set as a standard. I will discuss more in future newsletters.

Until the next enabled interrupt…