- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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