CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

I2C slave address 7 bit vs 10 bit

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








I2C slave address 7 bit vs 10 bit
PostPosted: Sat Aug 19, 2006 10:12 am     Reply with quote

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








PostPosted: Sat Aug 19, 2006 11:01 am     Reply with quote

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








PostPosted: Sat Aug 19, 2006 2:04 pm     Reply with quote

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








PostPosted: Sat Aug 19, 2006 7:10 pm     Reply with quote

Thanks!

I'll give it a shot.
Guest








PostPosted: Mon Aug 21, 2006 5:18 am     Reply with quote

Code is now working


#BYTE SSPADD = 0x93


SSPADD = i2cSlotAddress[slotID]; // load slave address
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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