Interrupt in Eico40
Moderator: Benj
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Interrupt in Eico40
Hi!
I try to make a second counter with an Eico 40th It uses a 48 mhz crystal. I want it as accurate as possible. I naturally use an interrupt, but when I eksambel use, shares 1:256 I get, 183.105 and it does not give an exact division. I know it's possible to use an offset in C Code, is there anyone in this forum who can tell me how it should be by the various divisions of the interrupt or how to calculate this,
1:1= ?
1:2= ?
1:4= ?
1:8= ?
ect,ect.and without to use the 1 sec delay.
Thank´s in advance.
Best regard
Jgu
I try to make a second counter with an Eico 40th It uses a 48 mhz crystal. I want it as accurate as possible. I naturally use an interrupt, but when I eksambel use, shares 1:256 I get, 183.105 and it does not give an exact division. I know it's possible to use an offset in C Code, is there anyone in this forum who can tell me how it should be by the various divisions of the interrupt or how to calculate this,
1:1= ?
1:2= ?
1:4= ?
1:8= ?
ect,ect.and without to use the 1 sec delay.
Thank´s in advance.
Best regard
Jgu
- Attachments
-
- 1SekTest.fcf
- (9 KiB) Downloaded 322 times
- Dan81
- Valued Contributor
- Posts: 268
- Joined: Sun Jan 15, 2006 4:07 pm
- Location: Albi France
- Been thanked: 60 times
- Contact:
Re: Interrupt in Eico40
Hello Jorgen
for TMR0 :
freq(int) = freq(Quartz) / 4 / prediv / N .
N = 256 with Flowcode.
If you want to change frequency, put at the beginning of the interrupt macro a C icon with "tmr0l = Y;" where Y = 256 - X.
see PM
Daniel
for TMR0 :
freq(int) = freq(Quartz) / 4 / prediv / N .
N = 256 with Flowcode.
If you want to change frequency, put at the beginning of the interrupt macro a C icon with "tmr0l = Y;" where Y = 256 - X.
see PM
Daniel
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt in Eico40
Hi Dan!
Once again, thank´s. I will make a test. Yesterday I send you one at your private (home) Mail.
Best regard
Once again, thank´s. I will make a test. Yesterday I send you one at your private (home) Mail.
Best regard
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Interrupt in Eico40
It is not recommended to place component macros which would contain delays them self within an interrupt. or in your case a call macro to update LCD display
If you do not remove the call macro, there would probably be stack corruption issues.
Best way is to set a variable called update for instance = 1 (instead of calling LCD update macro) after a second has elapsed. Then in main.
If update = 1 then update LCD : update = 0
Hope this makes sense.
If you do not remove the call macro, there would probably be stack corruption issues.
Best way is to set a variable called update for instance = 1 (instead of calling LCD update macro) after a second has elapsed. Then in main.
If update = 1 then update LCD : update = 0
Hope this makes sense.
Martin
- Dan81
- Valued Contributor
- Posts: 268
- Joined: Sun Jan 15, 2006 4:07 pm
- Location: Albi France
- Been thanked: 60 times
- Contact:
Re: Interrupt in Eico40
hello Jorgen
for TIMER0, the frequency of the interrupt is (see datasheet of your favorite Pic, chapter Timer0)
For a basic use of Flowcode
f (INT) = f(Quartz) / 4 / (prediv) / 256
If you use C code :
(INT) = f(Quartz) / 4 / (prediv) / X,
you must add at the beginning of the interrupt macro a C icon with " tmr0l = Y ; " with Y = 256 - X .
(note : tmr0l = TMR0L in lower case)
If you are lucky, you can find a whole number N ( N < 255) that gives a whole value for f(INT)
for example N = 125 ; give for ECIO f(int) = 375 Hz.
Add " tmr0l = 131 ; " because 131 = 256 - 125. (without the quotation marks" and don't forget the semi colon at the end).
Your variable "count" must be an integer. (375 > 255)
I hope my explanations are enough clear
If 375 Hz is too quick , you can use TIMER1 (or 2)
Daniel
for TIMER0, the frequency of the interrupt is (see datasheet of your favorite Pic, chapter Timer0)
For a basic use of Flowcode
f (INT) = f(Quartz) / 4 / (prediv) / 256
If you use C code :
(INT) = f(Quartz) / 4 / (prediv) / X,
you must add at the beginning of the interrupt macro a C icon with " tmr0l = Y ; " with Y = 256 - X .
(note : tmr0l = TMR0L in lower case)
If you are lucky, you can find a whole number N ( N < 255) that gives a whole value for f(INT)
for example N = 125 ; give for ECIO f(int) = 375 Hz.
Add " tmr0l = 131 ; " because 131 = 256 - 125. (without the quotation marks" and don't forget the semi colon at the end).
Your variable "count" must be an integer. (375 > 255)
I hope my explanations are enough clear
If 375 Hz is too quick , you can use TIMER1 (or 2)
Daniel
- Attachments
-
- 1SekTest_v3.fcf
- not hard tested
- (13 KiB) Downloaded 308 times
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt in Eico40
Hi both!
Thanks for your reply. I have tried following the instructions, but without success. The problem is that I do not have much experience with processors and their architecture. but trying to learn it.
Right now, I need 1sec, exactly by means of interrupt. I roughly understand how it works, basic. If I use crystal 19660800 mhz. it fits just fine with sharing an integer.
Would one of you be so kind and tell me how Ccode offset timer should be if I Eico uses a 48 mhz crystal and by the different sharing options in Interrupt for Timer0
1:01 = Ccode offset?
1:02 = "?
1:04 = "?
1:08 = "?
1:16 = "?
1:32 = "?
1:64 = "?
1:128 = "?
Or what am I doing in the past eksembel which I've attached to a precise second.
Forecast thanks for helping
Best regard
Jgu1
Thanks for your reply. I have tried following the instructions, but without success. The problem is that I do not have much experience with processors and their architecture. but trying to learn it.
Right now, I need 1sec, exactly by means of interrupt. I roughly understand how it works, basic. If I use crystal 19660800 mhz. it fits just fine with sharing an integer.
Would one of you be so kind and tell me how Ccode offset timer should be if I Eico uses a 48 mhz crystal and by the different sharing options in Interrupt for Timer0
1:01 = Ccode offset?
1:02 = "?
1:04 = "?
1:08 = "?
1:16 = "?
1:32 = "?
1:64 = "?
1:128 = "?
Or what am I doing in the past eksembel which I've attached to a precise second.
Forecast thanks for helping
Best regard
Jgu1
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt in Eico40
Hello again!
Just the explanation as Dan81 came with. That makes sense. Thank you very much.
Where is it nice with the support to get in here.
Best regard.
jgu1
Just the explanation as Dan81 came with. That makes sense. Thank you very much.
Where is it nice with the support to get in here.
Best regard.
jgu1
- 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 in Eico40
Hello,
The MIAC also runs at 48MHz and we have an example demo program that sets up the timer interrupt so that it gives you an exact 1 second count.
You should be able to change the target device via the view -> project options menu.
Then simply remove any calls to the MIAC component before removing the MIAC component from the program.
Let me know if you have any problems.
The MIAC also runs at 48MHz and we have an example demo program that sets up the timer interrupt so that it gives you an exact 1 second count.
You should be able to change the target device via the view -> project options menu.
Then simply remove any calls to the MIAC component before removing the MIAC component from the program.
Let me know if you have any problems.
- Attachments
-
- CLOCK1.fcf
- (9 KiB) Downloaded 315 times
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 in Eico40
Hi Ben.
Another good suggestion, smart. I tested it later and you hear from me.
Thanks Ben.
jgu1
Another good suggestion, smart. I tested it later and you hear from me.
Thanks Ben.
jgu1
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt in Eico40
Benj wrote:Hello,
The MIAC also runs at 48MHz and we have an example demo program that sets up the timer interrupt so that it gives you an exact 1 second count.
You should be able to change the target device via the view -> project options menu.
Then simply remove any calls to the MIAC component before removing the MIAC component from the program.
Let me know if you have any problems.
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt in Eico40
[/quote]jgu1 wrote:"]Hello,
The MIAC also runs at 48MHz and we have an example demo program that sets up the timer interrupt so that it gives you an exact 1 second count.
You should be able to change the target device via the view -> project options menu.
Then simply remove any calls to the MIAC component before removing the MIAC component from the program.
Let me know if you have any problems.
jgu1 wrote:Benj wrote:Hello,
The MIAC also runs at 48MHz and we have an example demo program that sets up the timer interrupt so that it gives you an exact 1 second count.
You should be able to change the target device via the view -> project options menu.
Then simply remove any calls to the MIAC component before removing the MIAC component from the program.
Let me know if you have any problems.
- Dan81
- Valued Contributor
- Posts: 268
- Joined: Sun Jan 15, 2006 4:07 pm
- Location: Albi France
- Been thanked: 60 times
- Contact:
Re: Interrupt in Eico40
Hello Jorgen
What do you mean by " without success" .
I made a test with an ECIO 28pin and I get a led flashing at 1Hz.
The clock seems OK
I can't verify the accuracy.
I don't see the advantage of taking an other prediv than 256.
If you change the prediv to 128 the condition will be count > 750 (375 * 2)
If you want to make a clock, you can take a RTC (like DS1307 for example)
Daniel
What do you mean by " without success" .
I made a test with an ECIO 28pin and I get a led flashing at 1Hz.
The clock seems OK
I can't verify the accuracy.
I don't see the advantage of taking an other prediv than 256.
If you change the prediv to 128 the condition will be count > 750 (375 * 2)
If you want to make a clock, you can take a RTC (like DS1307 for example)
Daniel
- Attachments
-
- clock_interrupt.fcf
- (8.5 KiB) Downloaded 284 times
-
- cligno_interrupt.fcf
- (5.5 KiB) Downloaded 254 times
-
- Posts: 1333
- Joined: Tue Oct 06, 2009 9:39 am
- Has thanked: 1135 times
- Been thanked: 299 times
- Contact:
Re: Interrupt in Eico40
Hi Daniel!
It is a misconception Dan. Your Flow Code works perfectly. I have probably expressed myself incorrectly. But it's me who does not really found out the calculations. But after your explanation I begin to see the light.
Sorry.
And thanks for your new proposal. Them I will also study very carefully
By the way, did you get my mail that I sent to you privately?
Regard
Jgu1
It is a misconception Dan. Your Flow Code works perfectly. I have probably expressed myself incorrectly. But it's me who does not really found out the calculations. But after your explanation I begin to see the light.
Sorry.
And thanks for your new proposal. Them I will also study very carefully
By the way, did you get my mail that I sent to you privately?
Regard
Jgu1
- Dan81
- Valued Contributor
- Posts: 268
- Joined: Sun Jan 15, 2006 4:07 pm
- Location: Albi France
- Been thanked: 60 times
- Contact:
Re: Interrupt in Eico40
Hello Jorgen
I've taken a look at the datasheet of the 18Fx455.
Timer0 can be a 16 bit timer (like Timer1 of many Pic) , so it possible to make a 1second interrupt.
Daniel
I've taken a look at the datasheet of the 18Fx455.
Timer0 can be a 16 bit timer (like Timer1 of many Pic) , so it possible to make a 1second interrupt.
Daniel