Hardware Reference
In-Depth Information
startOK0
movb
#$51,IBDR
; send Start Convert T command
brclr
IBSR,IBIF,*
; wait until the byte is shifted out
movb
#IBIF,IBSR
; clear the IBIF flag
brclr
IBSR,RXAK,startOK1
; did DS1631A acknowledge?
ldab
#$FF
rts
startOK1
bclr
IBCR,MSSL
; generate a stop condition
ldab
#0
; normal return code
rts
The C language version of the function is as follows:
char startConv (void)
{
sendSlaveID(0x92);
/* generate a start condition and send slave ID */
if (IBSR & RXAK)
return
2
1;
/* if not acknowledged, return error code
2
1 */
IBDR
5
0x51;
/* send command to start a conversion */
while(!(IBSR & IBIF));
IBSR
5
IBIF;
/* clear the IBIF flag */
if (IBSR & RXAK)
return
2
1;
IBCR &
5
,
MSSL;
/* generate a stop condition */
return 0;
}
▲
Example 11.12
▼
Write a function to set the high thermostat temperature. The upper and lower bytes of the
high thermostat temperatures are passed in stack.
Solution:
The procedure for setting up the high thermostat temperature is as follows:
Step 1
Assert the start condition and send control byte 0x92 with R/W bit 5 0.
Step 2
Wait until the I
2
C transfer is completed and check to see if the DS1631A acknowledges.
If not, exit.
Step 3
Send an Access TH command to DS1631A.
Step 4
Wait until the I
2
C transfer is completed and check to see if the DS1631A acknowledges.
If not, exit.
Step 5
Send the upper byte of the thermostat temperature to the DS1631A.
Step 6
Wait until the I
2
C transfer is completed and check to see if the DS1631A acknowledges.
If not, exit.
Search WWH ::
Custom Search