Problem with interrupt timer

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Rabbit
Posts: 28
Joined: Wed Apr 04, 2012 1:33 pm
Has thanked: 3 times
Been thanked: 3 times
Contact:

Problem with interrupt timer

Post by Rabbit »

Hello,
The example "Interrupt every second" will not run exact in simulation and at the EB-06.
Simulation: if I change the prescaler rate from 1:256 to 1:16 the LEDs increase in about 1 sec. interval.
EB-06: no action, only LED D0 is lighting constant.

Is my configuration correct? Please look to "PICmicro-Configuration.jpg"
Chip-Freuquency: 19.6608MHz
I have no idea where I have to debug.

Best Regards
Rabbit
Attachments
PICmicro-Configuration.jpg
PICmicro-Configuration.jpg (47.55 KiB) Viewed 5653 times

User avatar
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: Problem with interrupt timer

Post by Benj »

Hello Rabbit,

In your timer interrupt properties please ensure you are selecting the clock source as the CLKI and not the External Input. The timer should then run correctly on the hardware. The simulation speed will probably not be exact but allows you to see how the program should work when it is running at the correct speed on the hardware.

Rabbit
Posts: 28
Joined: Wed Apr 04, 2012 1:33 pm
Has thanked: 3 times
Been thanked: 3 times
Contact:

Re: Problem with interrupt timer

Post by Rabbit »

Hello Ben,
You got it! Many thanks to you. The internal clock (CLKO) is it. Now the program running with correct speed on the hardware.
Only the simulation is very slow.

Many thanks and best regards from Rabbit

mauro
Posts: 8
Joined: Tue Jul 12, 2011 8:09 pm
Has thanked: 41 times
Been thanked: 1 time
Contact:

Re: Problem with interrupt timer

Post by mauro »

Thanx Ben,

Would you please help me resolve the "Uninitialized Variable" in the Error Results window.
Thanx
Mauro
Attachments
Interrupt every second
Interrupt every second
UninitVar.JPG (87.49 KiB) Viewed 5502 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Problem with interrupt timer

Post by medelec35 »

Uninitialized Variables normally only occur if variable is read from before it's written to.

One way to resolve that is to select the variable and Edit type a value in the Initial Value: Box.
uninit1.png
(32.24 KiB) Downloaded 2924 times
Martin
Martin

mauro
Posts: 8
Joined: Tue Jul 12, 2011 8:09 pm
Has thanked: 41 times
Been thanked: 1 time
Contact:

Re: Problem with interrupt timer

Post by mauro »

:D Thank you Martin, all makes good sense now.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Problem with interrupt timer

Post by medelec35 »

No problem.
Glad it makes good sense now. :)

To make things even clearer.

When chip first starts up, unlike Flowcode simulator, all variables are at a random number to start with.

So if you have
Int_Count = Int_Count +1
If Int_Count = 75 then Int_Count = 0

Int_Count could start of with a value of 98 (just as a random number I thought of)

So the other option is to place a variable before the interrupt enable component:
Int_Count=0
So when the 'Int_Count = Int_Count +1' takes place then Int_Count would start off as 0
So again you would not get the message.

Martin
Martin

mauro
Posts: 8
Joined: Tue Jul 12, 2011 8:09 pm
Has thanked: 41 times
Been thanked: 1 time
Contact:

Re: Problem with interrupt timer

Post by mauro »

:lol: Hi Martin,
i have just finished getting rid of those "undesirables" in my flowchart...looks so much better now. I just could not figure it out. All was well and good in V4, then along came V5 with all its new stuff... guess its resistance to change.

Thanx for the great explanation

Mauro

Post Reply