Skip to main content
better wording for foldls finding
Source Link
Arsenal
  • 18.1k
  • 2
  • 35
  • 61

You always have the possibility to add that feature manually through setting a flag before you enter the STOP mode, and check if that flag is set in the interrupt handler.

As you might forget to do that every time you enter STOP mode, you could write a global function (like the compiler intrinsic) which sets the flag and enters STOP mode.


EDIT: I thought this bit would be helpful, but as @foldl found out, this bit seems to be set only in case of a wakeup from STANDBYthe wakeup pins and not from STOP modeother pins. I haven't seen any other bit which might be useful for this.

The PWR_CSR register contains a wakeup flag bit (WUF, bit 0):

Bit 0 WUF: Wakeup flag This bit is set by hardware to indicate that the device received a wakeup event. It is cleared by a system reset or by setting the CWUF bit in the Power control register (PWR_CR)

0: No wakeup event occurred

1: A wakeup event was received from one of the enabled WKUPx pins or from the RTC alarm.

Note: An additional wakeup event is detected if one WKUPx pin is enabled (by setting the EWUPx bit) when its pin level is already high.

See Reference Manual Page 83.

So in your interrupt service routine, you can check this flag. Note however, that you have to manually clear it through setting the CWUF bit in the PWR_CR register:

Bit 2 CWUF: Clear wakeup flag.

This bit is always read as 0.

0: No effect

1: Clear the WUF Wakeup Flag after 2 System clock cycles. (write)

You always have the possibility to add that feature manually through setting a flag before you enter the STOP mode, and check if that flag is set in the interrupt handler.

As you might forget to do that every time you enter STOP mode, you could write a global function (like the compiler intrinsic) which sets the flag and enters STOP mode.


EDIT: I thought this bit would be helpful, but as @foldl found out, this bit seems to be set only in case of a wakeup from STANDBY and not from STOP mode. I haven't seen any other bit which might be useful for this.

The PWR_CSR register contains a wakeup flag bit (WUF, bit 0):

Bit 0 WUF: Wakeup flag This bit is set by hardware to indicate that the device received a wakeup event. It is cleared by a system reset or by setting the CWUF bit in the Power control register (PWR_CR)

0: No wakeup event occurred

1: A wakeup event was received from one of the enabled WKUPx pins or from the RTC alarm.

Note: An additional wakeup event is detected if one WKUPx pin is enabled (by setting the EWUPx bit) when its pin level is already high.

See Reference Manual Page 83.

So in your interrupt service routine, you can check this flag. Note however, that you have to manually clear it through setting the CWUF bit in the PWR_CR register:

Bit 2 CWUF: Clear wakeup flag.

This bit is always read as 0.

0: No effect

1: Clear the WUF Wakeup Flag after 2 System clock cycles. (write)

You always have the possibility to add that feature manually through setting a flag before you enter the STOP mode, and check if that flag is set in the interrupt handler.

As you might forget to do that every time you enter STOP mode, you could write a global function (like the compiler intrinsic) which sets the flag and enters STOP mode.


EDIT: I thought this bit would be helpful, but as @foldl found out, this bit seems to be set only in case of a wakeup from the wakeup pins and not from other pins. I haven't seen any other bit which might be useful for this.

The PWR_CSR register contains a wakeup flag bit (WUF, bit 0):

Bit 0 WUF: Wakeup flag This bit is set by hardware to indicate that the device received a wakeup event. It is cleared by a system reset or by setting the CWUF bit in the Power control register (PWR_CR)

0: No wakeup event occurred

1: A wakeup event was received from one of the enabled WKUPx pins or from the RTC alarm.

Note: An additional wakeup event is detected if one WKUPx pin is enabled (by setting the EWUPx bit) when its pin level is already high.

See Reference Manual Page 83.

So in your interrupt service routine, you can check this flag. Note however, that you have to manually clear it through setting the CWUF bit in the PWR_CR register:

Bit 2 CWUF: Clear wakeup flag.

This bit is always read as 0.

0: No effect

1: Clear the WUF Wakeup Flag after 2 System clock cycles. (write)

reflect the tests performed by @foldl
Source Link
Arsenal
  • 18.1k
  • 2
  • 35
  • 61

You always have the possibility to add that feature manually through setting a flag before you enter the STOP mode, and check if that flag is set in the interrupt handler.

As you might forget to do that every time you enter STOP mode, you could write a global function (like the compiler intrinsic) which sets the flag and enters STOP mode.

 

