From: ceb Date: Sun, 6 Feb 2005 23:59:53 +0000 (+0000) Subject: tblrd_test fiddling X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=69e67b42144aa490d67918e3124e983fa598bebe;p=trains.git tblrd_test fiddling --- diff --git a/cebpic/i2c-test.asm b/cebpic/i2c-test.asm index d12325f..28df43b 100644 --- a/cebpic/i2c-test.asm +++ b/cebpic/i2c-test.asm @@ -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 diff --git a/cebpic/tblrd_test.asm b/cebpic/tblrd_test.asm index cc58b77..6f0428c 100644 --- a/cebpic/tblrd_test.asm +++ b/cebpic/tblrd_test.asm @@ -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