Chapter 7: Microcontroller Interrupts and Timers
temp Register,
CCAL
r runs to fast, decrease OSCCAL
therwise, if temp is less than 6120, increment OSCCAL.
)
llator runs to slow, increase OSCCAL
}
; // the interRC is correct
timer:
CR1B = (1<<CS10); // start timer1
ow if you are beginning to think all this is mighty confusing, you are finally
understand the core truth of microcontroller programming. It IS
bug infested and time consuming and ego
estroying and... well, you name it. But finally getting something working is the
u don’t actually get some
leasure from working out these puzzles you don’t need to be doing this for a
areer. Try professional knife fighting... you’ll survive longer. This complexity is
rimary reason to ‘reuse’ code. And speaking of stealing them naked, the
llowing project uses code lifted directly from the WinAVR port of the ATMEL
utterfly code.
temp += tempL;
}
Is greater than 6250? If so decrement the Oscillator Calibration
OS
if (temp > 6250)
{
OSCCAL--;//RC oscillato
}
O
else if (temp < 6120
{
OSCCAL++; //RC osci
If temp is between 6250 and 6120 the calibration is complete and we can go
home.
else
calibrate = TRUE
But before we turn out the light, we start the
TC
N
beginning to
mighty confusing. And frustrating and
d
greatest pleasure known to mankind, (if you overlook sex, eating, parenting, and
anything else you like to do). A word of advice: if yo
p
c
p
fo
B