View previous topic :: View next topic |
Author |
Message |
jynx
Joined: 28 Apr 2016 Posts: 8
|
Posted: Fri May 13, 2016 11:00 pm Post subject: XMEGA256A3BU Hardware / Software I2C |
|
|
I am trying to have a single MCU read as many I2C sensors as possible. The sensors will not be on the same I2C bus. I am using a XMEGA256A3BU and have tested I2C communication to my sensor with BASCOM. I have tested a single sensor using software I2C and hardware I2C interfaces . The XMEGA256A3BU has 2 I2C channels. Is it possible to use the 2 hardware based I2C channels along with I2C software based channels as well? How many software based I2C channels can BASCOM support? Can I use SPI channels at the same time as well? I am considering going with an MCU that has 4 I2C channels, but would still like to use additional software based I2C channels as well. Just trying to figure out what my possibilities are in the shortest time.
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue May 17, 2016 10:26 am Post subject: |
|
|
you might want to check the multibus lib :
Code: | '------------------------------------------------------------------------------
'name : I2C-multibus.bas
'copyright : (c) 1995-2014, MCS Electronics
'purpose : demonstrates I2C multibus library
'micro : Mega88
'suited for demo : no, lib not included in demo
'commercial addon needed : no
'------------------------------------------------------------------------------
$regfile="m88def.dat"
$crystal=8000000
$hwstack=32
$swstack=24
$framesize=24
config i2cbus=0,scl=portc.0,sda= portc.1 'each bus requires a configuration of the SCL and SDA pins
config i2cbus=1,scl=portc.2,sda= portc.3 'this sample creates 4 busses
config i2cbus=2,scl=portd.2,sda= portd.3
config i2cbus=3,scl=portd.4,sda= portd.5
Dim j as Byte
For j=0 to 3 'the first bus is 0 !!!
i2cbus=j 'select the BUS
i2cinit 'init the pins and state
Next
do
for j=0 to 3
i2cbus=j 'select the bus
I2CSend &H40, &B01010101 'send some data
next
waitms 100
loop
end |
_________________ Mark |
|
Back to top |
|
|
Mrshilov
Joined: 24 Jan 2009 Posts: 314 Location: Russia
|
Posted: Tue May 17, 2016 12:27 pm Post subject: |
|
|
Also in multibus you can reduce pins using common SDA line:
Code: | config i2cbus=0,scl=portc.0,sda= portc.1 'each bus requires a configuration of the SCL and SDA pins
config i2cbus=1,scl=portc.2,sda= portc.1 'this sample creates 4 busses
config i2cbus=2,scl=portd.2,sda= portc.1
config i2cbus=3,scl=portd.4,sda= portc.1 |
|
|
Back to top |
|
|
|
|
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 You cannot attach files in this forum You cannot download files in this forum
|
|