2024-05-21 12:47 AM
Hi
I saw that the CS and I2C enable are on the same pin and also the SPI and I2C CLK and data.
Does it means that this component can not be with other SPI IC on the same line? (because when the CS is 1 while talking to other ICs it will be in I2C mode and will transmit junk to the bus)? if so, its intended use in SPI mode is to be single component on the bus?
regarding Lis2MDL it has I2C_DIS (h62 bit 3). this is also not 100% clear to me. If I connect 2 ICs on same bus in the moment I will start to config the first IC to disable I2C the other will interfere because it CS will be on 1... please help me understand how can I do it? maybe the I2C_DIS bit is the default (it is missing in the datasheet)?
please help me understand this issue.
thanks
Solved! Go to Solution.
2024-05-23 05:43 AM
Hi @orsamoo ,
As I wrote in the previous answer (and like you already understood) having LIS3MDL on same SPI line of other devices can cause a misbehaving I2C communication if it is recognized a start condition and the SAD. So the risk is present but it has low probability.
If you want to avoid completely the risk, you can use LIS2MDL as suggested in my answer that you posted. With LIS2MDL they need to be on different I2C line if you want to configure/communicate them with I2C (different configuration one respect the other). Otherwise you can link them to same I2C bus (they should receive the same messages) and as first configuration assert I2C_DIS (h62 bit 3), in this way they will respond only to SPI communications from that on (their own specific CS).
2024-05-23 01:42 AM
Hi @orsamoo ,
Welcome to ST Community!
In SPI communication any device attached to the same CS line receives the message broadcasted from Master, different sensor should have different CS line asserted by master when chosen for communication (but can share SPC and SDA).
In I2C communication instead (CS 1) Lis3MDL will respond only if SAD of the message refers to its own, using SA1 you can have 2 of these sensors on same I2C line.
Regarding Lis2MDL register I2C_DIS (h62 bit 3) it is 0 by default. Unfortunately they have same SAD so if you want to set up differently, I suggest to use another I2C line of the micro for one of the two.
2024-05-23 02:01 AM
Hi Federica.
thank you for your answer but unfortunately doesn't answer My question.
I know how I2C and SPI are working in general, so let me explain myself better. I want to work with 2 Lis3MDL using SPI on same bus with 6 others SPI ICs (each will have different CS) however, in your IC you have located the CS and the I2C enable on the same line so every time I do not want to use the the LIS3MDL sensor and put their CS on 1 it will be listening to I2C communication and it will response in case they will think they receive their address (1 in a lifetime chance...).
My question is - due to this risk (or any other risk - please elaborate if there are) do you think that LIS3MDL should not be place on same SPI bus with other SPI components?
In continuous to this question I saw that LIS2MDL has I2C_DIS, I do not understand if it can solve the problem I referred to because if I put 2 LIS2MDL on same SPI bus there is still a chance that one of them will go to I2C mode and respond to the bus while configuring the other not to enter I2C mode. So how can it solve the situation.
just to make sur we are align - I need 2 hall sensor using same SPI bus with other 6 SPI ICs on the same bus.
Thank you.
2024-05-23 03:00 AM
Hi @orsamoo ,
Ok, now it's more clear. As you already understood, LIS3MDL when CS is 1 it enables I2C communication. I think that is very low the possibility that their SAD will be triggered, moreover because
In I2C: start condition is defined as a high to low transition on the data line while the SCL line is held high.
In SPI: SDI and SDO are respectively the serial port data input and output. Those lines are driven at the falling edge of SPC and should be captured at the rising edge of SPC.
so with a proper SPI communication the I2C should not encounter a start condition.
I think that LIS3MDL is enough for your goal.
2024-05-23 04:04 AM
Hi Federica.
Thank you for your detailed answer now it makes me more confident I can use 2 LIS3MDL on the same bus with other SPI components.
However, while doing some searching I came across this answer.
In that post you are saying that this component should not be with other SPI on the same bus (or I didn't understood the answer? ).
I just need clarification - the answer in that post was wrong? can I 100% use 2 of this sensors on same bus with other components?
thank you very much.
2024-05-23 05:43 AM
Hi @orsamoo ,
As I wrote in the previous answer (and like you already understood) having LIS3MDL on same SPI line of other devices can cause a misbehaving I2C communication if it is recognized a start condition and the SAD. So the risk is present but it has low probability.
If you want to avoid completely the risk, you can use LIS2MDL as suggested in my answer that you posted. With LIS2MDL they need to be on different I2C line if you want to configure/communicate them with I2C (different configuration one respect the other). Otherwise you can link them to same I2C bus (they should receive the same messages) and as first configuration assert I2C_DIS (h62 bit 3), in this way they will respond only to SPI communications from that on (their own specific CS).
2024-05-30 02:31 AM
thank you very much