A better way to change a variable... EEPROM maybe?

Discussion in 'Embedded Systems and Microcontrollers' started by Dalaran, May 15, 2011.

  1. Dalaran

    Thread Starter Active Member

    Dec 3, 2009
    I have a variable which I am increasing or decreasing depending on which of the 2 buttons was pushed (RB6/RB7). Using C language and PIC uC.

    Code ( (Unknown Language)):
    2.     if(PORTB.F6 == 1){
    3.       Set = Set + 0.1;
    4.     }
    5.     if(PORTB.F7 == 1){
    6.       Set = Set - 0.1;
    7.     }
    The code consists of an infinite while loop with the above snipit embedded in it. The problem is that if the code takes longer to run you may need to hold the button for sometime before it registers. I know there is an "interrupt on change" function for the PORTB pins in the PIC I am using, but cannot figure out how to get anything I change in the interrupt back to my main function. Would it make sense to write to the EEPROM during the interrupt routine? Anyone with any better ideas?