/******************************************************************** * FileName: Example LCD display.c * Processor: PIC18F4520 * Compiler: MPLAB C18 v.3.06 * * Author Date Comment * (your name here) *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/ /** Header Files ***************************************************/ #include #include #include "LCD Module.h" /** Define Constants Here ******************************************/ #define PRESSED 0 #define UNPRESSED 1 /** Local Function Prototypes **************************************/ void updateLCD(void); void high_isr(void); void low_isr(void); /** Configuration Bits *********************************************/ #pragma config OSC = INTIO67 #pragma config WDT = OFF #pragma config LVP = OFF #pragma config BOREN = OFF #pragma config XINST = OFF /** Declare Interrupt Vector Sections ****************************/ #pragma code high_vector=0x08 void interrupt_at_high_vector(void) { _asm goto high_isr _endasm } #pragma code low_vector=0x18 void interrupt_at_low_vector(void) { _asm goto low_isr _endasm } /** Global Variables *********************************************/ int sampleVariable; char name[] = " David Fisher"; char start[] = "is "; char end[] = " years old "; char age = 32; char tensDigit = '3'; char onesDigit = '2'; char recentButtonState = UNPRESSED; /***************************************************************** * Function: void main(void) ******************************************************************/ #pragma code void main (void) { ADCON1= 0x0F; TRISD = 0x00; // You'll need to add initialization stuff here (like say the LCD) updateLCD(); while (1) { // You'll need to look for the button press // and see if it's a new press // if it is a new press update the tens_digit and ones_digit // then update the LCD with the new info } } /***************************************************************** * Local functions go after main but before the interrupts if needed ******************************************************************/ /***************************************************************** * Function: void updateLCD(void) * Input Variables: * Output return: * Overview: When called, updates the LCD with the latest age global variables. ******************************************************************/ void updateLCD(void) { // You'll need to add code here to update the LCD // Hint for one possible method... // Go to the start of line 1 // write line 1 // Go to the start of line 2 // write line 2 // write the tens digit // write the ones digit // write the end of line 2 } /***************************************************************** * Function: void high_isr(void) * Purpose: ******************************************************************/ #pragma interrupt high_isr void high_isr(void) { // High Priority Interrupt Service Routine (High ISR) } /****************************************************************** * Function: void low_isr(void) * Purpose: ********************************************************************/ #pragma interruptlow low_isr void low_isr(void) { // Low Priority Interrupt Service Routine (Low ISR) }