How to Disable QuadDec_isr

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
mame_1061036
Level 1
Level 1

I have a simple QuadDec module which is connected to a motor encoder. If I now control the motor exactly to the position of the index signal, I have the problem that the processor is constantly stuck in the interrupt CY_ISR( QuadDec_ISR ) (file: QuadDec_INT.c).

I tried to stop the interrupt, but without success:

  • QuadDec_isr_Disable(): shows no effect
  • QuadDec_isr_Stop(): Code ends in the IntDefaultHandler which is expected.

Can I disable the interrupt? Why don't these APIs work?

0 Likes
1 Solution
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

You can also try CyIntClearPending(QD_ISR_NUMBER); to clear any pending interrupts. This too must be called from the callback function. This can be done if you don't want to disable and enable the interrupt every time.

Do let us know if it worked in your case.

Thanks and regards

Hari

View solution in original post

0 Likes
6 Replies
KyTr_1955226
Level 6
Level 6
250 sign-ins 10 likes given 50 solutions authored

Are you calling the ISR_ClearPending() function?

I'd imagine for the QuadDec component, you would need to read the counter/event registers to ensure the interrupt flag gets cleared and you don't immediately re-enter the ISR.

You can also use the QuadDec_SetInterruptMask(uint8) function to specify which events you want to trigger interrupts if you only want certain conditions to fire the ISR.

0 Likes

Since the interrupt is executed in code that has been autogenerated, I have not implemented ISR_ClearPending(). I also don't see this function called in the interrupt. Should I still insert the clearpending in the autocode? I think that's strange.


The interrupt mask is a good idea, I will try it out. But that doesn't explain why the interrupt deactivation doesn't work.

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi

You can try to run the code example "QDExample" and check if the same problem exists. This code example returns back to main after servicing the interrupt routine.

If masking the interrupt didn't work, please share your project so that we can take a look.

Thanks and regards

Hari

0 Likes

I don't think I've ever worked with a MCU that will automatically clear the interrupt flag/source, even with autogenerated code. That's on the programmer to do (since depending on how your ISR is laid out you may want to do it at a specific point).  To be fair though, PSoC is the only autogenerated code I've ever really used extensively, I can't speak to many others.

Also, if you don't feel like digging through autogenerated files to get to your ISRs, using the ISR Macro Callback would make it an easier time.  Search for "Macro Callbacks" in the PSoC Creator help.

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

If you are using a 32 bit counter for the Quadrature decoder, the QuadDec_SetInterruptMask() API will not work for counter overflow, underflow and reset interrupts.

You can try the CyIntDisable(QuadDec_ISR_NUMBER); API to disable the interrupt and write the CyIntDisable(QuadDec_ISR_NUMBER); in main to enable it once it comes back to main.

The function however, is suggested to be written in a separate callback function. You can refer PSoC Creator help-> Writing code, for details on how to write a callback function.

Thanks and regards

Hari

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

You can also try CyIntClearPending(QD_ISR_NUMBER); to clear any pending interrupts. This too must be called from the callback function. This can be done if you don't want to disable and enable the interrupt every time.

Do let us know if it worked in your case.

Thanks and regards

Hari

0 Likes