tmr interrupts
Moderator: Benj
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
tmr interrupts
wanted to start a thread to see the proper way of using the tmr interrupts so they wont effect the loop....first off the compiler complains when i enable a tmr interrupt then disable it, how can i get around this? how can the tmr be used and not effect the loop(jitter) ....how many tmr interrupts would be acceptable to use as a max number per chip? .... if setting one up at 1k what should i set the other ones to so there is no conflicts of missing events? and stuff like that!.... basicly i've been using port,int,tmr0,1,2 interrupts for months now and want to see where the loop holes are in my designs and where i should stay clear for PROPER USE OF TMR0,1,2
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: tmr interrupts
Hello,
If two interrupts are triggered at once then one will be serviced followed by the other. You shouldn't miss any interrupts unless one is triggered while in a disabled state.
Is this the warning about re-enabling the macro using a different Flowcode macro? If so then this is simply saying that if you re-enable the interrupt using a different Flowcode macro then only the first macro you selected will get called.first off the compiler complains when i enable a tmr interrupt then disable it
If two interrupts are triggered at once then one will be serviced followed by the other. You shouldn't miss any interrupts unless one is triggered while in a disabled state.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: tmr interrupts
Hi Ben, It is my understanding that if an interrupt is triggered while in disable state its placed in a type of queue, then as soon as interrupt is re-enabled then the interrupt in the queue is then instantly triggered.Benj wrote:You shouldn't miss any interrupts unless one is triggered while in a disabled state.
Would you mind clarifying that for me please?
Martin
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: tmr interrupts
Hello,
Each interrupt is generally governed by an interrupt enable flag and an interrupt pending flag.
The interrupt enable flag is controlled using the Flowcode interrupt icons.
The interrupt pending flag is controlled by the peripheral, eg timer timeout or UART byte received.
Each interrupt is generally governed by an interrupt enable flag and an interrupt pending flag.
The interrupt enable flag is controlled using the Flowcode interrupt icons.
The interrupt pending flag is controlled by the peripheral, eg timer timeout or UART byte received.
This is correct but as there is only one pending flag you only get the one interrupt being stored while the interrupt itself is disabled. If the pending flag gets reset eg during the re-enable process then this could cause an interrupt to be missed after it has been re-enabled.It is my understanding that if an interrupt is triggered while in disable state its placed in a type of queue, then as soon as interrupt is re-enabled then the interrupt in the queue is then instantly triggered.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
Re: tmr interrupts
i dont understand this? what i was hoping to do somehow is enable a tmro interrupt only when the switches are pressed then disable when switches are not pressed because the program im using while the tmr is active it makes the output jitter.... is it possible to do this?Is this the warning about re-enabling the macro using a different Flowcode macro? If so then this is simply saying that if you re-enable the interrupt using a different Flowcode macro then only the first macro you selected will get called.
- Attachments
-
- lut making better(v3) tmr0 2 speed scroll.fcf
- (46.88 KiB) Downloaded 270 times
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
Re: tmr interrupts
something im curious about--> if im using 3 tmr0,1,2 (all three timers) and i set them all to 61 hz i dont see how this could work since all three would be running through macro at the same time but program could only process one, am i missing anything, what would be the correct way of doing this? and reasoning behind it
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: tmr interrupts
Hello,
On a 8-bit PIC using multiple interrupts without priority settings you basically service each interrupt as it requests attention. eg if timer 0, 1 and 2 all interrupted at exactly the same time then the code would service timer 0, followed by timer 1 and finishing with timer 2. Otherwise the timer that interrupted first would be serviced first.
Some chips allow you to prioritise the interrupts allowing you to control which interrupts are more important and require servicing first.
On a 8-bit PIC using multiple interrupts without priority settings you basically service each interrupt as it requests attention. eg if timer 0, 1 and 2 all interrupted at exactly the same time then the code would service timer 0, followed by timer 1 and finishing with timer 2. Otherwise the timer that interrupted first would be serviced first.
Some chips allow you to prioritise the interrupts allowing you to control which interrupts are more important and require servicing first.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
Re: tmr interrupts
thanks ben, to clearify, no matter what frequencies i use i will never mis a timer based interrupt, why would this happen in a nutshell?.....what about port or int interrupts, so if i have 3 timers going at same or different frequecies and have a couple port interrupts at the same time what would happen here? ..... is there any write ups that explain how all this works, i would like to understand it so i dont get my self in trouble
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: tmr interrupts
Hello,
The only time you might miss a timer interrupt is if you are still executing code in the service macro when the next interrupt occurs. That is why it is common practice to get out of the service macro as quickly as possible and execute as much of the code as possible as part of the main.
You should be fine really, have a play with the interrupts and see what's possible. I have created programs using timer and signal based interrupts all tightly interwoven around each other for my propeller display and not really experienced any significant problems.
[/youtube]
Flickering is only picked up by camera. to the eye you get a static image. Flickering is good to show how its working, only ever 1 segment on at a time.
The only time you might miss a timer interrupt is if you are still executing code in the service macro when the next interrupt occurs. That is why it is common practice to get out of the service macro as quickly as possible and execute as much of the code as possible as part of the main.
You should be fine really, have a play with the interrupts and see what's possible. I have created programs using timer and signal based interrupts all tightly interwoven around each other for my propeller display and not really experienced any significant problems.
[/youtube]
Flickering is only picked up by camera. to the eye you get a static image. Flickering is good to show how its working, only ever 1 segment on at a time.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel