1
\$\begingroup\$

I am trying to create a simple application to get the idea of interrupts down and eventually use it for a project that requires a HFINTOSC.

I made a flashing LED. I want the microcontroller to start in the sleep() mode and for it to wake-up from the sleep mode when a button connected to a pin is pressed.

Waking up from the sleep mode requires interrupts for what I have read, but at the same time, if I am using an HF internal oscillator, the HF internal oscillator is off during the sleep mode. Button inputs require a clock for them to work, right?

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Specify the MCU. \$\endgroup\$
    – user263983
    Commented Jul 24 at 1:22

1 Answer 1

3
\$\begingroup\$

The datasheet seems pretty clear to me.

page 72

8.1 Wake-up from Sleep
The device can wake-up from Sleep through one of the following events:

  1. External Reset input on MCLR pin, if enabled
  2. BOR Reset, if enabled
  3. POR Reset
  4. Watchdog Timer, if enabled
  5. Any external interrupt
  6. Interrupts by peripherals capable of running during Sleep (see individual peripheral for more information)

It goes on in some detail describing the process of waking up through interrupts. Then provides this figure, showing that the input and output clocks, and the program counter, stall while in sleep and resume once the interrupt is flagged.

waking via interrupts

Is there something not covered in the datasheet?

\$\endgroup\$
7
  • \$\begingroup\$ For an input to be read, doesn’t that require a clock to be on? Or for a interrupt to be serviced. \$\endgroup\$
    – xcaliber99
    Commented Jul 24 at 4:02
  • \$\begingroup\$ @xcaliber99 There is lots of combinational logic in microcontrollers. Not everything requires a clock. \$\endgroup\$ Commented Jul 24 at 4:10
  • \$\begingroup\$ @xcaliber99 An interrupt does not need to be serviced, software can clear the flag. Please read more than just a paragraph of the data sheet. \$\endgroup\$ Commented Jul 24 at 5:49
  • \$\begingroup\$ @xcaliber99 Both the INT pin or interrupt on pin change for a port work without clock (that's the point of sleep) and the device will still wakeup if the interrupt is disabled. It will then simply resume after the sleep instruction. The flag still has to be cleared and a NOP should be the first instruction after sleep. \$\endgroup\$ Commented Jul 24 at 10:14
  • \$\begingroup\$ i am still confused. For the device to wake-up through an interrupt event, the corresponding interrupt enable bit must be enabled. if GIE bit is disabled, the device continues execution after sleep instruction (it still wakes up). if the GIE bit is enabled, the device also continues execution (it also still wakes up) after sleep instruction but will call the interrupt service routine. So the "corresponding interrupt enable bit" isn't set by GIE? \$\endgroup\$
    – xcaliber99
    Commented Jul 24 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.