Hi there!
I'm planning to use an L6470 motor driver for some industrial machinery but I'm not familiar with SPI.
Link for the datasheet: datasheet (Registers on page 40-41)
My problem is that I don't know how to read and write to these registers and the length of most of them is not even multiple of 8 bits. I'm wondering how could I for example write 22 bits to the "Mark position" register or read 20 bits from "Current speed".
I've seen libraries that would do this for me easily but the one I found easy to use uses a software SPI implementation and I don't quite like software serial implementations in the kind of environment for this project. Alco I'd like to get known with SPI as I could do many useful things with it.
So my final questions are:
How can I read/write these registers with "unconventional" length?
Do you have any other advice for me regarding this project or IC?
What do the registers from h09 to h11 do? I don't quite understand the function of all of them.
FeriHUN:
Hi there!
I'm planning to use an L6470 motor driver for some industrial machinery but I'm not familiar with SPI.
Link for the datasheet: datasheet (Registers on page 40-41)
My problem is that I don't know how to read and write to these registers and the length of most of them is not even multiple of 8 bits. I'm wondering how could I for example write 22 bits to the "Mark position" register or read 20 bits from "Current speed".
I've seen libraries that would do this for me easily but the one I found easy to use uses a software SPI implementation and I don't quite like software serial implementations in the kind of environment for this project. Alco I'd like to get known with SPI as I could do many useful things with it.
So my final questions are:
How can I read/write these registers with "unconventional" length?
Do you have any other advice for me regarding this project or IC?
What do the registers from h09 to h11 do? I don't quite understand the function of all of them.
Well, SPI is serial by bit, shifted in from the low order bit of the byte, so registers with less than 8 bits will be in the low order part of the byte.
I note in the PDF, the data is sent low order byte first, so you will need to re-order the bytes in your Arduino program. Same conversion for sending to the controller.
I am sure your Google has lots of information on SPI communication.
Paul
From Page 38:
So, imagine you always send / receive the smallest multiple of 8 bits that can hold the contents of the register in question. As a guess, I'd say the register is justified to the LSB end. But, I haven't read very much of the datasheet.
So for example can I send an int type value to write to the 12 bit register and a long type for the 22 bits one with the SPI in MSBFIRST mode? (shifted to the right as needed)
I'd think for 22-bit register you'd only send 3 bytes, not 4.
Yes, but there's no 3 byte long data type.
Or maybe I could du this: uint8_t reg_name[3] = {};
Does it look good?