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

Two i2c address on the same pins

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



Joined: 08 Oct 2009
Posts: 73

View user's profile Send private message

Two i2c address on the same pins
PostPosted: Sun Dec 15, 2013 5:49 pm     Reply with quote

Chip18f25K20
PCWH 5.016
I need to implement 2 I2C slave interfaces on the same chip (pins) with different addresses. Is it possible to do with MASK parameter ?? Any idea or help?

Thank you in advance
Warmest Regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Mon Dec 16, 2013 1:42 am     Reply with quote

Potentially, yes.
You'd need to setup the chip as if you are using one particular address, and then turn off one mask bit for a bit in this address.
So, something like:
Code:

#use I2C(slave,sda=PIN_C4,scl=PIN_C3, address=0xa0, FORCE_HW, mask=0xDF)

The chip should then accept address 0xA0, and also address 0x80, and interrupt on each. The slave handler is going to have to read the address byte, and verify which address it is responding to.

The masking works as:
0b10100000 address
0b11011111 mask

0b10x00000 addresses that will match

Going to be 'interesting ground' getting this to work right....

Best Wishes
micro_debugger



Joined: 08 Oct 2009
Posts: 73

View user's profile Send private message

PostPosted: Mon Dec 16, 2013 3:40 am     Reply with quote

Thank you so much for your guides, I will try to do it today and reply to the forum
Best Regards
micro_debugger



Joined: 08 Oct 2009
Posts: 73

View user's profile Send private message

PostPosted: Mon Dec 16, 2013 11:39 am     Reply with quote

I done it, seems to be working, but there is bug in the #use i2c(....., MASK=...)
not setting the proper register at all. Always is 0xff. So needed to be set by hand, and then is working. I need to make more tests.
Warmest Regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Mon Dec 16, 2013 3:53 pm     Reply with quote

It has the address mask address correct in the device database. Sounds as though a 'quick report' is needed to CCS.

Best Wishes
micro_debugger



Joined: 08 Oct 2009
Posts: 73

View user's profile Send private message

PostPosted: Wed Dec 18, 2013 5:04 pm     Reply with quote

already done, will be included in the next upgrade of the compiler

Thank you and Kind Regards
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