Hi JeremyZhou,
I am asking about the following watchdog timer:-
The i.MX RT1050 Processor Reference
Chapter 55 Quadrature Encoder/Decoder (ENC)
55.2.3.7 Watchdog Timer
The watchdog timer ensures that the algorithm is indicationg motion in the shaft; 2 successive counts indicate proper operation and will reset the timer
- The timeout value is programmable
- When a timeout occurs, an interrupt to the processor can be generated.
I took this example from SDK - "enc_basic".
I am trying to enable the watchdog timer for the encoder so that when there is pulse detected for, say, 1ms, watchdog will be triggered.
If you check these library files out - fsl_enc.c/.h, there is this function:-
void ENC_GetDefaultConfig(enc_config_t *config)
{
onfig->enableReverseDirection = false;
config->decoderWorkMode = kENC_DecoderWorkAsNormalMode;
config->HOMETriggerMode = kENC_HOMETriggerDisabled;
config->INDEXTriggerMode = kENC_INDEXTriggerDisabled;
config->enableTRIGGERClearPositionCounter = false;
config->enableTRIGGERClearHoldPositionCounter = false;
config->enableWatchdog = false;
config->watchdogTimeoutValue = 0U;
config->filterCount = 0U;
config->filterSamplePeriod = 0U;
config->positionMatchMode = kENC_POSMATCHOnPositionCounterEqualToComapreValue;
config->positionCompareValue = 0xFFFFFFFFU;
config->revolutionCountCondition = kENC_RevolutionCountOnINDEXPulse;
config->enableModuloCountMode = false;
config->positionModulusValue = 0U;
config->positionInitialValue = 0U;
}
What I have been doing is changing the default config to the following to enable the watchdog interrupt:-
enc_config_t mEncConfigStruct;
ENC_GetDefaultConfig(&mEncConfigStruct);
config->enableWatchdog = false;
config->watchdogTimeoutValue = 0xFFFFFFFFU;
ENC_Init(QENC_BASEADDR, &mEncConfigStruct);
ENC_DoSoftwareLoadInitialPositionValue(QENC_BASEADDR);
/* Enable at the NVIC */
EnableIRQ(QENC_IRQ_ID);
ENC_EnableInterrupts(QENC_BASEADDR, kENC_WatchdogTimeoutInterruptEnable);
My problem is no mater what value this config->watchdogTimeoutValue set to (0xFFFFFFFF or 0x0FFFFFFF, the interrupt always triggered every 1.3ms when input is missing.
I am looking forward for your help.
Thanks.
Best Regards,
Cindy