I did something like this but it was for a 12F1822 with a 2x16 LCD display using the 4-bit interface and 250 microsecond update intervals.
Using a faster update interval and modifying the buffer directly does allow you to do some neat things. For example, exclusive-or'ing the colon character positions in the buffer with ':'^' ' every 500 milliseconds will produce the flashing colon effect seen in the video below.
Here's the interrupt routine from the demo (C code);
Code:
/******************************************************************
* *
******************************************************************/
void interrupt() // 250 usec (500 cycle) interrupts
{ static char line = 0xC0; //
static char bndx = 0; //
pir1.TMR2IF = 0; // clear TMR2 interrupt flag
/* *
* update one LCD character from the display array buffer (34 *
* interrupts or 8.5 ms to completely refresh the display). *
* */
if(line & 0x80) // if "new line"
PutCMD(line ^= 0x40); // set DDRAM address (0x80 or 0xC0)
else // not "new line" so
PutDAT(lcd[bndx++]); // refresh display, bump index
bndx &= 31; // pseudo %32, 0..31 inclusive
if((bndx & 15) == 0) // if new line (0 or 16)
line ^= 0x80; // toggle b7 pseudo "new line" flag
}
Bookmarks