Interrupt in Eico40

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

jgu1
Posts: 1176
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1102 times
Been thanked: 294 times
Contact:

Interrupt in Eico40

Postby jgu1 » Mon Nov 29, 2010 10:24 am

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
Attachments
1SekTest.fcf
(9 KiB) Downloaded 141 times

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: Interrupt in Eico40

Postby Dan81 » Tue Nov 30, 2010 6:14 am

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

jgu1
Posts: 1176
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1102 times
Been thanked: 294 times
Contact:

Re: Interrupt in Eico40

Postby jgu1 » Tue Nov 30, 2010 12:03 pm

Hi Dan!

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

Best regard

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8816
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2559 times
Been thanked: 3715 times
Contact:

Re: Interrupt in Eico40

Postby medelec35 » Tue Nov 30, 2010 12:39 pm

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.
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: Interrupt in Eico40

Postby Dan81 » Tue Nov 30, 2010 5:19 pm

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
Attachments
1SekTest_v3.fcf
not hard tested
(13 KiB) Downloaded 132 times
These users thanked the author Dan81 for the post:
jgu1 (Wed Dec 01, 2010 5:58 am)
Rating: 5%
 

jgu1
Posts: 1176
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1102 times
Been thanked: 294 times
Contact:

Re: Interrupt in Eico40

Postby jgu1 » Tue Nov 30, 2010 5:55 pm

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

jgu1
Posts: 1176
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1102 times
Been thanked: 294 times
Contact:

Re: Interrupt in Eico40

Postby jgu1 » Wed Dec 01, 2010 6:50 am

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

User avatar
Benj
Matrix Staff
Posts: 14790
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4752 times
Been thanked: 4358 times
Contact:

Re: Interrupt in Eico40

Postby Benj » Wed Dec 01, 2010 9:23 am

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.
Attachments
CLOCK1.fcf
(9 KiB) Downloaded 138 times

jgu1
Posts: 1176
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1102 times
Been thanked: 294 times
Contact:

Re: Interrupt in Eico40

Postby jgu1 » Wed Dec 01, 2010 1:10 pm

Hi Ben.

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

Thanks Ben.


jgu1 8)

jgu1
Posts: 1176
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1102 times
Been thanked: 294 times
Contact:

Re: Interrupt in Eico40

Postby jgu1 » Wed Dec 01, 2010 1:11 pm

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.

jgu1
Posts: 1176
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1102 times
Been thanked: 294 times
Contact:

Re: Interrupt in Eico40

Postby jgu1 » Wed Dec 01, 2010 1:12 pm

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.

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: Interrupt in Eico40

Postby Dan81 » Wed Dec 01, 2010 5:06 pm

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
Attachments
clock_interrupt.fcf
(8.5 KiB) Downloaded 115 times
cligno_interrupt.fcf
(5.5 KiB) Downloaded 101 times

jgu1
Posts: 1176
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1102 times
Been thanked: 294 times
Contact:

Re: Interrupt in Eico40

Postby jgu1 » Thu Dec 02, 2010 6:04 am

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

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: Interrupt in Eico40

Postby Dan81 » Thu Dec 02, 2010 9:58 am

hello Jorgen

see your PM

Daniel

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: Interrupt in Eico40

Postby Dan81 » Thu Dec 02, 2010 4:12 pm

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