Is it a good idea to use multiple interrupts in one project?
- I want to use a timer for longer periods (1 minute) and want to accomplish this with a timer interrupt.
- I need an interrupt on a UART RX change
- I want one on a IO port change
- And I think I would need another one.
Is it a good idea to use more than one interrupt?
Some of the interrupts would be disabled in the flowchart and enabled later on.
Is that a good idea, enable and disable them while the program is running?
Or is this a recipe for problems?
So two questions:
- Multiple interrupts in one program: good idea?
- Enable/disable interrupts on the fly: good idea?
Multiple interupts at a time: good idea or not?
Moderator: Benj
- 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: Multiple interupts at a time: good idea or not?
Hello,
As with most things the answer is it's complicated. However yes in most cases multiple interrupts and disabling / re-enabling interrupts is absolutely fine.
The one thing you can't do is change the macro assigned to a specific interrupt. We have a compile error message in place should you try to do this.
As with most things the answer is it's complicated. However yes in most cases multiple interrupts and disabling / re-enabling interrupts is absolutely fine.
The one thing you can't do is change the macro assigned to a specific interrupt. We have a compile error message in place should you try to do this.
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
- celebriums
- Posts: 125
- Joined: Sun Sep 25, 2016 3:50 pm
- Has thanked: 71 times
- Been thanked: 33 times
- Contact:
Re: Multiple interupts at a time: good idea or not?
Dear Ben,
Greetings to everyone from Turkey.
I hope you are fine.
I often have problems with this.
Problem 1
The 2nd interrupt does not work on most 8-bit processors (except the PIC18 family).!!!!
I am setting the OSC Tune correctly. If OSC Tune is not set, no function is already running.
A non-functioning Interrupt is usually a UART Interrupt.
HS, XT crystal necessarily have to use.
but Correct working condition of 2 interrupts,
(Reading the UART should definitely be inside the Main While Cycle !!!!!)
2. Problem
For 8-bit processors, if Internal oscillator is selected; UART is not working correctly.
I've had problems recently.
I am setting the OSC Tune correctly. If OSC Tune is not set, no function is already running.
Correct working condition of 2 interrupts,
When 20 Mhz (HS) fundemental crystals were used, everything returned to normal.
(Reading the UART should definitely be inside the Main While Cycle !!!!!)
3. Problem
16 and 32-bit processors;
UART and TMR Interrupti are working at the same time,
Everything is normal and stable in EC, HS and XT.
You can easily use more than one interrupt.
But
I am doing Time Management with TMR,
I always calculate the length of the process step.
Otherwise, problems may occur.
Especially for CANBUS, RS485 and UART
However, if INT OSC is selected, it does not work!!!!
I don't think these problems are caused by the processor.
Greetings to everyone from Turkey.
I hope you are fine.
I often have problems with this.
Problem 1
The 2nd interrupt does not work on most 8-bit processors (except the PIC18 family).!!!!
I am setting the OSC Tune correctly. If OSC Tune is not set, no function is already running.
A non-functioning Interrupt is usually a UART Interrupt.
HS, XT crystal necessarily have to use.
but Correct working condition of 2 interrupts,
(Reading the UART should definitely be inside the Main While Cycle !!!!!)
2. Problem
For 8-bit processors, if Internal oscillator is selected; UART is not working correctly.
I've had problems recently.
I am setting the OSC Tune correctly. If OSC Tune is not set, no function is already running.
Correct working condition of 2 interrupts,
When 20 Mhz (HS) fundemental crystals were used, everything returned to normal.
(Reading the UART should definitely be inside the Main While Cycle !!!!!)
3. Problem
16 and 32-bit processors;
UART and TMR Interrupti are working at the same time,
Everything is normal and stable in EC, HS and XT.
You can easily use more than one interrupt.
But
I am doing Time Management with TMR,
I always calculate the length of the process step.
Otherwise, problems may occur.
Especially for CANBUS, RS485 and UART
However, if INT OSC is selected, it does not work!!!!
I don't think these problems are caused by the processor.
-
- Valued Contributor
- Posts: 652
- Joined: Fri Jun 06, 2014 3:53 pm
- Has thanked: 184 times
- Been thanked: 202 times
- Contact:
Re: Multiple interupts at a time: good idea or not?
Hi Sadik
I often use 8-bit PICs running on Internal Oscillator and the UART component without issue (typically Baud of 9600). Normally I have the RxInt enabled that branches to a macro that then reads the UART and fills a Circular Buffer. Processing of the CB is done in the Main Loop as-and-when.
I also have multiple interrupts running concurrently (in most cases IOC on pin(s)) without too much issue. Certain chips can prioritise interrupts but if a chip cannot and there is a danger of interrupts conflicting, it is a simple matter to disable interrupts as the first step in your interrupt handling macro and then re-enable once complete.
Hope this is of interest.
I often use 8-bit PICs running on Internal Oscillator and the UART component without issue (typically Baud of 9600). Normally I have the RxInt enabled that branches to a macro that then reads the UART and fills a Circular Buffer. Processing of the CB is done in the Main Loop as-and-when.
I also have multiple interrupts running concurrently (in most cases IOC on pin(s)) without too much issue. Certain chips can prioritise interrupts but if a chip cannot and there is a danger of interrupts conflicting, it is a simple matter to disable interrupts as the first step in your interrupt handling macro and then re-enable once complete.
Hope this is of interest.
- celebriums
- Posts: 125
- Joined: Sun Sep 25, 2016 3:50 pm
- Has thanked: 71 times
- Been thanked: 33 times
- Contact:
Re: Multiple interupts at a time: good idea or not?
Hello chipfryer27
Thanks for messages.
Using INT OSC with the PIC18F series, you can communicate with 9600 baudrate in UART communication.
This is true, but;
At 19200, 38400 and higher, have you experimented?
Thanks for messages.
Using INT OSC with the PIC18F series, you can communicate with 9600 baudrate in UART communication.
This is true, but;
At 19200, 38400 and higher, have you experimented?
chipfryer27 wrote:Hi Sadik
I often use 8-bit PICs running on Internal Oscillator and the UART component without issue (typically Baud of 9600). Normally I have the RxInt enabled that branches to a macro that then reads the UART and fills a Circular Buffer. Processing of the CB is done in the Main Loop as-and-when.
I also have multiple interrupts running concurrently (in most cases IOC on pin(s)) without too much issue. Certain chips can prioritise interrupts but if a chip cannot and there is a danger of interrupts conflicting, it is a simple matter to disable interrupts as the first step in your interrupt handling macro and then re-enable once complete.
Hope this is of interest.
-
- Valued Contributor
- Posts: 652
- Joined: Fri Jun 06, 2014 3:53 pm
- Has thanked: 184 times
- Been thanked: 202 times
- Contact:
Re: Multiple interupts at a time: good idea or not?
Hi Sadik
I've only used 115200 over a very short distance (a couple of cm) and mainly to change the default rate of the device down to 9600 using "AT's". I simply don't need anything faster. I can imagine though that you may need to "tune" the oscillator for higher speeds and there are posts regarding this in the forum.
Now you have my interest piqued and when I'm back I will probably experiment with higher speeds "just because"
I have some fun times ahead
Regards
I've only used 115200 over a very short distance (a couple of cm) and mainly to change the default rate of the device down to 9600 using "AT's". I simply don't need anything faster. I can imagine though that you may need to "tune" the oscillator for higher speeds and there are posts regarding this in the forum.
Now you have my interest piqued and when I'm back I will probably experiment with higher speeds "just because"
I have some fun times ahead
Regards
- celebriums
- Posts: 125
- Joined: Sun Sep 25, 2016 3:50 pm
- Has thanked: 71 times
- Been thanked: 33 times
- Contact:
-
- Valued Contributor
- Posts: 652
- Joined: Fri Jun 06, 2014 3:53 pm
- Has thanked: 184 times
- Been thanked: 202 times
- Contact:
Re: Multiple interupts at a time: good idea or not?
Hi Sadik
I travel a lot but so looking forward to experimenting with this. Never having a real "need for speed" the issue of Int Osc has never came up in my snail paced world.
I will update the post with the results of my tinkering
Might be a week or two though.
Regards
I travel a lot but so looking forward to experimenting with this. Never having a real "need for speed" the issue of Int Osc has never came up in my snail paced world.
I will update the post with the results of my tinkering
Might be a week or two though.
Regards