Skip to main content
fix typo
Source Link
Dave Tweed
  • 178.3k
  • 17
  • 242
  • 418

Is there a better approach, easier?

One would normally use a uC that supports low-power mode (sleep), and then wake from an interrupt. Many uC's allow interrupts to be generated from input pins.

This is cleaner, more elegant, and the expected way to do things.

If the signal is coming from a mechanical switch, then the switch signal must be properly de-bounced, outside the controller, in order to be used as an interrupt input (or else your uC may become very confused...). Proper method(s) for (hardware) switch debouncing is another subject.

Interrupts are recorded in registers, which once set are not unset until handled. This means that if the user lets go of the button, it's activation will state will remain until you handle it in code.

Since you don't specify what controller you are using, we can't say if these common features are supported in your hardware.

Is there a better approach, easier?

One would normally use a uC that supports low-power mode (sleep), and then wake from an interrupt. Many uC's allow interrupts to be generated from input pins.

This is cleaner, more elegant, and expected way to do things.

If the signal is coming from a mechanical switch, then the switch signal must be properly de-bounced, outside the controller, in order to be used as an interrupt input (or else your uC may become very confused...). Proper method(s) for (hardware) switch debouncing is another subject.

Interrupts are recorded in registers, which once set are not unset until handled. This means that if the user lets go of the button, it's activation will state will remain until you handle it in code.

Since you don't specify what controller you are using, we can't say if these common features are supported in your hardware.

Is there a better approach, easier?

One would normally use a uC that supports low-power mode (sleep), and then wake from an interrupt. Many uC's allow interrupts to be generated from input pins.

This is cleaner, more elegant, and the expected way to do things.

If the signal is coming from a mechanical switch, then the switch signal must be properly de-bounced, outside the controller, in order to be used as an interrupt input (or else your uC may become very confused...). Proper method(s) for (hardware) switch debouncing is another subject.

Interrupts are recorded in registers, which once set are not unset until handled. This means that if the user lets go of the button, it's activation will state will remain until you handle it in code.

Since you don't specify what controller you are using, we can't say if these common features are supported in your hardware.

Source Link
Chris Knudsen
  • 3.7k
  • 14
  • 21

Is there a better approach, easier?

One would normally use a uC that supports low-power mode (sleep), and then wake from an interrupt. Many uC's allow interrupts to be generated from input pins.

This is cleaner, more elegant, and expected way to do things.

If the signal is coming from a mechanical switch, then the switch signal must be properly de-bounced, outside the controller, in order to be used as an interrupt input (or else your uC may become very confused...). Proper method(s) for (hardware) switch debouncing is another subject.

Interrupts are recorded in registers, which once set are not unset until handled. This means that if the user lets go of the button, it's activation will state will remain until you handle it in code.

Since you don't specify what controller you are using, we can't say if these common features are supported in your hardware.