Hardware Reference
In-Depth Information
Example 11.10
Write a function to configure the DS1631A in Figure 11.34 to operate in continuous conver-
sion mode and set the T OUT polarity to active high. Assume that the I 2 C has only one master
and there is no possibility in getting bus collision.
Solution: The procedure for configuring 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 transfer is completed and check to see if the DS1631A acknowledges. If
not, exit.
Step 3
Send an Access-Config command to the DS1631A.
Step 4
Wait until the I 2 C bus is idle and check to see if the DS1631A acknowledges. If not, exit.
Step 5
Write a command byte to configure the DS1631A to operate in continuous conversion
mode and set the T OUT polarity to active high.
Step 6
Wait until the I 2 C bus is idle and check to see if the DS1631A acknowledges. If not, exit.
Step 7
Assert a stop condition to complete the whole process.
The assembly function that performs the desired confi guration is as follows:
openDS1631
ldaa
#$92
jsr
sendSlaveID
brclr
IBSR,RXAK,openOK0
; did DS1631A acknowledge?
ldab
#$FF
; return error code 21
rts
openOK0
movb
#$AC,IBDR
; send the Access Config command
brclr
IBSR,IBIF,*
movb
#IBIF,IBSR
; clear the IBIF flag
brclr
IBSR,RXAK,openOK1
; did DS1316A acknowledge?
ldab
#$FF
rts
openOK1
stab
IBDR
; sends configuration data
brclr
IBSR,IBIF,*
; wait until the byte has been shifted out
movb
#IBIF,IBSR
; clear the IBIF flag
brclr
IBSR,RXAK,openOK2
; did DS1316A acknowledge?
ldab
#$FF
rts
openOK2
bclr
IBCR,MSSL
; generate a stop condition
ldab
#0
; normal return code
rts
Search WWH ::




Custom Search