1

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

dataSheet

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

3

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
7
  • How can I understand this from data sheet like from sr3 and sr4 – Lawliet Oct 15 '20 at 21:10
  • The 8:2 and 6:0 refer to the range of bits stored in that register. It's a little unusual to have overlap like that. – Majenko Oct 15 '20 at 21:17
  • So is it okay to do like :: ‘(sr3 << 2 | sr4)’ – Lawliet Oct 15 '20 at 21:19
  • No, because of the PAR bit that's in the MSB that will corrupt SR3. – Majenko Oct 15 '20 at 21:20
  • 1
    Practice and experience. It's the first time I have seen overlapping bits like that, but the code snippet you showed and the 8:2 and 6:0 in the datasheet allowed me to infer it. It's really not clear at all in the datasheet, so it's not surprising you were struggling with it. – Majenko Oct 15 '20 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.