Hardware Reference
In-Depth Information
Step 10
Assert the stop condition.
The assembly program that implements this procedure is as follows:
readConf
ldaa
#$92
; generate a start condition and send out DS1631A
jsr
sendSlaveID
; ID
brclr
IBSR,RXAK,rdConfok1
; did DS1631A acknowledge?
ldab
#$FF
; return error code 2 1
rts
rdConfok1
movb
#$AC,IBDR
; send out the Access Conf command
brclr
IBSR,IBIF,*
; wait until the command is shifted out
movb
#IBIF,IBSR
; clear the IBIF flag
brclr
IBSR,RXAK,rdConfok2
; did DS1631A acknowledge?
ldab
#$FF
; return error code 2 1
rts
rdConfok2
bset
IBCR,RSTA
; generate a restart condition
movb
#$93,IBDR
; send out slave ID and set R/W bit to 1
brclr
IBSR,IBIF,*
; wait until the command is shifted out
movb
#IBIF,IBSR
; clear the IBIF flag
brclr
IBSR,RXAK,rdConfok3
; did DS1631A acknowledge?
ldab
#$FF
; return error code 2 1
rts
rdConfok3
bclr
IBCR,TXRX
; prepare to read
bset
IBCR,TXAK
; prepare to send NACK
ldaa
IBDR
; perform a dummy read to trigger nine clock pulses
brclr
IBSR,IBIF,*
; wait until a byte has been shifted in
movb
#IBIF,IBSR
; clear the IBIF flag
bclr
IBCR,MSSL
; generate a stop condition
ldab
IBDR
; place the Conf register value in B
rts
The C language version of the function is as follows:
char readConf(void)
{
char temp;
sendSlaveID(0x92);
if(IBSR & RXAK)
/* did DS1631A acknowledge? */
return 2 1;
IBDR 5 0xAC;
/* send command to access Conf register */
while(!(IBSR & IBIF));
IBSR 5 IBIF;
if (IBSR & RXAK)
return 2 1;
IBCR | 5 RSTA;
/* generate a restart condition */
IBDR 5 0x93;
/* send out ID and set R/W to 1 */
while(!(IBSR & IBIF));
IBSR 5 IBIF;
if (IBSR & RXAK)
return 2 1;
IBCR & 5 , TXRX;
/* prepare to receive */
Search WWH ::




Custom Search