3 i2c example 3: slave mode receive, 4 i2c example 4: slave mode receive, C example 3: slave mode receive -8 – Maxim Integrated MAXQ Family Users Guide: MAXQ2010 Supplement User Manual
Page 131: C example 4: slave mode receive -8, Maxq family user’s guide: maxq2010 supplement

MAXQ Family User’s Guide:
MAXQ2010 Supplement
22-8
22.2.3 I
2
C Example 3: Slave Mode Receive
; I2C configured as slave with address 1ah
; Setup for Slave Mode Receive
move I2CSLA, #01ah
; I2C Slave Address = 01ah
move I2CCN, #0001h
; I2CEN = 1, I2CMST = 0, I2CMODE = 0, I2CSTART = 0
call wait_start
; Polling routine to wait for I2CSTART to be set,
; indicating a received START
;; Check for address match
move ACC, I2CST
and #0020h
; Check for Address Match flag set
cmp #0020h
jump ne, no_match
; If address match bit not set, not for us, else:
move I2CIE.2, #01h
; Enable Receive Ready Interrupt
call wait_rxbuf
; Wait for a receive interrupt
;; Byte received in I2CBUF, clear I2C interrupt flag and wait for next interrupt
22.2.4 I
2
C Example 4: Slave Mode Receive
; I2C configured as slave with address 1ah
; Setup for Slave Mode Receive
move I2CSLA, #01ah
; I2C Slave Address = 01ah
move I2CCN, #0001h
; I2CEN = 1, I2CMST = 0, I2CMODE = 0, I2CSTART = 0
call wait_start
; Polling routine to wait for I2CSTART to be set,
; indicating a received START
;; Check for address match
move ACC, I2CST
and #0020h
; Check for Address Match flag set
cmp #0020h
jump ne, no_match
; Not an address match
move ACC, I2CCN
; Check transfer mode is set
and #004h
cmp #004h
jump ne, not_sl_xmit ; If transfer mode is low, not a slave transmit, else:
move I2CBUF, #0aah
; Data byte to be transmitted
call wait_xmit
; Poll for transmit done
;; Verify ACK received from master
move ACC, I2CST
and #080h
cmp #000h
jump ne, FAIL
; If NACK bit set, handle retransmission, else continue