Wake up interrupt input shared with LED output

Thread Starter

Goxeman

Joined Feb 28, 2017
176
Hi. I am short with MCU pins and I am trying to mix an LED output with an interrupt input to wake up the MCU from a deep sleep state on the same pin I/O. The MCU can only be woken up from deep sleep through an interrupt high input while is in deep sleep state. I send the MCU to deep sleep because I disconnect main power and keep MCU in deep sleep powered with a battery.

Right now I use two pins:
- One pin is used with a LED which is turned on with a high signal (3V) from MCU in normal operation (when is awake).
- Other pin is used as interrupt input to wake the MCU up when main 3V power is connected. As this pin is directly tied to main power, it always see 3V while the main power is on. When main power is disconnected (I still have battery power), I send the MCU to deep sleep and when the main power is back on the pin interrupt input see again 3V to wake up.

I want to mix both pins in only one pin I/O by changing the configuration of the pin on each situation:
- In normal operation (main power is on), the pin is configured as an output for the LED (default state is low to have the LED off).
- When main power turns off, before sending the MCU to deep sleep I change the pin configuration as interrupt input.
- When main power is back on (3V), the MCU wakes up and I change the the pin configuration back to output for the LED.

My problem with my configurations mixing idea is that the pin always see 3V while main power is on, therefore the LED is always on and I cant control it with the MCU.

Does any one have any suggestion? Thanks :)
 

crutschow

Joined Mar 14, 2008
34,680
My problem with my configurations mixing idea is that the pin always see 3V while main power is on, therefore the LED is always on and I cant control it with the MCU.
Connect the 3V to the pin through a capacitor to give an interrupt pulse when the 3V is applied, but no steady DC, so the operation of the LED is then unaffected.
The capacitor just needs to be large enough to generate a long enough pulse across the LED resistance for the MCU to recognize the interrupt.
Do you know how long a pulse would be needed?
 

Thread Starter

Goxeman

Joined Feb 28, 2017
176
Connect the 3V to the pin through a capacitor to give an interrupt pulse when the 3V is applied, but no steady DC, so the operation of the LED is then unaffected.
The capacitor just needs to be large enough to generate a long enough pulse across the LED resistance for the MCU to recognize the interrupt.
Do you know how long a pulse would be needed?
The datasheet says that it takes almost 9ms to wake up the MCU from deep sleep.

Do you mean connecting the capacitor in series with LED anode and MCU pin? I dont understand the logic.

Thanks because I would have never thought about it.
 

MisterBill2

Joined Jan 23, 2018
18,943
Certainly the capacitor trick is what I recommend. Any other scheme will be rather complex. and given the fairly high impedance of the input function the cap will not to be super large.
 

Thread Starter

Goxeman

Joined Feb 28, 2017
176
I will try for sure, I will try values of 100nF and 1uF to start my tests. What type of capacitors are normally used for this application? Ceramic? Electrolitic? Polirized or not?

Thanks
 

crutschow

Joined Mar 14, 2008
34,680
Do you mean connecting the capacitor in series with LED anode and MCU pin? I dont understand the logic.
No, I mean what I said.
The capacitor is in series with the 3V to the MCU input.
The LED stays connected as it already is.

The capacitor size depends upon the required pulse width, the rise-time of the 3V power signal, and the LED series resistor.

How is the 3V turned-on, and do you know what that resistor value is?
 
Last edited:

crutschow

Joined Mar 14, 2008
34,680
given the fairly high impedance of the input function the cap will not to be super large.
Note that the LED and its resistor are also connected to that input, thus the cap will have to drive that as well, so I suspect the capacitor will have to be in the 10's of microfarads to get the 9ms pulse.
 
Last edited:

Thread Starter

Goxeman

Joined Feb 28, 2017
176
Thanks for both of your answers.
I purchased a board that assembles the MCU I need and then I will do the tests. I never tried this :)
 

crutschow

Joined Mar 14, 2008
34,680
Below is the LTspice sim of an example circuit, with assumed values for the LED circuit:
The MCU input (yellow trace) stays above 2V (assumed logic high) for ≈16ms with a 10ms power rise-time (green trace).

1713965251301.png
 

Thread Starter

Goxeman

Joined Feb 28, 2017
176
Below is the LTspice sim of an example circuit, with assumed values for the LED circuit:
The MCU input (yellow trace) stays above 2V (assumed logic high) for ≈16ms with a 10ms power rise-time (green trace).

View attachment 320640
I see then it’s a bigger capacitor value than expected. I will try real capacitor voltage and see how it behaves in the oscilloscope.

thanks
 
Top