i.MX.RT1050 - Encoder - watchdogTimeoutValue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX.RT1050 - Encoder - watchdogTimeoutValue

Jump to solution
1,717 Views
Cindy
Contributor III

Hi,

I am trying to set watchdogTimeoutValue so that the interrupt triggered only once every ms if there is not inputs to capture.

However, the interrupt always triggered every 1.3ms no matter what was the value of watchdogTimeoutValue. When I set  watchdogTimeoutValue = 0x0FFFFFFF, the interrupt was triggered every 1.3ms. When I set  watchdogTimeoutValue = 0xFFFFFFFF, the interrupt was still triggered every 1.3ms.

 

Please let me know what is wrong with my setup:-

 

 

 

Lets say the source clock for the encoder is 25MHz.

 

#define QENC_BASEADDR ENC1
#define QENC_IRQ_ID ENC1_IRQn
#define QENC_IRQHandler ENC1_IRQHandler


void QENC_IRQHandler(void)
{
ENC_ClearStatusFlags(QENC_BASEADDR, kENC_WatchdogTimeoutFlag);

__DSB();
}

 

int main()
{
enc_config_t mEncConfigStruct;

....

ENC_GetDefaultConfig(&mEncConfigStruct);

mEncConfigStruct.enableWatchdog = true;
mEncConfigStruct.watchdogTimeoutValue = 0xFFFFFFFF;

ENC_Init(QENC_BASEADDR, &mEncConfigStruct);
ENC_DoSoftwareLoadInitialPositionValue(QENC_BASEADDR); /* Update the position counter with initial value. */


EnableIRQ(QENC_IRQ_ID);
ENC_EnableInterrupts(QENC_BASEADDR, kENC_WatchdogTimeoutInterruptEnable);


while(1)
{
}

return 0;
}

 

 

Thanks!

 

Best Regards,

Cindy

0 Kudos
Reply
1 Solution
1,693 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,

Thanks for your reply.
Firstly, I think the code is good, second, the WTR register is 16 bit, not 32 bit, so it's no different to set 0xFFFFFFFF or 0x0FFFFFFF to it.
Last, please calculate the timeout period whether closes to 1.3 ms when the WTR = 0xFFFF.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

4 Replies
1,709 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Actually, I'm not very clear with your question, especially the interrupt you mentioned, does it pertain to Watchdog or Encoder?
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply
1,700 Views
Cindy
Contributor III

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

0 Kudos
Reply
1,694 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,

Thanks for your reply.
Firstly, I think the code is good, second, the WTR register is 16 bit, not 32 bit, so it's no different to set 0xFFFFFFFF or 0x0FFFFFFF to it.
Last, please calculate the timeout period whether closes to 1.3 ms when the WTR = 0xFFFF.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,682 Views
Cindy
Contributor III

Hi JeremyZhou.

 

You are right! I have corrected the mistake and it is working as expected now.

Yes, the timeout period is about 1.3ms when WTR = 0xFFFF.

Thank you!

 

Best Regards,

Cindy

0 Kudos
Reply