// Monitor.C // // This program reads the serial port at 9600 baus // and displays the data on the LCD display // Global Variables unsigned char MSG0[21] = "Monitor.C "; unsigned char MSG1[21] = "9600 Baud "; unsigned char KEY[80] = "Three rings for the elvin kings under the sky. "; unsigned char M; // byte M of message unsigned char TEMP; // temp data from SCI port unsigned char i; unsigned char FLAG; // Subroutine Declarations #include // Subroutines #include "lcd_portd.c" // High-priority service void interrupt IntServe(void) { if (RCIF) { TEMP = ((RCREG ^ KEY[M]) & 63) + 'a'; TXREG = TEMP; if (TEMP > 20) MSG0[M++] = TEMP; if (M > 21) M = 21; if (TEMP == 13){ FLAG = 1; for (i=M+1; i<21; i++) MSG1[i] = ' '; for (i=0; i<20; i++) { MSG1[i] = MSG0[i]; MSG0[i] = ' '; } M = 0; } RCIF = 0; } } // Main Routine void main(void) { unsigned int DATA; unsigned int i, j; TRISA = 0; TRISB = 0; TRISC = 0; TRISD = 0; TRISE = 0; ADCON1 = 0x0F; LCD_Init(); // initialize the LCD LCD_Move(0,0); for (i=0; i<20; i++) LCD_Write(MSG0[i]); LCD_Move(1,0); for (i=0; i<20; i++) LCD_Write(MSG1[i]); LCD_Inst(0x01); // Initialize Serial Port to 9600 baud TRISC = TRISC | 0xC0; TXIE = 0; RCIE = 1; BRGH = 1; BRG16 = 1; SYNC = 0; SPBRG = 255; SPBRGH = 0; TXSTA = 0x22; RCSTA = 0x90; PEIE = 1; // Turn on all interrupts GIE = 1; while(1) { LCD_Move(0,0); for (i=0; i<16; i++) LCD_Write(MSG0[i]); LCD_Move(1,0); for (i=0; i<16; i++) LCD_Write(MSG1[i]); } }