Two inputs on one interrupt pin

I am working with a Trinket processor and only have available one interrupt pin. I want to detect when a button is pressed (interrupt signal is HIGH) and when the RTC sends an interrupt indicating an alarm has gone off (interrupt signal is LOW). I've set it up so that the ISR executes on any change. The code works when only one interrupt is connected to the pin, but when both are physically connected to the pin, no worky. Is this just something that will not work, or is there some kind of work around?

never mind :-)

It will not work when you've got a positive and a negative singal. You need to ensure you will generate the same signal. That means you need to invert one of the two signals. That's an easy job if the button can be connected to GND instead of power. The 2nd. best way would probably to invert the positive signal by sending it to a transistor (use a resistor). Then have a resistor between positive and collector of the transistor, and connect the emitter to GND. Your input then goes to the joint of resistor and collector. You need to make sure your combined signal doesn't influence the other part but i think you'll be OK here.

I will give it a try. Thanks so much.

You refer to a button. Manual pushbutton.

In general, it is a very bad idea to use interrupts to detect manual button presses (or most mechanical sources) as there is no need to do so - properly written code will poll sufficiently rapidly to detect such events. De-bouncing is much more difficult when you use interrupts and if a button event is expected to change the direction of execution of your program, an interrupts is an inappropriate way of doing so.

In fact, there is really only one reason to attach an interrupt to a pushbutton or switch - to wake from sleep.

To: MAS3

One more thing. You wouldn't be able to tell me the transistor I need for this. Either a general description or the specific item. Thanks.

That would be some general NPN transistor.
Like 2N2222 or BC547.
Base resistor would be something like 1K, collector resistor 10K (didn’t do any calculation here).
These are all real cheap parts.

Read Paul__B’s comment.
A button needs to be debounced, certainly when you are connecting it to an interrupt.
Else you might get multiple interrupts, even an interrupt during an interrupt (i’m not sure that is possible, but you want to prevent that).

Thanks again for the info.

I am not using the interrupt to read the buttons,and their output does run through a debouncing routine for the code. I am using the interrupt to wake the processor up when any button is pressed. With interrupt the ISR that handles it only sets a flag in the code and when the code sees the flag it disables the interrupt and handles whatever happened. The RTC has a routine one can use to see if the alarm has been triggered. Probably too much info but that's the general plan.

Works like a charm. Many thanks.

Can you please show us what you ended up doing in a schematic, and share your code? It sounds useful.