This is a funny one.
I'm seeing erratic lcd behaviour (jumping cursor, non-alphabetic characters) after a few minutes of running my program. I'm tracking an encoder with ioc and then start a clock for debouncing. Any of those interrups may occur while writing to the lcd, and I have a hunch that upsets it, but so far no hard evidence as to the cause. It works correctly while simulating. I've cut the program down to just the encoder stuff and the lcd writing.
Interestingly, sometimes it displays random-looking characters or strings, sometimes again displays the log-on message that I display at start-up. It looks as if there is a mix up in a jump or return stack within the lcd routines when interrupted.
Is that a valid possibility? Any tips how I can test that?
thanks,
jan didden
LCD write corrupted by interrupts?
Moderator: Benj
- 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: LCD write corrupted by interrupts?
Hello Jan
If you have a LCD clear somewhere in your main loop then changing this to a start may help you to eliminate any corruption as it starts to happen.
Are you calling any of the LCD routines from your interrupts? This could be what is causing the adverse effects. Instead you could set a flag variable in the interrupt and then service the flag in your main routine.
If you have a LCD clear somewhere in your main loop then changing this to a start may help you to eliminate any corruption as it starts to happen.
Are you calling any of the LCD routines from your interrupts? This could be what is causing the adverse effects. Instead you could set a flag variable in the interrupt and then service the flag in your main routine.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Flowcode v5 User
- Posts: 273
- Joined: Thu Apr 17, 2008 9:59 am
- Has thanked: 19 times
- Been thanked: 16 times
Re: LCD write corrupted by interrupts?
Yes, if I do a start/clear just prior to a write, it clears the junk and gets back to normal. But that's no real solution of course.
I do set a couple of flags at interrupt and process them later, trying to keep interrupt processing to a minimum.
There is something to these interrupts. I tried, in the same program, to use TMR1 as a low speed interrupt for some led indicating functions. Program starts up and hangs immediately without any user action, even with the interrupt service routine doing nothing, just entering and leaving again. Then I changed the timer to TMR2, and it works. Weird.
jan didden
I do set a couple of flags at interrupt and process them later, trying to keep interrupt processing to a minimum.
There is something to these interrupts. I tried, in the same program, to use TMR1 as a low speed interrupt for some led indicating functions. Program starts up and hangs immediately without any user action, even with the interrupt service routine doing nothing, just entering and leaving again. Then I changed the timer to TMR2, and it works. Weird.
jan didden
-
- Flowcode v5 User
- Posts: 273
- Joined: Thu Apr 17, 2008 9:59 am
- Has thanked: 19 times
- Been thanked: 16 times
Re: LCD write corrupted by interrupts?
Hello Ben, just thought about something.
If an interrupt occurs, there's a central dispatcher determining which type of int it was and transferring execution accordingly.
What would happen if an interrupt occured while the dispatcher (or the int specific code) was being executed? Is that stuff reentrant?
thanks,
jan didden
If an interrupt occurs, there's a central dispatcher determining which type of int it was and transferring execution accordingly.
What would happen if an interrupt occured while the dispatcher (or the int specific code) was being executed? Is that stuff reentrant?
thanks,
jan didden