That being saidEDIT: I thought this bit would be helpful, there is a possibilitybut as @foldl found out, this bit seems to check if it wasbe set only in case of a wakeup or a normal interrupt (Ifrom STANDBY and not from STOP mode. I haven't tried it, just found that information in the reference manual)seen any other bit which might be useful for this.

The PWR_CSR register contains a wakeup flag bit (WUF, bit 0):

Bit 0 WUF: Wakeup flag This bit is set by hardware to indicate that the device received a wakeup event. It is cleared by a system reset or by setting the CWUF bit in the Power control register (PWR_CR)

0: No wakeup event occurred

1: A wakeup event was received from one of the enabled WKUPx pins or from the RTC alarm.

Note: An additional wakeup event is detected if one WKUPx pin is enabled (by setting the EWUPx bit) when its pin level is already high.

See Reference Manual Page 83.

So in your interrupt service routine, you can check this flag. Note however, that you have to manually clear it through setting the CWUF bit in the PWR_CR register:

Bit 2 CWUF: Clear wakeup flag.

This bit is always read as 0.

0: No effect

1: Clear the WUF Wakeup Flag after 2 System clock cycles. (write)

You always have the possibility to add that feature manually through setting a flag before you enter the STOP mode, and check if that flag is set in the interrupt handler.

As you might forget to do that every time you enter STOP mode, you could write a global function (like the compiler intrinsic) which sets the flag and enters STOP mode.

That being said, there is a possibility to check if it was a wakeup or a normal interrupt (I haven't tried it, just found that information in the reference manual).

The PWR_CSR register contains a wakeup flag bit (WUF, bit 0):

Bit 0 WUF: Wakeup flag This bit is set by hardware to indicate that the device received a wakeup event. It is cleared by a system reset or by setting the CWUF bit in the Power control register (PWR_CR)

0: No wakeup event occurred

1: A wakeup event was received from one of the enabled WKUPx pins or from the RTC alarm.

Note: An additional wakeup event is detected if one WKUPx pin is enabled (by setting the EWUPx bit) when its pin level is already high.

See Reference Manual Page 83.

So in your interrupt service routine, you can check this flag. Note however, that you have to manually clear it through setting the CWUF bit in the PWR_CR register:

Bit 2 CWUF: Clear wakeup flag.

This bit is always read as 0.

0: No effect

1: Clear the WUF Wakeup Flag after 2 System clock cycles. (write)

You always have the possibility to add that feature manually through setting a flag before you enter the STOP mode, and check if that flag is set in the interrupt handler.

As you might forget to do that every time you enter STOP mode, you could write a global function (like the compiler intrinsic) which sets the flag and enters STOP mode.

 

EDIT: I thought this bit would be helpful, but as @foldl found out, this bit seems to be set only in case of a wakeup from STANDBY and not from STOP mode. I haven't seen any other bit which might be useful for this.

The PWR_CSR register contains a wakeup flag bit (WUF, bit 0):

Bit 0 WUF: Wakeup flag This bit is set by hardware to indicate that the device received a wakeup event. It is cleared by a system reset or by setting the CWUF bit in the Power control register (PWR_CR)

0: No wakeup event occurred

1: A wakeup event was received from one of the enabled WKUPx pins or from the RTC alarm.

Note: An additional wakeup event is detected if one WKUPx pin is enabled (by setting the EWUPx bit) when its pin level is already high.

See Reference Manual Page 83.

So in your interrupt service routine, you can check this flag. Note however, that you have to manually clear it through setting the CWUF bit in the PWR_CR register:

Bit 2 CWUF: Clear wakeup flag.

This bit is always read as 0.

0: No effect

1: Clear the WUF Wakeup Flag after 2 System clock cycles. (write)

Source Link
Arsenal
  • 18.1k
  • 2
  • 35
  • 61

You always have the possibility to add that feature manually through setting a flag before you enter the STOP mode, and check if that flag is set in the interrupt handler.

As you might forget to do that every time you enter STOP mode, you could write a global function (like the compiler intrinsic) which sets the flag and enters STOP mode.

That being said, there is a possibility to check if it was a wakeup or a normal interrupt (I haven't tried it, just found that information in the reference manual).

The PWR_CSR register contains a wakeup flag bit (WUF, bit 0):

Bit 0 WUF: Wakeup flag This bit is set by hardware to indicate that the device received a wakeup event. It is cleared by a system reset or by setting the CWUF bit in the Power control register (PWR_CR)

0: No wakeup event occurred

1: A wakeup event was received from one of the enabled WKUPx pins or from the RTC alarm.

Note: An additional wakeup event is detected if one WKUPx pin is enabled (by setting the EWUPx bit) when its pin level is already high.

See Reference Manual Page 83.

So in your interrupt service routine, you can check this flag. Note however, that you have to manually clear it through setting the CWUF bit in the PWR_CR register:

Bit 2 CWUF: Clear wakeup flag.

This bit is always read as 0.

0: No effect

1: Clear the WUF Wakeup Flag after 2 System clock cycles. (write)