Hardware Reference
In-Depth Information
Step 7
Send the lower byte of the thermostat temperature to the DS1631A.
Step 8
Wait until the I 2 C transfer is completed and check to see if the DS1631A acknowledges.
If not, exit.
Step 9
Assert the stop condition.
The assembly program that implements this procedure is as follows:
THhi
equ
2
; offset of TH high byte from top of the stack
THlo
equ
3
; offset of TH low byte from top of the stack
setTH
ldaa
#$92
jsr
sendSlaveID
brclr
IBSR,RXAK,setTHok1
; did DS1631A acknowledge?
ldab
#$FF
; return error code 2 1
rts
setTHok1
movb
#$A1,IBDR
; send out access TH command */
brclr
IBSR,IBIF,*
; wait until command is shifted out
movb
#IBIF,IBSR
; clear IBIF flag
brclr
IBSR,RXAK,setTHok2
; did DS1631A acknowledge?
ldab
#$FF
rts
setTHok2
ldaa
THhi,sp
; get the upper byte of TH from stack
staa
IBDR
; send out TH high byte
brclr
IBSR,IBIF,*
movb
#IBIF,IBSR
; clear the IBIF flag
brclr
IBSR,RXAK,setTHok3
; did DS1631A acknowledge?
ldab
#$FF
rts
setTHok3
ldaa
THlo,sp
; get the lower byte of TH from stack
staa
IBDR
; send out the lower byte of TH
brclr
IBSR,IBIF,*
; “
movb
#IBIF,IBSR
; clear the IBIF flag
brclr
IBSR,RXAK,setTHok4
; did DS1631A acknowledge?
ldab
#$FF
rts
setTHok4
bclr
IBCR,MSSL
; generate the stop condition
ldab
#0
; normal return code
rts
The caller of this function pushes the high- and then the low byte of the new TH value into
the stack before calling this function.
The C language version of the function is as follows:
char setTH(char hibyte, char lobyte)
{
sendSlaveID(0x92);
if(IBSR & RXAK)
/* did DS1631A acknowledge? */
return 2 1;
IBDR 5 0xA1;
/* send command to access TH */
while(!(IBSR & IBIF));
Search WWH ::




Custom Search