I am using a Kinetis K64 device with MQX, using Processor Expert to create drivers for some peripherals for which MQX does not provide drivers.
I am using the WatchDog_LDD component to configure and drive the EWM (the External Watchdog Monitor module, not the regular Watchdog Timer module). PE generates an Init() function that I call to initialise the device, and a Clear() function that I call regularly to clear it. If I don't clear it at the appropriate rate the watchdog expires and the EWM_OUT pin becomes asserted, which forces some external hardware into a fail-safe state. This all works as expected.
I would like to be able to tell, in firmware, if the watchdog has expired. Processor Expert does not offer to generate any function that would provide this information. Looking at the MCU datasheet, I see there is no convenient register bit that shows this. There is, however, a register bit that enables an interrupt on expiry. Processor Expert looks like it has the ability to generate a callback via the OnWatchDog() event, but this is greyed out and I cannot set it to generate code.
Is there some way to enable the OnWatchDog event of the PE WatchDog_LDD component for the EWM on the K64? If so, how?
Solved! Go to Solution.
Hello,
The WatchDog_LDD component does not support the OnWatchDog event for EWM device. You can use Init_EWM component to initiliaze EWM and enable EWM interrupt. The interrupt service routine is declared and the interrupt service routine is registered in interrupt vector table. But you must write own code to service this interrupt.
The Init_EWM does not provide any other methods and therefore you must also write own EWM clear function (e.g. you can copy the code from the Clear method of the WatchDog_LDD component):
PE_ISR(EWM_ISR) {
/* user interrupt service routine code */
. . .
}
void EWM_Clear(void) {
EnterCritical();
EWM_PDD_WriteServiceReg(EWM_BASE_PTR, EWM_PDD_KEY_1);
EWM_PDD_WriteServiceReg(EWM_BASE_PTR, EWM_PDD_KEY_2);
ExitCritical();
}
Example of Init_EWM component configuration:
Best Regards,
Marek Neuzil
Hello,
The WatchDog_LDD component does not support the OnWatchDog event for EWM device. You can use Init_EWM component to initiliaze EWM and enable EWM interrupt. The interrupt service routine is declared and the interrupt service routine is registered in interrupt vector table. But you must write own code to service this interrupt.
The Init_EWM does not provide any other methods and therefore you must also write own EWM clear function (e.g. you can copy the code from the Clear method of the WatchDog_LDD component):
PE_ISR(EWM_ISR) {
/* user interrupt service routine code */
. . .
}
void EWM_Clear(void) {
EnterCritical();
EWM_PDD_WriteServiceReg(EWM_BASE_PTR, EWM_PDD_KEY_1);
EWM_PDD_WriteServiceReg(EWM_BASE_PTR, EWM_PDD_KEY_2);
ExitCritical();
}
Example of Init_EWM component configuration:
Best Regards,
Marek Neuzil
Hi Marek, thanks for the reply. The options that PE shows me are not the same as the ones shown in your screenshots. The Methods pages does offer to generate a Clear function (and it works), but the Properties page has no settings concerning interrupts.
Hello Matthew:
Marek recommended the Init_EWM component (), your screenshot is for WatchDog_LDD ().
Please read again his proposed workaround. Although I am not sure if the interrupt can be handled independently from MQX RTOS.
Regards!,
Jorge Gonzalez
Right, got it, thanks.