Multiple interrupt on same bus - Page 1
Forum section: electronics / projects

author: mheruian
author_rank: Contributor
timestamp: June 12, 2018, 03:24:14 pm
content: Hi guys,I am new to interrupt stuffs. Watch and read a lot about it so somehow familiar. I just want to ask is it possible to have many interrupts on a single bus/connection to the microcontroller? Do i need to consider stuffs like putting additional electronic components on the bus to work this out properly? because so far, i haven't seen anyone on my searches that had tried itI hope you could just straight-forwardly give me answer because I'm not that much geeky.

author: C
author_rank: Super Contributor
timestamp: June 12, 2018, 06:26:37 pm
content: YESWhen working with a bus with many things connected, the many different interrupts lets you know what needs interrupt service.With out many interrupts you would have to find what thing needs the service.Going a step further, some things connected can have many different interrupts outputs, again saving time with the interrupt stating what needs service.C

author: Kleinstein
author_rank: Super Contributor
timestamp: June 12, 2018, 07:11:03 pm
content: Interrupts over an exteral bus are not that typical for µC. Many µC, especially the smaller ones have no external bus at all. In an µC the interrupt handling is usually internal and many interrupt source are also internal, like times or UART or I2C or an ADC. There are usually also some pins that can directly trigger an Interrupt.It very much depends on the µC - there are quite different ones.There is usually no need to trigger more interrupts at the same time, because the internal CPU still has the serve the interrupts one after the other - so a special handler could also do all the jobs in a single interrupt, though details could differ a little depending on the interrupt queue if there are additional interrupts pending or following very soon.

author: mheruian
author_rank: Contributor
timestamp: June 12, 2018, 10:51:03 pm
content: Quote from: C on June 12, 2018, 06:26:37 pmQuote from: Kleinstein on June 12, 2018, 07:11:03 pmThanks a lot guysi have these ICs that are limited so i am not quite sure if i had to test it so i did ask first. I have 5 pieces of same PMICs having same external interrupt output pin. I have my microcontroller where i need to save GPIO pins that's why i just want a single bus for external interrupt inputs and i had this mind setup where can I connect the 5 PMICs interrupt pins to be connected on a single external interrupt pin of microcontroller then just poll each of the 5 PMICs to know which had interrupted - something like that. And i was thinking if do i have to put pull down resistors, etc on the bus to make this reliable.

author: C
author_rank: Super Contributor
timestamp: June 12, 2018, 11:48:04 pm
content: It depends on what you call and external bus.Is I2C or SPI an external bus?I think and many others think they are.And I have seen many chips that connect to these buses have an interrupt output pin.The question then becomes how you connect these interrupt pins to microcontroller.You could connect each Interrupt output pin to a pin on microcontroller that is capable of creating and interrupt. This is nice as pin interrupt = chip on bus needing service.Next best choice is connect each interrupt output pin to a priority encoder input.Using an 8-bit priority encoder gives you a new interrupt output & you get a 3-bit binary output of which of 8 caused the interrupt. So in place of polling to find which of 8 needs interrupt service a simple 3-bit tells you. These chiips are designed to scale so each additional bit is power of 2 interrupt sources.So a pin causing a interrupt on microcontroller causes a read which gets what interrupt needs service.So#1 with one GPIO pin that can create an interrupt & OR of interrupt sources you have an interrupt and a need to poll each.#2 Replace OR of #1 with 8-bit priority encoder and read 3-bit output of 8-bit priority encoder and know which needs interrupt service.This read could be on the bus that has the 5 PMICs.C

author: rstofer
author_rank: Super Contributor
timestamp: June 13, 2018, 12:05:31 am
content: You're stepping back more than 50 years if you try to use a single pin for multiple external interrupts. It might be ok if you had an interrupt controller but even the old IBM1130 had multiple interrupt levels and multiple devices per level. It was no big deal because there was a register associated with each level that indicated exactly what interrupts were active. More important levels could interrupt lesser levels. Once the card starts moving through the card reader, you either got the column when the interrupt came by or you missed it. Card reader was a high priority interrupt. Keyboard was a low priority interrupt. Interesting thing: There was no way to disable interrupts!More recently, the Intel 8080 family had an 8259 Interrupt Controller which is just what you need - if you had an 8 bit data bus to read it. It was easy with the old microcomputers, less so with the modern microcontrollers.https://pdos.csail.mit.edu/6.828/2014/readings/hardware/8259A.pdf

