Page 1 of 1

Interrupt in Eico40

Posted: Mon Nov 29, 2010 10:24 am
by jgu1
Hi! :roll:

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

Re: Interrupt in Eico40

Posted: Tue Nov 30, 2010 6:14 am
by Dan81
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

Re: Interrupt in Eico40

Posted: Tue Nov 30, 2010 12:03 pm
by jgu1
Hi Dan!

Once again, thank´s. I will make a test. Yesterday I send you one at your private (home) Mail.

Best regard

Re: Interrupt in Eico40

Posted: Tue Nov 30, 2010 12:39 pm
by medelec35
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.

Re: Interrupt in Eico40

Posted: Tue Nov 30, 2010 5:19 pm
by Dan81
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

Re: Interrupt in Eico40

Posted: Tue Nov 30, 2010 5:55 pm
by jgu1
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

Re: Interrupt in Eico40

Posted: Wed Dec 01, 2010 6:50 am
by jgu1
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. :P

Best regard.

jgu1

Re: Interrupt in Eico40

Posted: Wed Dec 01, 2010 9:23 am
by Benj
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.

Re: Interrupt in Eico40

Posted: Wed Dec 01, 2010 1:10 pm
by jgu1
Hi Ben.

Another good suggestion, smart. I tested it later and you hear from me.

Thanks Ben.


jgu1 8)

Re: Interrupt in Eico40

Posted: Wed Dec 01, 2010 1:11 pm
by jgu1
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.

Re: Interrupt in Eico40

Posted: Wed Dec 01, 2010 1:12 pm
by jgu1
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.
[/quote]
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.

Re: Interrupt in Eico40

Posted: Wed Dec 01, 2010 5:06 pm
by Dan81
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

Re: Interrupt in Eico40

Posted: Thu Dec 02, 2010 6:04 am
by jgu1
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

Re: Interrupt in Eico40

Posted: Thu Dec 02, 2010 9:58 am
by Dan81
hello Jorgen

see your PM

Daniel

Re: Interrupt in Eico40

Posted: Thu Dec 02, 2010 4:12 pm
by Dan81
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