View previous topic :: View next topic |
Author |
Message |
micro_debugger
Joined: 08 Oct 2009 Posts: 73
|
Two i2c address on the same pins |
Posted: Sun Dec 15, 2013 5:49 pm |
|
|
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: 19537
|
|
Posted: Mon Dec 16, 2013 1:42 am |
|
|
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
|
|
Posted: Mon Dec 16, 2013 3:40 am |
|
|
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
|
|
Posted: Mon Dec 16, 2013 11:39 am |
|
|
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: 19537
|
|
Posted: Mon Dec 16, 2013 3:53 pm |
|
|
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
|
|
Posted: Wed Dec 18, 2013 5:04 pm |
|
|
already done, will be included in the next upgrade of the compiler
Thank you and Kind Regards |
|
|
|