Page 1 of 1
INT TMR0 or simulation problem
Posted: Fri Jun 19, 2009 5:38 pm
by ITISVARESE
This simple flowchart must toogle led on or off for 1 second; when i simule it in flowccide V4
time of lightining is missing.
Code in real world work ok.
Re: INT TMR0 or simulation problem
Posted: Sat Jun 20, 2009 10:23 am
by medelec35
I agree the simulation for TMR0 has a bug and is not working, and your program is working.
One general point on interrupts and accuracy.
If accuracy is important, then you need to select a prescaler rate that is as close to a whole number as you can get.
Then set the decision for greater than 1 number less than this whole number.
E.g. Assuming 4MHz internal Osc is accurate.
With your settings of prescaler rate = 1:128. The interrupt will call your INT_TMRO macro 30.5 times every second since that is the interrupt frequency. Since a macro cannot be called for a number fraction times i.e. you can call macro once, but you can't call a macro more than 0 and less than once (e.g 1/2), so there will be small errors if interrupt frequency is not a whole number.
Since the Entrate Decision is set for 33, then the yes branch will followed every 1.081 seconds. (if you set Entrate for >30 or set to =31 then yes branch will followed every 1.016 seconds)
If you change prescaler rate to 1:64. The interrupt will call your INT_TMRO macro 61.035 times every second
change Entrate Decision to >60 then yes branch will followed every 0.999 seconds.
Re: INT TMR0 or simulation problem
Posted: Sat Jun 20, 2009 10:31 am
by ITISVARESE
Thank for Your reply,
i agree and know what You says but it is only a sample to test simulation interrupt in V4
and not a really work; i want a confirm that problem is in V4.
Re: INT TMR0 or simulation problem
Posted: Sat Jun 20, 2009 11:20 am
by medelec35
Your welcome. Yes problem is in V4 simulation only as stated in previous post
The information I posted is aimed at any one who is using timer interrupt for the first time, or not 100% sure how it works.
I was not sure if you did or not.