View previous topic :: View next topic |
Author |
Message |
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Thu May 06, 2021 4:45 pm Post subject: I2C BUS question |
|
|
Hi,
Before I draw a PCB, I need some clarifications:
I'm going to use config I2Cbus, on port A of a 1284P I would like to know if I can also use the hard I2C bus portC.0 and portC.1
I Think yes but ...
Thank you for your answer
JP :wink:
(BASCOM-AVR version : 2.0.8.3 ) _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Thu May 06, 2021 6:55 pm Post subject: Re: I2C BUS question |
|
|
Duval JP wrote: | I Think yes but ... |
I think no.
The logical side of it: hard TWI, as well as soft I2C use the same commands like I2CStart, I2CWByte a.s.o. , thus to use multiple channels there must be a mechanism to select the proper channel.
Solution for multibus I2C is to set the channel in front of the I2C command(s).
What channel number would you use to switch to hard I2C?
Hard I2C has no channel number. (XMega plays a special role)
You can't also omit "i2cbus = 1" to switch to hardware, the i2cbus-variable and thus the channel will stay the same until you change it.
See the problem?
You can use soft-I2C for both ports. Additionally you can still use the hard TWI on PortC, but you can not use the hard TWI with Bascom commands.
Means you have to set up all proper routines and control all the hardware registers yourself. |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Fri May 07, 2021 7:56 am Post subject: |
|
|
Thanks MWS for your clear answers.
Sometimes I forget to reason logically.
I am going to use for an application 4 sensors that have the same I2C address hence the use of I2Cbus.
But I also need an I2C address for an RTC.
I will try with a breadboard:
3 sensors with the same address and 1 with the same address + the RTC address.
JP _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Fri May 07, 2021 9:10 am Post subject: |
|
|
There are specialized chips for that such of "address conflicts"
If this is only hobby "one or two units" project then use TCA9548A or simillar.
Only if cost of one of the "thousants" piece matter then it is worth to write those routines.
... Or maybe you have a lot of time to spent on your favoured hobby |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Fri May 07, 2021 12:17 pm Post subject: |
|
|
Duval JP wrote: | 3 sensors with the same address and 1 with the same address + the RTC address. |
If you don't want to spare pins, you can give each of the 5 slaves its very own channel, afaics multibus supports 16 channels.
Last edited by MWS on Fri May 07, 2021 12:27 pm; edited 1 time in total |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Fri May 07, 2021 12:26 pm Post subject: |
|
|
EDC wrote: | There are specialized chips for that such of "address conflicts"
If this is only hobby "one or two units" project then use TCA9548A or simillar.
Only if cost of one of the "thousants" piece matter then it is worth to write those routines.
... Or maybe you have a lot of time to spent on your favoured hobby |
The one and only reason would be, if he runs out of free pins, otherwise the plain solution is to use multibus I2C for everything, as it's most cost- and time-effective.
I see no requirement to use the hard-TWI module for the described setup. |
|
Back to top |
|
|
|