Listing 1. pseudocode example (continued) – Rainbow Electronics MAX1618 User Manual
Page 17

MAX1618
Remote Temperature Sensor
with SMBus Serial Interface
______________________________________________________________________________________
17
int ALERT_IntHandler()
{
int ErrorCode
= NoError;
int WhoDunnit
= Nobody;
int FoundState
= 0;
int StatusInfo
= 0;
int TempHigh;
int TempLow;
/* This interrupt handler verifies that the MAX1618 is the source of
the interrupt (and also clears the interrupt) via the SMBus Alert
Response address; checks the status byte to ensure that a temperature
change did indeed cause the interrupt; reads the remote temperature;
programs a corresponding clock-throttling duty cycle, and sets up new
Thigh and Tlow limits. */
ReadAlertResponse(&WhoDunnit, &ErrorCode);
if (WhoDunnit == MAX1618Addr) then {
MAX1618Read(RSL, &StatusInfo, &ErrorCode);
if (((StatusInfo & CollisionMask) != 0) and (ErrorCode ==
NoError)) then
MAX1618Read(RSL, &StatusInfo, &ErrorCode);
if (StatusInfo & DiodeFaultMask) != 0) then {
/* Shut down system because thermal diode doesn't
work */
}
else if ((StatusInfo & TempChangeMask) != 0) then {
MAX1618Read(RRTE, &TempRead, &ErrorCode);
while ((TempRead >= State[FoundState + 1]) and
(FoundState < (NumStates - 1)) do
FoundState++;
if (FoundState == (NumStates - 1)) then {
/* Ahhhhh!!! SHUT SYSTEM OFF!!!! */
}
else {
/* adjust clock duty cycle */
TempHigh = TempRead + HighAdder;
TempLow = TempRead - LowSubtracter;
MAX1618Write(WRHA, TempHigh, &Error);
MAX1618Write(WRLN, TempLow, &Error);
}
/* End of if (FoundState ... */
}
/* End of if (((StatusInfo .. else if ... */
/* Handle local temp status bits if set */
}
else {
/* Handle cases for other interrupt sources */
}
/* End of if (WhoDunnit ... */
return(ErrorCode);
Listing 1. Pseudocode Example (continued)