chiark / gitweb /
tblrd_test fiddling
authorceb <ceb>
Sun, 6 Feb 2005 23:59:53 +0000 (23:59 +0000)
committerceb <ceb>
Sun, 6 Feb 2005 23:59:53 +0000 (23:59 +0000)
cebpic/i2c-test.asm
cebpic/tblrd_test.asm

index d12325fd014a71c1eb4a6e344db4e16cd649dc96..28df43be7a9de4ee1608f95df993bcb7879907c4 100644 (file)
@@ -28,11 +28,12 @@ F_I2C_CTRL_U        equ     20h     ; flash location of i2c control byte
 F_I2C_CTRL_H   equ     00h
 F_I2C_CTRL_L   equ     01h
 
-; i2c specifit stuff
+; i2c specific stuff
 
 I2C_BUFF_PAGE  equ     4       ; put i2c relevant stuff into buffer page 4
 PIC_NO         equ     00h     ; pic no goes to 400h
 I2C_CTRL       equ     01h     ; i2c ctrl bit goes to 401h
+I2C_MASTER     equ     0       ; bit 0 of I2C_CTRL is 1=master 0=slave
 
 
 
@@ -151,6 +152,24 @@ initialise
 
 ; i2c setup
 
+       movlb   I2C_BUFF_PAGE   ; ser BSR=i2c BSR (4)
+
+       btfss   I2C_CTRL,I2C_MASTER,1   ; test whether PIC is master
+       goto    pic_master_setup        ; if so, set up as master
+       goto    pic_slave_setup         ; else set up as slave
+
+
+pic_master_setup
+
+
+
+
+pic_slave_setup
+
+
+
+
+
 ; p68
 ; p314
 ; p 275 ID locs
index cc58b778b5b68851b0c635c18e8eb4aa60d8eb0d..6f0428c6a3f29b8247c6af2e52a3cd80d490ba60 100644 (file)
@@ -148,7 +148,8 @@ initialise
 
        tblrd   *               ; read i2c 
 
-       movff   TABLAT, I2C_CTRL        ; move i2c_ctrl byte into normal memory
+       movf    TABLAT,0,0      ; move i2c_ctrl byte into normal memory
+       movwf   I2C_CTRL,1
 
 ; now have: PIC number in 400h, i2c control byte in 401h