Hardware Reference
In-Depth Information
To confi gure the DS1631A with the desired setting, use the following instruction sequence to
call the previous function:
ldab #$0E
jsr openDS1631
The C language version of the function is as follows:
char openDS1631(char cy)
{
sendSlaveID(0x92);
/* generate a start condition and send ID */
if (IBSR & RXAK)
return
2
1;
/* error code when DS1631A did not acknowledge */
IBDR
5
0xAC;
/* send command Access Config */
while(!(IBSR & IBIF));
IBSR
5
IBIF;
/* clear the IBIF flag */
if (IBSR & RXAK)
return
2
1;
/* error code when DS1631A did not acknowledge */
IBDR
5
cy;
/* send configuration byte */
while(!(IBSR & IBIF));
IBSR
5
IBIF;
if (IBSR & RXAK)
return
2
1;
/* error code when DS1631A did not acknowledge */
IBCR
&
5
,
MSSL;
/* generate a stop condition */
return 0;
/* normal return code */
}
▲
Example 11.11
▼
Write a function to start temperature conversion.
Solution:
The procedure for starting temperature conversion using the DS1631A is as follows:
Step 1
Assert a start condition and send a control byte (0x92) to the DS1631A with R/W 5 0.
Step 2
Wait until the I
2
C bus is idle and check to see if the DS1631A acknowledges. If not, exit.
Step 3
Send a Start Convert T command to the 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
Assert a stop condition to complete the whole process.
The assembly program that implements this procedure is as follows:
startConv
ldaa
#$92
jsr
sendSlaveID
; generate a start condition and send DS1631A's ID
brclr
IBSR,RXAK,startOK0
; did DS1631A acknowledge?
ldab
#$FF
; return error code
2
1
rts
Search WWH ::
Custom Search