author: C
author_rank: Super Contributor
timestamp: June 13, 2018, 01:32:03 am
content: In simple terms your 8259 Interrupt Controller is just one way to do interrupts. The 8259 puts instructions on bus at Interrupt ACK.The PDP-11, Z80 & 68000 all supported vector interrupts. Just a different way to do things. Here the CPU reads a interrupt vector at interrupt ACK.The Z80 then uses Vector as am address to a table in memory for starting address of interrupt code. The old Z80 can have up to 128 vector interrupts.Both have used the same number of bus cycles.Going an additional step. Z80 & 68000 have a daisy chain that sets priority of each interrupt in the chain. My memory has PDP-11 having daisy chains also.The 68000 has many levels and a daisy chain for each level.The big difference here is that the 8259 is much more limited then the the Vector interrupt method. The 8259 way is actually a security problem, as it can supply any valid instructions in response to interrupt ACK.As to your card reader. The priority is set by where in daisy chain it is connected and what daisy chain.Just a different way of doing things.By using an 8-bit priority encoder, mheruian can set the priority of his interrupts and a read gives what vector.From what you state about the IBM1130 it sounds like it is much more limited then the PDP-11, Z80 & 68000.C

author: Ian.M
author_rank: Super Contributor
timestamp: June 13, 2018, 02:09:03 am
content: I'm assuming your interrupt sources hold an active level until serviced. If not, it gets really *fugly* really quick and lost interrupts are highly probable.Although you can wire multiple active low open drain interrupt outputs together to a single MCU interrupt pin, with a pullup resistor to hold the pin high with no interrupt source active, that is a real PITA because you need to poll every possible interrupt source over your SPI or I2C bus to determine what interrupted.To handle multiple interrupt sources to a single MCU pin without having to poll every single device on the I2C or SPI bus to determine what caused the interrupt, use a Microchip MCP23008 (I2C) or MCP23S08 (SPI) 8 bit I/O expander(datasheet)as an interrupt controller. Yes it needs extra pins for I2C or SPI, but can coexist on the same bus as other I2C or SPI devices so the only overhead is one 7 bit I2C address used on that bus, or one additional SPI chip select from your MCU for the SPI version.Configure its INTCON and DEFVAL registers for level triggered interrupts on all I/O pins, and enable those you want using its GPINTEN register. Connect its INT output pin to an interrupt capable input pin on your MCU and configure the ODR and INTPOL bits in its IOCON register for active high, active low or open drain active low interrupt output as required by your MCU. Finally poll its GPIO register to clear any false interrupts that may have occurred while setting it up and for the I2C version, set its register address to INTF so you can read that register quickly, with only a two byte transfer.When one of its inputs changes to the interrupt state you defined in DEFVAL, it will pass that interrupt on to your MCU and also latch it in its INTF register.Unless its on a dedicated SPI or I2C bus, if the bus is in use, you'll probably have to defer servicing the MCU interrupt till the bus is free.The ISR running in your MCU must then poll the MCP23x08's INTF register (over the I2C or SPI bus) to determine what caused the interrupt, and service it, + any others that may have activated between the first one and polling INTF. It then needs to clear the interrupt by polling the MCP23x08's GPIO register - all bits should be at the interrupt inactive state. If any are not, it represents an unexpected interrupt that occurred while servicing the interrupts detected by polling INTF. Service the unexpected interrupt(s) and re-poll GPIO till all bits are at the interrupt inactive state then (I2C version only) set its register address back to INTF. Finally clear the MCU's interrupt flag for whichever MCU interrupt pin you are using and return from your ISR.

author: mheruian
author_rank: Contributor
timestamp: August 19, 2018, 07:19:51 am
content: Thanks for all the reply, just got back from no tech vacationi appreciate all the answer and help. I'll try all of them out starting with the priority encoder.