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.
I am again, try and use the interrupt hours2 in a study. I made this second count. Although I have copied Martin's FC in a previous project, I can not get the time to fit exactly. When I compare with the stopwatch, it looks like the counter lose time when it flip over from 59 to 00. What am I doing wrong?
You are doing a lot in the interrupt code, including updating the LCD. What if the interrupt code just added 1, and the rest of the code was in a different macro that was called from within the loop?
It is important that you do not place any delays or components that will have delays in like LCD displays ,RS232 etc within timer interrupts. Keep interrupt macros as short as possible.
Components like LEDs and calculation icons are OK to use.
If you do use delays which lasts for longer than the timer interrupt takes to trigger, then corruption will occur giving unexpected results.
If you want to update a LCD display after an interrupt has occurred, then set a flag to 1 within interrupt. E.g. update_lcd=1
then for your LCD have a decision branch E.g
If lcd=1 then display macros : lcd=0
It is important that you do not place any delays or components that will have delays in like LCD displays ,RS232 etc within timer interrupts. Keep interrupt macros as short as possible.
Components like LEDs and calculation icons are OK to use.
If you do use delays which lasts for longer than the timer interrupt takes to trigger, then corruption will occur giving unexpected results.
If you want to update a LCD display after an interrupt has occurred, then set a flag to 1 within interrupt. E.g. update_lcd=1
then for your LCD have a decision branch E.g
If lcd=1 then display macros : lcd=0
Martin
In the code provided by the OP it appears that the LCD update happens once per second, and there is already code to check for that. The problem was that all of the code was in the interrupt routine, and as you pointed out, that is not a good idea.