PDA

View Full Version : LCDOUT & interrupts



lab310
- 7th April 2005, 14:24
How much time does typical LCDOUT (for example LCDOUT $fe,1,"HELLO WORLD !!!" ) takes ? I always get problem when using interrupts and LCDOUT. Is there a simple way to overcome this ?

Darrel Taylor
- 7th April 2005, 22:35
The LCDOUT is pretty fast. It really depends on the DEFINES for the LCD.

Each character takes 10-15 us to set up, then the program will wait an amount of time determined by the "DEFINE LCD_DATAUS" statement. It defaults to 50uS if no DEFINE is supplied.

Commands like Clear screen, or home cursor take longer. And are controlled by "DEFINE LCD_COMMANDUS" which defaults to 2000uS.

However, LCD data is clocked out synchronously. This means that it will not be affected by interrupts. At least not by interrupt routines that behave properly.

What kind of interrupts are you using. ON INTERRUPT, or ASM interrupts?

Can you post the code?

Darrel

lab310
- 8th April 2005, 09:51
All my interrupt routines are ASM, ON INTERRUPT won't do as I need a REAL interrupts , not "I'll do it if I can" type. I'm sure that they are properly writen, they work fine if I don't utilise LCD. My interrupts are pretty fast, always in range of 200-1000 us and execute in couple of us. Problems manifests as displaying garbage on LCD, missing lines or some strange thing as shifting entire lcd to left or freezing it completly. Few time it even managed to reset PIC (had to increase WDT prescaler by far to get read of this).

I didn't know that commands take such long time (2000us). Is this a time to PIC to issue or LCD to process command? If second, I could manage to to overcome this. If first, it is the problem since my interrupt vould cut this command several times during execution.

Melanie
- 8th April 2005, 10:30
Are you remembering to SAVE all your registers and pointers BEFORE executing your Interrupt? Are you RESTORING everything back to the way it was BEFORE you leave your interrupt? quote: "My interrupts are pretty fast... and execute in couple of us." Somehow from your statement I don't think you're doing all the required housekeeping.

PICBasic's LCD Routine is in the middle of transferring half a byte (or command) to the LCD when your interrupt pops-up, tears it away from what it's doing, and then returns it an indeterminate time later supposedly to carry on from where it left off. Will the LCD routine still find all the registers EXACTLY the way it EXPECTS to have them? Have you interfered with a critical timing operation? Have you double-checked with the Hitachi Controller manual to see you're not comitting any sins?

Sometimes there are CRITICAL operations that must be completed BEFORE you go and do something else. Go study and understand the LCD code before you blindly go interrupting it. There are rules for interrupts.

cupajoe
- 8th April 2005, 11:59
I know that this isn't going to be very helpful but I use ASM interrupts with an LCD alot and I don't have any problems. I would check you're context saving as Melanie suggested. Also try writting short code pieces to try and test/isolate the problem. If you post some code we could probably help more.

Regards,

Joe