The application is planned run on a STK506 in a STK500. with PortB1-3 connected to the switches. Pushing a switch means pulling the pin to ground. PortB0 outputs System Clock/2.
The application measures the temperature to check for changes and checks if a switch have been pushed. If the temperature hase changed more than a defined limit (TEMP_DIFF_LIMIT) or switch PB3 has been pushed, a measurement and calibration sequence will be initiated. First the Slow RC oscillator period is calculated from the temperature measurement, then the ULP RC oscillator is measured against the Slow RC and the period calculated. Lastly the Fast RC Oscillator is calibrated against the Slow RC Oscillator. If switch PB1 is pressed the FOSCCAL is adjusted one step down (decreasing frequency) and if PB2 is pressed FOSCCAL is adjusted one step up (increasing frequency). The key reading routine waits util the buttons have been released and returns an error if multiple have been pressed.
1.5.5