|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
I2C slave address 7 bit vs 10 bit |
Posted: Sat Aug 19, 2006 10:12 am |
|
|
Hi,
I have a master I2C talking to a salve.
I'm having problems with the salve address.
My slave is set to 0x12 as follows:
#use I2C(slave, sda=PIN_B4, scl=PIN_B6, address=0x12, FORCE_HW)
It however only communicates with the master when the master sets the address to 0x1E.
Do I have a problem with 7 bit vs 10 bit addressing modes?
Thanks for your time
Jeff |
|
|
Guest
|
|
Posted: Sat Aug 19, 2006 11:01 am |
|
|
I fixed the problem by relocating
#use I2C(slave, sda=PIN_B4, scl=PIN_B6, address=0x12, FORCE_HW)
This brings me to my next question. I have a backplane that can hold 7 slaves. The salves address is determined by the solt postion of the backplane. I have a subroutine that reads the slot position and then sets the slave address. This routine was causing my first problem EVEN THOUGH I NEVER CALLED the routine!
Is this a compiler problem?
switch (slotID)
{
case 0:
#use I2C(slave, sda=PIN_B4, scl=PIN_B6, address=0x10, FORCE_HW)
break;
case 1:
#use I2C(slave, sda=PIN_B4, scl=PIN_B6, address=0x12, FORCE_HW)
break;
case 2:
#use I2C(slave, sda=PIN_B4, scl=PIN_B6, address=0x14, FORCE_HW) break;
case 3:
#use I2C(slave, sda=PIN_B4, scl=PIN_B6, address=0x16, FORCE_HW)
break;
case 4:
#use I2C(slave, sda=PIN_B4, scl=PIN_B6, address=0x18, FORCE_HW)
break;
case 5:
#use I2C(slave, sda=PIN_B4, scl=PIN_B6, address=0x1a, FORCE_HW)
break;
case 6:
#use I2C(slave, sda=PIN_B4, scl=PIN_B6, address=0x1c, FORCE_HW)
break;
case 7:
#use I2C(slave, sda=PIN_B4, scl=PIN_B6, address=0x1e, FORCE_HW)
break;
}
} |
|
|
Guest
|
|
Posted: Sat Aug 19, 2006 2:04 pm |
|
|
You can�t do that. #use is a pre-processor directive, so the last one found in the source code will be the one that works. Try to change the slave address wrtiting directly to the respective register. |
|
|
Guest
|
|
Posted: Sat Aug 19, 2006 7:10 pm |
|
|
Thanks!
I'll give it a shot. |
|
|
Guest
|
|
Posted: Mon Aug 21, 2006 5:18 am |
|
|
Code is now working
#BYTE SSPADD = 0x93
SSPADD = i2cSlotAddress[slotID]; // load slave address |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|