Hi all,
I have a Photon with FW v0.6.1-rc2. Here below is simple the code that it runs:
#include "application.h"
SYSTEM_MODE(MANUAL);
#define RELAY_ON_PIN D1
#define RELAY_OFF_PIN D0
#define RELAY_SENSE_PIN D2
#define LED_STATUS D6
#define RELAY_DELAY 30
#define DEEP_SLEEP_SECONDS 5
#define DELAY_TIME_MS 5000
void setup()
{
}
void switch_relay_on(void)
{
pinMode(RELAY_ON_PIN, OUTPUT);
digitalWrite(RELAY_ON_PIN, HIGH);
delay(RELAY_DELAY);
digitalWrite(RELAY_ON_PIN, LOW);
}
void switch_relay_off(void)
{
pinMode(RELAY_OFF_PIN, OUTPUT);
digitalWrite(RELAY_OFF_PIN, HIGH);
delay(RELAY_DELAY);
digitalWrite(RELAY_OFF_PIN, LOW);
}
void loop()
{
pinMode(LED_STATUS, OUTPUT);
digitalWrite(LED_STATUS, HIGH);
delay(DELAY_TIME_MS);
pinMode(RELAY_SENSE_PIN, INPUT);
if (HIGH == digitalRead(RELAY_SENSE_PIN))
{
switch_relay_on();
}
else
{
switch_relay_off();
}
digitalWrite(LED_STATUS, LOW);
System.sleep(SLEEP_MODE_DEEP, DEEP_SLEEP_SECONDS);
}
The application runs fine and the Photon wakes up at regular intervals as expected, but only as long as the WKP pin is low when the Photon enters in Standby mode following an external WKP event (WKP pin rising edge). In fact in such case if the WKP pin is high before the Photon enters the Standby mode then it will not be woken up any more by the internal RTC alarm.
There is an interesting Note in the STM32F205xx Reference Manual which states the following:
Note: An additional wakeup event is detected if the WKUP pin is enabled (by setting the EWUP bit) when the WKUP pin level is already high. (see PWR_CSR register description).
Is this condition handled by the system drivers ?
Here below a timing diagram showing the point (in red) when the issue occurs.