mainlogo.jpg (16286 bytes)

AN505

Product: Domino 2

I2C Bus Error Checking

Date: 6/7/00

Introduction: The I2C Domino Utility routine has a feature that can check to see if the I2C bus is communicating properly. If it isn’t, the I2C bus can be reset to restore proper communications.
 

Background: The use of I2C devices make expansion of the Domino very simple to accomplish. Such devices include the Domino 2 I/O coprocessor, expansion data E2PROM and I2C I/O expanders. This application note demonstrates how to reset the I2C bus should the users code inadvertently cause it to lock up.

 

How it works: The program listing below contains subroutines to read and write to the I2C I/O coprocessor of the Domino 2. Whether the user is reading from the coprocessor or writing to the coprocessor the POP command needs to be used or the argument stack can eventually run out of bounds. So why not take advantage of the information popped off of the argument stack and use it to check for errors. If the variable the information is popped into is greater than 255 then an I2C communications error has occurred. The program listing demonstrates how to bring communications back by setting P1.6 and P1.7 high. That is all it takes to reset the I2C bus. One way the I2C bus can lock up is if P1.6 or P1.7 are accidentally left unmasked while writing to port 1 of the Domino.

 

Program Listing:

10000 REM ******************************************************

10010 REM Coprocessor Read Routine

10020 REM R= Register of the coprocessor

10030 PUSH 2000H + R

10040 CALL 0F12Ch

10050 POP DT

10060 IF DT>255 THEN GOSUB 11100

10070 RETURN

10080 REM

10997 REM ******************************************************

10998 REM Coprocessor Write Routine

10999 REM R= Register of the coprocessor, DT= The data to write to the register

11000 PUSH 2000H+R,DT

11010 CALL 0F128H

11020 POP DT

11030 IF DT>255 THEN GOSUB 11100

11040 RETURN

11050 REM

11060 REM ******************************************************

11070 REM I2C BUS Reset Subroutine.

11080 REM Set P1.6 and P1.7 high masking the rest of the port,

11090 REM so the other bits will not be affected.

11100 PORT1 = PORT1 .OR. 0C0H

11110 RETURN

11120 REM ******************************************************