Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/apps/rs232_expander_apps/aanderaa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(APP_LIBS

set(APP_DEFINES
APP_NAME="${APP_NAME}"
APP_AANDERAA_CURRENT_METER
# Add network stress test functions
STRESS_TEST_ENABLE
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ extern "C" {
#define configUSE_PREEMPTION 1
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#ifdef APP_AANDERAA_CURRENT_METER
#define configUSE_IDLE_HOOK 0
#else // APP_AANDERAA_CURRENT_METER
#define configUSE_IDLE_HOOK 1
#endif // APP_AANDERAA_CURRENT_METER
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( SystemCoreClock )
#define configTICK_RATE_HZ ((TickType_t)1000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ static void defaultTask(void *parameters) {
// platform boot before starting the watchdog task
memfault_platform_boot();

#ifdef APP_AANDERAA_CURRENT_METER
startIWDGTask();
#endif // APP_AANDERAA_CURRENT_METER
startSerial();

startSerialConsole(&usbCLI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
#define CLI_TASK_PRIORITY 1
#define DEFAULT_TASK_PRIORITY 1

#define IWDG_TASK_PRIORITY 0
8 changes: 8 additions & 0 deletions src/lib/common/lpm_u5.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,18 @@ void lpmPreSleepProcessing() {
}

void lpmPostSleepProcessing() {
//
// A bug was found with the Aanderaa Current Meter RS232 Mote application with this
// implementation of the watchdog. So for now while we figure out how to workaround it
// we will go back to using the old watchdog for the Aanderaa Current Meter RS232 app.
// See watchdog.c for more details.
//
#ifndef APP_AANDERAA_CURRENT_METER
// reference xMaximumSuppressedTicks, the maximum amount of time we can sleep
// is 1998 ticks (or ms, ref configTICK_RATE_HZ). Feed the watchdog here
// before moving onto next tasks
watchdogFeed();
#endif // APP_AANDERAA_CURRENT_METER
if (SCB->SCR & SCB_SCR_SLEEPDEEP_Msk)
{
// We may have been in deep sleep. If we were, the RCC cleared several enable bits in the CR, and
Expand Down
53 changes: 52 additions & 1 deletion src/lib/common/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,36 @@
#include "iwdg.h"
#include "task_priorities.h"

// If you want to use the memfault watchdog, uncomment the following include,
// enable the LPTIM2 clock, and uncomment the memfault_software_watchdog_enable()
// call in startIWDGTask() and the memfault_software_watchdog_feed() call in watchdogFeed()
// #include "memfault/ports/watchdog.h"

void watchdogFeed() {
LL_IWDG_ReloadCounter(IWDG);
// memfault_software_watchdog_feed();
}

/***************************************************************************************
*
* Potential Watchdog issue relating to STM32u575 Errata 2.2.26
*
* We have observed that the Aanderaa Current Meter RS232 application has been
* unexpectedly resetting during some of our testing. Through testing and git bisecting
* we were able to determine that the commit that changed the watchdog from PR#316
* was the commit that introduced the issue. Interestingly with the watchdog changes
* this vApplicationIdleHook gets called before we enter Stop mode. Errata 2.2.26 states
* that there are certain conditions that if met upon entering sleep would result in
* the processor being stuck in stop mode with a system reset being the only recovery
* method. So this errata, along with other theories are being investigated to root
* cause the unexpected resets.
*
* While we are doing that we are going to go back to using the old watchdog for the
* Current Meter Aanderaa RS232 application.
*
***************************************************************************************/
void vApplicationIdleHook(void) {
watchdogFeed();
}

//
Expand All @@ -25,10 +53,33 @@ void watchdogFeed() {
// periodically and the watchdog is only refreshed when several
// conditions are met.
//
#ifdef APP_AANDERAA_CURRENT_METER
static void iWDGTask( void *parameters );

void vApplicationIdleHook(void) {
void startIWDGTask() {
// memfault_software_watchdog_enable();
BaseType_t rval;
rval = xTaskCreate(
iWDGTask,
"IWDG",
configMINIMAL_STACK_SIZE,
NULL,
IWDG_TASK_PRIORITY,
NULL);

configASSERT(rval == pdTRUE);
}

static void iWDGTask( void *parameters ) {
// Don't warn about unused parameters
(void) parameters;

for(;;) {
watchdogFeed();
vTaskDelay(2 * 1000);
}
}
#endif // APP_AANDERAA_CURRENT_METER

void IWDG_IRQHandler(void) {
LL_IWDG_EnableWriteAccess(IWDG);
Expand Down
1 change: 1 addition & 0 deletions src/lib/common/watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
extern "C" {
#endif

void startIWDGTask();
void watchdogFeed();

#ifdef __cplusplus
Expand Down
Loading