fixed and enabled software watchdog timer
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="2331"/>
|
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="2331"/>
|
||||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/>
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/>
|
||||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="false"/>
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
|
||||||
@@ -77,6 +77,6 @@
|
|||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<listEntry value="4"/>
|
<listEntry value="4"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/>
|
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/>
|
||||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
|||||||
@@ -77,6 +77,6 @@
|
|||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<listEntry value="4"/>
|
<listEntry value="4"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/>
|
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/>
|
||||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
|||||||
@@ -4,35 +4,46 @@
|
|||||||
#include "test_led.h"
|
#include "test_led.h"
|
||||||
#include "init_peripherals.h"
|
#include "init_peripherals.h"
|
||||||
|
|
||||||
//static uint32_t prevWatchdogCounter = 0;
|
/* NOTE: Because of a bug in the ROM bootloader of the KL03Z, the watchdog timer is disabled and cannot be re-enabled.
|
||||||
uint32_t I2cWatchdog_RecoveryCounter;
|
* See https://community.nxp.com/thread/457893
|
||||||
volatile uint32_t I2cWatchdog_WatchCounter;
|
* Therefore the hardware watchdog timer cannot be used without an extra way to enter bootloader or application mode.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define WATCH_ENABLE_WATCHDOG (1) /* additionally, un-comment InitI2cWatchdog() in init_peripherals.c */
|
||||||
|
|
||||||
|
#if WATCH_ENABLE_WATCHDOG
|
||||||
|
static uint32_t prevWatchdogCounter = 0;
|
||||||
|
#endif
|
||||||
|
static uint32_t I2cWatchdog_RecoveryCounter; /* counter for how many times we had to recover and restart */
|
||||||
|
|
||||||
void InitI2cWatchdog(void)
|
void InitI2cWatchdog(void)
|
||||||
{
|
{
|
||||||
lptmr_config_t lptmrConfig;
|
lptmr_config_t lptmrConfig;
|
||||||
LPTMR_GetDefaultConfig(&lptmrConfig);
|
LPTMR_GetDefaultConfig(&lptmrConfig);
|
||||||
LPTMR_Init(LPTMR0, &lptmrConfig);
|
LPTMR_Init(LPTMR0, &lptmrConfig);
|
||||||
LPTMR_SetTimerPeriod(LPTMR0, USEC_TO_COUNT(LPTMR_USEC_COUNT, LPTMR_SOURCE_CLOCK));
|
LPTMR_SetTimerPeriod(LPTMR0, USEC_TO_COUNT(LPTMR_USEC_COUNT, LPTMR_SOURCE_CLOCK)); /* set LPTM for a 100 ms period */
|
||||||
LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable);
|
LPTMR_EnableInterrupts(LPTMR0, kLPTMR_TimerInterruptEnable);
|
||||||
EnableIRQ(LPTMR0_IRQn);
|
EnableIRQ(LPTMR0_IRQn);
|
||||||
LPTMR_StartTimer(LPTMR0);
|
LPTMR_StartTimer(LPTMR0);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
#if WATCH_ENABLE_WATCHDOG
|
||||||
void I2C_WATCHDOG_LPTMR_HANDLER(void)
|
void I2C_WATCHDOG_LPTMR_HANDLER(void)
|
||||||
{
|
{
|
||||||
|
static volatile uint32_t I2cWatchdog_WatchCounter = 0; /* counter for timer */
|
||||||
TEST_LED_TOGGLE();
|
TEST_LED_TOGGLE();
|
||||||
I2cWatchdog_WatchCounter++;
|
I2cWatchdog_WatchCounter++;
|
||||||
|
|
||||||
if (I2C_Watchdog == prevWatchdogCounter) { // Restart I2C if there hasn't been any interrupt during 100 ms
|
if (I2cWatchdog_WatchCounter>1) { /* do not check within the first 100 ms, as I2C might not be running yet */
|
||||||
// NVIC_SystemReset();
|
if (I2C_Watchdog == prevWatchdogCounter) { // Restart I2C if there hasn't been any interrupt during 100 ms. I2C_Watchdog gets incremented for every I2C transaction
|
||||||
I2cWatchdog_RecoveryCounter++;
|
// NVIC_SystemReset();
|
||||||
I2C_SlaveDeinit(I2C_BUS_BASEADDR);
|
I2cWatchdog_RecoveryCounter++;
|
||||||
InitI2c();
|
I2C_SlaveDeinit(I2C_BUS_BASEADDR);
|
||||||
|
InitI2c();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
prevWatchdogCounter = I2C_Watchdog; /* remember previous counter */
|
||||||
prevWatchdogCounter = I2C_Watchdog;
|
|
||||||
|
|
||||||
LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
|
LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ void InitPeripherals(void)
|
|||||||
InitLedDriver();
|
InitLedDriver();
|
||||||
InitTestLed();
|
InitTestLed();
|
||||||
LedPwm_Init();
|
LedPwm_Init();
|
||||||
// InitI2cWatchdog();
|
|
||||||
DebugOverSpi_Init();
|
DebugOverSpi_Init();
|
||||||
InitI2c();
|
InitI2c();
|
||||||
|
InitI2cWatchdog();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,10 +64,10 @@
|
|||||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="uhk60-right_debug/uhk-right.elf"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="uhk60-right_debug_standalone/uhk-right.elf"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="uhk-right"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="uhk-right"/>
|
||||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.1939339834.1692217331.1297236062.2081695142"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
<listEntry value="/uhk-right"/>
|
<listEntry value="/uhk-right"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
@@ -77,6 +77,6 @@
|
|||||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/>
|
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/>
|
||||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
|||||||
Reference in New Issue
Block a user