Page 1 of 1
something wrong with timeroverflow interruptions
Posted: Wed Jan 29, 2014 1:30 pm
by ALOPEZ
Hello Benj,
I have some problems(hardware, simulations runs perfect) with programas that manage lcd and timeroverflow interruptions.
Please find attach this program. when i activate interruption, interruption works ok, i can see D0 in the osciloscope. But lcd doens't print right in the hardware.
when i deactivated interrupcion LCD hardware works perfect.
what it can be?
Re: something wrong with timeroverflow interruptions
Posted: Wed Jan 29, 2014 1:37 pm
by Benj
Hello,
It sounds like the interrupt may be messing up the bit banged signals to the LCD though this seems odd.
One thing to try would be to remove the 1ms delay from the timer interrupt and instead set a variable. Check the variable as part of your main loop and if it is set then set the pin, wait the millisecond and clear it again. This way the toggling pin cannot effect the LCD operations.
Re: something wrong with timeroverflow interruptions
Posted: Wed Jan 29, 2014 3:23 pm
by ALOPEZ
Hello Benj,
Seems to my that you can't use delay box in the main program and in the interruption.
PLease find attach this program. You can't see if there is just one delay (in interruption or main program) program works ok. but if you try to use delay in program and interruption, seems delay sub rutine get broke.
should be nice have the possibility to use delay fuction in program and interruption.
thanks for your fast answer.
Re: something wrong with timeroverflow interruptions
Posted: Wed Jan 29, 2014 4:28 pm
by Benj
Aha yes there is millisecond delays used by the LCD so I suppose if you go back into the delay function via an interrupt while the main loop is inside a delay then the LCD will likely get corrupted.
Delays inside an interrupt are not recommended. What about you have an interrupt, set the pin then re-enable the interrupt for 1ms time and then when you interrupt again switch the output pin back off. This way you don't have to use delays and your interrupt code will be a lot more efficient.