I have a follow up question. The above response says:
"So the resulting byte will be the equivalent of RR left shifted twice then ANDed with 0b11111100."
I don't understand why the "then ANDed with 0b11111100." is needed.
For example: If RR = 43 = b101011, then left shifting twice and adding 0, 0 at the end gives b10101100 =172. ANDing this with b11111100 gives:
b10101100 =172
b11111100 = 252
---------------
b10101100 = 172 the same number I started with before ANDing.
Did I do this correctly? Is the ANDing necessary?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using this Magnetometer IC:
https://cdn.sparkfun.com/assets/2/2/4/d/6/MLX90393-Datasheet-Melexis_revision_003.pdf
On Page 17, in the Read Register row they use this terminology {A5…A0,0,0}
Does anyone know what {A5…A0,0,0} means?
It is telling you the bit range that is returned, its justification and the padding.
So in this case if the register name is RR then it will return RR.5 then RR.4, RR.3, RR.2, RR.1, RR.0 then 0. 0
So the resulting byte will be the equivalent of RR left shifted twice then ANDed with 0b11111100.
I am not sure how to make that explanation clearer and it still looks awkward, so I hope it is not even more confusing.
Thanks Chris! That helps
I have a follow up question. The above response says:
"So the resulting byte will be the equivalent of RR left shifted twice then ANDed with 0b11111100."
I don't understand why the "then ANDed with 0b11111100." is needed.
For example: If RR = 43 = b101011, then left shifting twice and adding 0, 0 at the end gives b10101100 =172. ANDing this with b11111100 gives:
b10101100 =172
b11111100 = 252
---------------
b10101100 = 172 the same number I started with before ANDing.
I think you misunderstood my reply.
I was not saying that "You" have to do the shift followed by AND, I was pointing out that that is what "They" have done to give you the result.
Thanks Chris! I did misunderstand.