Interrupt Arduino Uno
Moderator: Benj
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Interrupt Arduino Uno
Hi!
Sorry it´s me Again, but as you see I use FC a lot.
In a project where I need to make an interrupt, I discovered that the delay is twice as long as specified when the macro is calling interrupt. Is it correct??
If I make delay in the main loop and not using interrupt fit value as it should.
Best rgard
Jorgen
Sorry it´s me Again, but as you see I use FC a lot.
In a project where I need to make an interrupt, I discovered that the delay is twice as long as specified when the macro is calling interrupt. Is it correct??
If I make delay in the main loop and not using interrupt fit value as it should.
Best rgard
Jorgen
- Attachments
-
- Smeden.fcfx
- (5.48 KiB) Downloaded 276 times
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Interrupt Arduino Uno
I apologize if I point you in a wrong direction as I am not and AVR user however the symptom you describe point for me in the direction that you enter and incorrect Oscilator frequency or your oscillator is not running at the speed you think it is runningjgu1 wrote: discovered that the delay is twice as long as specified when the macro is calling interrupt.
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt Arduino Uno
Hi!
Ok this could be misunderstod, but I mean, The delay (500mS) I use in the delay, macro called by interrupt, is, when I compile to Arduino (in real World) 1000mS
But if I make a program without interrupt, switch an output on and off in mainloop with a delay 500mS then it is 500mS in real world.
the oscillolator freq. is default 16Mhz and is not possible to change on an Arduino.
Hope it make sense?
Ok this could be misunderstod, but I mean, The delay (500mS) I use in the delay, macro called by interrupt, is, when I compile to Arduino (in real World) 1000mS
But if I make a program without interrupt, switch an output on and off in mainloop with a delay 500mS then it is 500mS in real world.
the oscillolator freq. is default 16Mhz and is not possible to change on an Arduino.
Hope it make sense?
Last edited by jgu1 on Fri Oct 10, 2014 9:23 pm, edited 1 time in total.
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Interrupt Arduino Uno
I would like to help you more however I have no clue how the AVR Interrupt mechanism is setup which I expect a person should know to be of help to you
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt Arduino Uno
I´m sure that some of the "hard Guys" here know something and can help me as usual
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: Interrupt Arduino Uno
Hi
Try the attached chart, basically at 16mhz a count of 31(ish) will = 1/2 sec , so one int triggered ,it counts switches on led and off at end of copunt, its not the tidiest chart but try it and let us know if it works for you
Regards
Dazz
Try the attached chart, basically at 16mhz a count of 31(ish) will = 1/2 sec , so one int triggered ,it counts switches on led and off at end of copunt, its not the tidiest chart but try it and let us know if it works for you
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt Arduino Uno
Hi Dazz
Many thanks for your example. I know the method you make, but this is not the issue . There are many ways to do it.
This what surprised me is if you use a delay in a macro which is triggered by an interrupt so is time for delay function I use in the macro called by interrupt, twice as long as I have set, eg. 500 mS in FC becomes 1 second in Real World. If I use a delay function in a loop without interrupt, then the delaytime is ok. And my question is, is a Delay set to 500mS = 500mS no matter where I use it or maybe some special explanation if I use it in an interrupt or is it not correct to use Delay in a macro called by interrupt.
Best regard
Jorgen.
Many thanks for your example. I know the method you make, but this is not the issue . There are many ways to do it.
This what surprised me is if you use a delay in a macro which is triggered by an interrupt so is time for delay function I use in the macro called by interrupt, twice as long as I have set, eg. 500 mS in FC becomes 1 second in Real World. If I use a delay function in a loop without interrupt, then the delaytime is ok. And my question is, is a Delay set to 500mS = 500mS no matter where I use it or maybe some special explanation if I use it in an interrupt or is it not correct to use Delay in a macro called by interrupt.
Best regard
Jorgen.
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: Interrupt Arduino Uno
Hi
All i know is if you place a delay in an interupt it will cause issues like you are getting, which is why its better to use a count like in the chart i did,
hope that helps
Regards
Dazz
All i know is if you place a delay in an interupt it will cause issues like you are getting, which is why its better to use a count like in the chart i did,
hope that helps
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Interrupt Arduino Uno
jgu1 wrote:
When I change to a PIC16FXX It work´s
Yes because PIC's are great Micro's Hope you get it working on your AVR
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt Arduino Uno
Hi QMESAR!
Yes, it´s also a good device I like your sense of humor
I hope some of "tough guy´s" from MM WHO make flowcode can tell me what´s wrong.
Have a nice sunday.
Jorgen
Yes, it´s also a good device I like your sense of humor
I hope some of "tough guy´s" from MM WHO make flowcode can tell me what´s wrong.
Have a nice sunday.
Jorgen
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Interrupt Arduino Uno
Jorgen have good time
I am sure some one of Matrix will help you on Monday
I am sure some one of Matrix will help you on Monday
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt Arduino Uno
Hi Dazz!
For info: I make a test with your program. Your delay is max 50mS, should be 500mS, so something is wrong.
Jorgen
For info: I make a test with your program. Your delay is max 50mS, should be 500mS, so something is wrong.
Jorgen
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: Interrupt Arduino Uno
Hi jorgen
i got my sums wrong it should have been 31250 i think, was tired yesterdat sorry
Regards
Dazz
i got my sums wrong it should have been 31250 i think, was tired yesterdat sorry
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt Arduino Uno
Hi Dazz!
No sorry, I should see this by my self
I will try change and then try. But anyway, I think something is wrong. Thank´s Dazz
Jorgen
No sorry, I should see this by my self
I will try change and then try. But anyway, I think something is wrong. Thank´s Dazz
Jorgen
- 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: Interrupt Arduino Uno
Hello,
The only thing I can think of looking at your original program is that the 1ms delay from the main is interfering with the 500ms delay from the interrupt and causing stack corruption. If you get rid of the 1ms delay in the main loop does this help at all?
The only thing I can think of looking at your original program is that the 1ms delay from the main is interfering with the 500ms delay from the interrupt and causing stack corruption. If you get rid of the 1ms delay in the main loop does this help at all?
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: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt Arduino Uno
Hi Ben!
Sorry Ben, but I have tryed to remove the 1mS from main, and try to increase the value, but no matter. And still, if I use a Pic16fXX it´s ok. Hope you will investigate some more????
But anyway, in ver.6.1 when I use Arduino, with the new "Automatic setting´s for the port", easy and work´s fine, good job
Best regard
Jorgen
Sorry Ben, but I have tryed to remove the 1mS from main, and try to increase the value, but no matter. And still, if I use a Pic16fXX it´s ok. Hope you will investigate some more????
But anyway, in ver.6.1 when I use Arduino, with the new "Automatic setting´s for the port", easy and work´s fine, good job
Best regard
Jorgen