Created Thu, 24 Nov 2011 08:59:06 +0000 by spencoid
Thu, 24 Nov 2011 08:59:06 +0000
I have a two line LCD character display that I am using for status information. It is supposed to be compatible with 3.2 volt logic. I have 4 interrupts and a PWM timer running in this application. I have not had problems with simpler tests. When I invoke an interrupt handler (with a button press) that contains code that writes to the LCD I often get garbled nonsense characters and seemingly also crash the program requiring a reboot. This only happens on the first interrupt. If it makes it past the first one it is fine indefinitely.
Are there any known issues that could cause this? Can or should I disable the interrupts other than the one from which the LCD is written. I don't know how to do this. Should I fiddle with interrupt priority levels? Are higher numbers a higher priority or are lower numbers a higher priority?
Thu, 24 Nov 2011 09:28:18 +0000
Garbled LCD characters usually indicate writing too fast to the device , especially after a clear command.
Thu, 24 Nov 2011 09:34:11 +0000
How do I slow it down? The write is within an interrupt routine and delay is not supposed to work or at least I read in the Arguino docs that it doesn't. Will it work in the pic version? If not is there another way?
Thu, 24 Nov 2011 09:54:15 +0000
It does seem to be a speed or initialization problem. The problem just showed up recently and I was assuming that it was the added complexity of the program that was the cause but I had changed one feature that I just changed back and the problem is gone. When the program boots there was a scrolling banner telling what button to press. I thought this was annoying so I made it a shorter static message. If I put the scrolling message up first before calling the interrupt, the problem is gone.
I would prefer a more elegant fix if anyone has a suggestion.
Thu, 24 Nov 2011 11:29:51 +0000
To be honest I am a novice with this language so i have steered away from using libraries other than wire. I have hung a 4x20 lcd of a I2C port expander this solves any 3.3 and 5 v problems and cuts down connections etc, if i code a clearlcd I have to wait 100 msec before attempting another write, I have worked with lcd and PICs with asm. programing where timing for writing nibbles and commands are easier kept within spec lcd, are slow devices.
Fri, 25 Nov 2011 00:00:19 +0000
When I invoke an interrupt handler (with a button press) that contains code that writes to the LCD I often get garbled nonsense characters and seemingly also crash the program requiring a reboot.
How are you communicating to the LCD? SPI, I2C, Parallel? If your using SPI or I2C and making calls in an interrupt to talk to the bus, as well as out side, then the interrupt could be interrupting what ever is talking to the bus mid message and be confusing the bus.
If so you should disable (this) interrupt around what ever else may be using the bus, but typically I try to avoid using the SPI, I2C, USB or USART calls in an interrupt. If I need to send a message then I just set a flag and do it in the main loop.
Jacob