IMX1050RT Encoder Interrupt Posmatch mode has no effect

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

IMX1050RT Encoder Interrupt Posmatch mode has no effect

3,348 Views
benolayinka
Contributor III

I'm trying to trigger an interrupt any time an encoder position changes, and it looks like the 

enc_config_t.positionMatchMode =

kENC_POSMATCHOnReadingAnyPositionCounter inititialization setting should cause the interrupt to trigger, but it does nothing. I confirmed in ENC_Init that setting positionMatchMode sets the 

ENC_CTRL2_OUTCTL_MASK, but it doesn't change the behaviour, I only get an interrupt when the position is equal to position compare.

Is this a hardware bug? Can someone with this board check?

/* Initialize the ENC module. */
 enc_config_t mEncConfigStruct;
 ENC_GetDefaultConfig(&mEncConfigStruct);
 mEncConfigStruct.positionMatchMode = kENC_POSMATCHOnReadingAnyPositionCounter;
 ENC_Init(ENC1, &mEncConfigStruct);
 ENC_DoSoftwareLoadInitialPositionValue(ENC1); /* Update the position counter with initial value. */
 NVIC_SetPriority(ENC1_IRQn, MAX_INTERRUPT_PRIORITY);
 EnableIRQ(ENC1_IRQn);
 ENC_EnableInterrupts(ENC1, kENC_PositionCompareInerruptEnable);c
Labels (1)
Tags (1)
0 Kudos
Reply
13 Replies

3,152 Views
benolayinka
Contributor III

The POSMATCH signal is the same one triggering the CMPIE (COMPARE MATCH) interrupt, right?

Is there any simple way to trigger an interrupt when the position changes? This seems like an obvious feature. I'm going to try wiring the POSMATCH signal in to a GPIO but that seems like an unnecessary workaround.

0 Kudos
Reply

3,152 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi BENJAMIN OLAYINKA,

  1. The POSMATCH signal is the same one triggering the CMPIE (COMPARE MATCH) interrupt, right?

     No, POSMATCH signal is the position match output, it own't triggering CMPIE.

pastedImage_1.png

    But when the compare matches the COMP, the compare interrupt request flag is set, then the POSMATCH output is asserted, please note, not the POSMATCH output trigger the CMPIE.

pastedImage_2.png

2. Is there any simple way to trigger an interrupt when the position changes?

  You can check the GPIO interrupt code in the SDK, as you know the POSMATCH will output the signal.

Wish it helps you!

If you still have questions about it, please kindly let me know.
Have a great day,
Kerry

-------------------------------------------------------------------------------
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

3,152 Views
benolayinka
Contributor III

Okay, thanks. Having to use two extra GPIO pins just to send/receive posmatch to trigger an interrupt makes it basically useless to me, I just wrote my own simple driver using an interrupt on the encoder phase a.

Thanks

Ben

0 Kudos
Reply

3,126 Views
thivya_ashokkum
Contributor II

Were you able workaround your issue and get an interrupt fired whenever the position changes?

0 Kudos
Reply

3,152 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi BENJAMIN OLAYINKA,

    POSMATCH can be connected to other SoC resources, just as the reference manual described:

pastedImage_1.png

If you don't want to use the external GPIO, maybe you can consider to use the POSMATCH output to tigger the timer channel, then use the timer interrupt, you can set the timer is very small.


Have a great day,
Kerry

 

-------------------------------------------------------------------------------
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

3,152 Views
jackking
Senior Contributor I

That’s exactly the same route I ended up taking.  A custom encoder library based on GPIO and interrupts...   I didn’t use the ENC module at all because it didn’t have this interrupt capability.

0 Kudos
Reply

3,154 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi  BENJAMIN OLAYINKA ,

   

          RT1050 chip ENC module can support the following interrupt:

pastedImage_1.png

       So, when you use the posmatch, do you want to get the compare match interrupt?

      When you posmatch happens, do you check the CTRL[CMPIRQ], is it set or not?


Have a great day,
Kerry

-------------------------------------------------------------------------------
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

3,154 Views
jackking
Senior Contributor I

Any updates on this?  I asked a similar question awhile ago: https://community.nxp.com/thread/503445   but I didn't know this OUTCTL option could allow interrupts on any position change.

I ended up abandoning the ENC peripheral and writing my own encoder library using GPIO and interrupts so I could generate interrupts whenever the encoder position changes, but I would love to go back to using the ENC.

0 Kudos
Reply

3,155 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Jack King,

   What's your detail problem?

   I find you didn't follow up your own post.

   As I know, OUTCTL  can't trigger the ENC interrupt directly. As you know, the ENC just have these interrupt:

pastedImage_1.png

But I didn't find the OUTCTL  triggered interrupt, so my thought is the same as you, can use OUTCTL  associate with the GPIO input interrupt.


Have a great day,
Kerry

-------------------------------------------------------------------------------
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

3,155 Views
benolayinka
Contributor III

Hi Kerry,

I get the CMPIRQ interrupt when POS is equal to POSCOMPARE (initialized as -1 in the default settings).

In the data sheet and in the source, it looks like setting the OUTCTL bit should change the POSMATCH function so that it fires ANY TIME a position register is read. I want an interrupt to fire any time the position changes, but setting OUTCTL isn't making that happen. Basically, the OUTCTL bit seems to do nothing.

Is there a simpler way to get an interrupt any time the encoder position changes?

Screen Shot 2019-07-05 at 12.27.48.png

0 Kudos
Reply

3,155 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi BENJAMIN OLAYINKA,

  Even you modify the OUTCTL to 1, but this bit can't fire the interrupt directly, it just can make POSMATCH pulses when the UPOS, LPOS, REV, or POSD registers are read.

   Just as the interrupt list for ENC which I give you, it doesn't have the PSMATCH pulse interrupt.

   But, if you want the PSMATCH pulse to trigger the interrupt, I think you can connect this signal to another external interrupt, then when the PSMATCH pulse happens, then that interrupt happens, take use the PSMATCH to trigger another gpio interrupt, but you need to connect your PSMATCH to the related gpio input pin.

  You can try it.

  If you still have questions about it, please kindly let me know.

 


Have a great day,
Kerry

-------------------------------------------------------------------------------
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

3,155 Views
jackking
Senior Contributor I

I just tried it as well, and I didn't ever see the interrupt generated.

0 Kudos
Reply

3,155 Views
benolayinka
Contributor III

I do get the interrupt, but only when POS = POSCOMPARE, which is initialized to -1 in the default settings. I would like to get an interrupt any time the position changes.

void ENC_GetDefaultConfig(enc_config_t *config)
{
...

//changing positionMatchMode should set OUTCTL and fire an interrupt any time position changes.. but it doesn't
    config->positionMatchMode = kENC_POSMATCHOnPositionCounterEqualToComapreValue;
    config->positionCompareValue = 0xFFFFFFFFU;
    
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
Reply