Hi,
we use K64 with KSDK2.1 and IAR Workbench.
I use KSDK2.1 lib funtions.
I use the K64 internal watchdog in my application. After using the watchdog in my application, I want to disable the watchdog again.
--> the disabled watchdog resets the system
I wrote a little demo:
- Setup GPIO A5 for debug purpose
- enable watchdog with 2 seconds + IRQ
- wait a short time
- disable watchdog
- wait forever
When waiting "forever" the disabled watchdog resets my system after 2 seconds. It looks, like the watchdog is still enabled!
Can anyone look at this, and tell me what goes wrong??
Best regards
Manfred
#define BOARD_TP37_GPIO GPIOA
#define BOARD_TP37_PORT PORTA
#define BOARD_TP37_PIN 5
#define BOARD_TP37_PIN_MASK (1L<<BOARD_TP37_PIN)
#define BOARD_WDOG_IRQ_PRIO 0
#define BOARD_WDOG_IRQ WDOG_EWM_IRQn
void Watchdog_IRQHandler(void) {
WDOG_ClearStatusFlags(WDOG, kWDOG_TimeoutFlag);
GPIO_SetPinsOutput(GPIOA, BOARD_TP37_PIN_MASK);
GPIO_ClearPinsOutput(GPIOA, BOARD_TP37_PIN_MASK);
GPIO_SetPinsOutput(GPIOA, BOARD_TP37_PIN_MASK);
return;
}
void main (void) {
uint32_t wait;
wdog_config_t config;
const port_pin_config_t pin_port_config = {
.pullSelect = kPORT_PullDisable,
.slewRate = kPORT_SlowSlewRate,
.passiveFilterEnable = kPORT_PassiveFilterDisable,
.openDrainEnable = kPORT_OpenDrainDisable,
.driveStrength = kPORT_LowDriveStrength,
.mux = kPORT_MuxAsGpio,
.lockRegister = kPORT_UnlockRegister
};
const gpio_pin_config_t pin_gpio_config = { kGPIO_DigitalOutput, 0 };
CLOCK_EnableClock(kCLOCK_PortA);
PORT_SetPinConfig(BOARD_TP37_PORT, BOARD_TP37_PIN, &pin_port_config);
GPIO_PinInit(BOARD_TP37_GPIO, BOARD_TP37_PIN, &pin_gpio_config);
GPIO_ClearPinsOutput(GPIOA, BOARD_TP37_PIN_MASK);
WDOG_GetDefaultConfig(&config);
config.enableWdog = true;
config.timeoutValue = 2000/8;
config.enableInterrupt = true;
config.prescaler = kWDOG_ClockPrescalerDivide8;
config.clockSource = kWDOG_LpoClockSource;
config.workMode.enableDebug = false;
WDOG_Init(WDOG, &config);
WDOG_Refresh(WDOG);
NVIC_SetPriority(BOARD_WDOG_IRQ, BOARD_WDOG_IRQ_PRIO);
EnableIRQ(BOARD_WDOG_IRQ);
__enable_interrupt();
wait = 0x10000;
while(--wait);
WDOG_GetDefaultConfig(&config);
config.enableWdog = false;
WDOG_Init(WDOG, &config);
for(;;);
}