Hello
I'm working on a Board which decodes a PPM Signal (Sum-Signal of 12 Servo-Channels).
On the other Side the Board generates 9 Servo-Signals with two Pins connected to a Johnson-Counter. (Reset and Clock)
Johnson Counter: On each positive Edge of the Clock Signal the next Output-Pin goes high and the last Pin goes low...
Each Part of this functions works fine. No Chitter on the measured PPM Signal and also no Chitter on the Servo-Signals.
But when I run both functions at the same Time i have Chitter on the Servo-Signals. The PPM-Signal is decoded correctly and without Chitter.
The PPM-Decoding is realized with Pulse/Period Measuring on TimerB1. (TB1In is connected to the PPM-Signal)
The tb1ic is set to Priority 4.
The PWM-Generation for the Servos is realized with two Timers. B2 and B3.
One ist for the Pulses (1 to 2ms), and the other for the Reset every 22.5ms.
Both have the Interrupt Priority 7
Now I Analyzed the Signals with the Oscilloscope. I saw, that the Chitter occures exactly at the Moment, when the Interrupt of the Decoding is at the same Time of the Interrupt of the PWM.
I Alredy checked, if something with the Priority doesent works, but it works fine. It Jumps from Priority4 Interrupt to a Priority7 Interrupt, but not the other way.
When I stop timberB1 at the Beginning of the PWM-Interrupt, the Chitter is gone, but then the PPM-Decoding doesent works properly anymore. (I think because of the reloading-value on the Start)
Does anyone knows a way to get this Chitter away?
If nothing else works, I alredy thought abaout using the DMA for the Decoding... would this work?
Martin
In general, even when you're using the priority levels, there's a time between "interrupt happens" and "interrupts are re-enabled" that you can only minimize, but not eliminate together. Make sure re-enabling interrupts is the very first thing your low-priority ISR does.
If I understand you correct:
If a Interrupt is running (even with priority 7) and another Interrupt happens (Interrupt 4). There is a schort waiting-time before the Priority7 Interrupt continious running?
What happens if I disable all Interrupts with "asm("fclr I");" at the beginning of the Prio7 Interrupt and re-enable it with "asm("fset I");" at the End of the Prio7 Interrupt.
Or explained otherwise: I tried it that way, and it didn't worked...
Why is there a glitch, even no Interrupts are enabled...
Ah yes, and the Glitch is about 100us... But the R32C111 runs with 50MHz CPU-Clock and 25MHz Peripherial-Clock...
No, I meant, if a low-priority interrupt happens, and the next clock cycle a high-priority interrupt happens, the high-priority one won't interrupt the low priority one until you re-enable interrupts (fset I).
100 uS? That's very long for an R32C. If your handlers don't even take that long, I'd look at how you're configuring the hardware - you might be missing an interrupt completely, or programming the hardware wrong. I don't use R32C, so I can't help there.
No Problem...
I just look for more Ideas, where the devil is hiding...
I'm mostly shure, the Hardware is initialized correct. Since I set the ***** PRC Register before setting the PLL, everything works really fine... All Timings are pretty exact and so on...
But this Interrupt problem is very annoying!
Hm... it would surprise me a little bit, but if I understand you right, I have to re-enable Global Interrupts in a Interrupt...
That means, when a lvl4 Interrupt happens, it runs to Its End before another (lvl7) Interrupt can start. Except I re-enable global Interrupts in the running Interrupt?
That would explain all the Problems, but it would be really new to me!
There are (or should be) two "enablers" for interrupts - the global enable flag, and the interrupt priority. If the global interrupt flag is not set, NO interrupts happen, regardless of the priority. If the global flag is set, only interrupts higher than the interrupt priority happen.
So yes, in your interrupt handler you should re-enable interrupts if you want higher priority interrupts to happen.
You should also read the chip-specific documentation on interrupt priorities.
Well... it works :-)
That part with the re-enabling of the Global Interrupts at the beginning of an Interrupt was really new to me. I don't remember, that I saw such thing anytime on another Microcontroller...
But its ok... Its just good, that I know it now.
I also found the part in the documentations now.
Thanx very much for helping!