user66713: I was reading the data Sheet of AMIS-30543 stepper motor driver and I was not able to understand how to combine the result of the Micro step position status register MSP[8:0]. I know that its a 9 bit value . Help me understand how to get the value.
In the data sheet it is given like

in SR3 -> MSP[8:2], and in SR4 -> MSP[6:0]. How I am I suppose to get the 9 bit out of these.

In the library I have seen that , (sr3<<2) | (sr4 & 3)  . I don't understand why they are doing and & here.
Please explain . also If there was no library how am I suppose to know how to combine these registers from the dataSheet .
Link to DataSheet

user4143: Most of the data is duplicated between the registers. Both registers contain MSP[6:2].
If MSP contains 111001001 the registers (ignoring the MSB "PAR" bit) would look like:
SR3: 1110010
SR4: 1001001

If we line those up it's then like:
SR3: 1110010
SR4    1001001

You can now see the overlap.
So taking SR3 and shifting it left two places (sr3 << 2) gives you:
SR3:   1110010
<<2: 111001000

Taking the lowest two bits of SR4 with & 3 gives you:
SR4:   1001001
& 3:   0000001

Then ORing the two results together:
SR3<<2: 111001000
SR4 &3: 000000001
-----------------
MSP   : 111001001


66713: <p>I was reading the data Sheet of AMIS-30543 stepper motor driver and I was not able to understand how to combine the result of the Micro step position status register MSP[8:0]. I know that its a 9 bit value . Help me understand how to get the value.</p>
<p>In the data sheet it is given like</p>
<p><a href="https://i.stack.imgur.com/rHgg0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rHgg0.png" alt="dataSheet" /></a></p>
<p>in SR3 -&gt; MSP[8:2], and in SR4 -&gt; MSP[6:0]. How I am I suppose to get the 9 bit out of these.</p>
<hr />
<p>In the library I have seen that , <code>(sr3&lt;&lt;2) | (sr4 &amp; 3) </code> . I don't understand why they are doing and <code>&amp;</code> here.</p>
<p>Please explain . also If there was no library how am I suppose to know how to combine these registers from the dataSheet .</p>
<p>Link to <a href="https://www.onsemi.com/pub/Collateral/AMIS-30543-D.PDF" rel="nofollow noreferrer">DataSheet</a></p>
 4143: <p>Most of the data is duplicated between the registers. Both registers contain MSP[6:2].</p>
<p>If MSP contains <code>111001001</code> the registers (ignoring the MSB &quot;PAR&quot; bit) would look like:</p>
<pre><code>SR3: 1110010
SR4: 1001001
</code></pre>
<p>If we line those up it's then like:</p>
<pre><code>SR3: 1110010
SR4    1001001
</code></pre>
<p>You can now see the overlap.</p>
<p>So taking SR3 and shifting it left two places (<code>sr3 &lt;&lt; 2</code>) gives you:</p>
<pre><code>SR3:   1110010
&lt;&lt;2: 111001000
</code></pre>
<p>Taking the lowest two bits of SR4 with <code>&amp; 3</code> gives you:</p>
<pre><code>SR4:   1001001
&amp; 3:   0000001
</code></pre>
<p>Then ORing the two results together:</p>
<pre><code>SR3&lt;&lt;2: 111001000
SR4 &amp;3: 000000001
-----------------
MSP   : 111001001
</code></pre>
