AnsweredAssumed Answered

how to pack data for L6470 devices in a daisy-chain configuration

Question asked by minconetti.stefano on Dec 16, 2013
Latest reply on Jan 2, 2014 by Gigi

Hello everyone,

I'm here to ask some questions about using three L6470 stepper driver ICs connected together in a daisy-chain configuration.  The SPI device driver I'm writing for an ARM MCU takes SPI application commands (eventually) ready to be send to one or more of the three L6470 devices;  it then serializes the data bytes composing the commands of the various L6470 devices in the correct order, sending first on the MCU MOSI pin the data byte of the last L6470 device (whose SDO line connects directly to the MCU MISO line) and sending last the data byte of first L6470 device (whose SDI line connect directly to the MCU MOSI LINE).

Meanwhile the SPI device driver takes the data bytes coming on the MCU MISO, storing the first of them in the Rx buffer reserved for the last L6470 device and storing the last received data in the Rx buffer reserved for the first L6470 device.

Various situations may happen: for example at a given time, the MCU needs to send to the first L6470 device a SetParam(PARAM1, VALUE1x) command with three VALUE parameters (x=0..2; VALUE10, VALUE11, VALUE12), to the second L6470 device a SetParam(PARAM2, VALUE2y) command with two VALUE parameters (y=0..1; VALUE20, VALUE21) and to the last third L6470 device a SetParam(PARAM2, VALUE3z) command with only one VALUE parameter (z=0; VALUE30).

The problem I think can arises is about the possible correct sequence of the data byte packing over the SPI MOSI.
I think at least three possible SPI frame could be valid:

SPI frame #1:

a)      HIGH-to-LOW transition on the common Chip Select signal (CSn=0, start of SPI frame);
b)      spi_byte[00]: SetParam command for 3rd device;
c)       spi_byte[01]: SetParam command for 2nd  device;
d)      spi_byte[02]: SetParam command for 1st  device;
e)      spi_byte[03]: PARAM3 for 3rd device;
f)       spi_byte[04]: PARAM2 for 2nd device;
g)      spi_byte[05]: PARAM1 for 1st device;
h)      spi_byte[06]: VALUE30 for 3rd device;
i)        spi_byte[07]: VALUE20 for 2nd device;
j)        spi_byte[08]: VALUE10 for 1st device;
k)      spi_byte[09]: 1st NOP for 3rd device;
l)        spi_byte[10]: VALUE21 for 2nd device;
m)    spi_byte[11]: VALUE11 for 1st device;
n)      spi_byte[12]: 2nd NOP for 3rd device;
o)   spi_byte[13]: 1st NOP for 2nd device;
p)      spi_byte[14]: VALUE12 for 1st device;
q)      LOW-to-HIGH transition on the common Chip Select signal (CSn=1, stop of SPI frame).

[CSn=0] [SetParam, SetParam, SetParam] [PARAM3, PARAM2, PARAM1] [VALUE30, VALUE20, VALUE10] [NOP, VALUE21, VALUE11] [NOP, NOP, VALUE12] [CSn=1]


SPI frame #2:

a)      HIGH-to-LOW transition on the common Chip Select signal (CSn=0, start of SPI frame);
b)      spi_byte[00]: SetParam command for 3rd device;
c)       spi_byte[01]: SetParam command for 2nd  device;
d)      spi_byte[02]: SetParam command for 1st  device;
e)      spi_byte[03]: PARAM3 for 3rd device;
f)       spi_byte[04]: PARAM2 for 2nd device;
g)      spi_byte[05]: PARAM1 for 1st device;
h)      spi_byte[06]: 1st NOP for 3rd device;
i)        spi_byte[07]: 1st NOP for 2nd device;
j)        spi_byte[08]: VALUE10 for 1st device;
k)      spi_byte[09]: 2nd NOP for 3rd device;
l)        spi_byte[10]: VALUE20 for 2nd device;
m)    spi_byte[11]: VALUE11 for 1st device;
n)      spi_byte[12]: VALUE30 for 3rd device;
o)   spi_byte[13]: VALUE21 for 2nd device;
p)      spi_byte[14]: VALUE12 for 1st device;
q)      LOW-to-HIGH transition on the common Chip Select signal (CSn=1, stop of SPI frame).

 [CSn=0] [SetParam, SetParam, SetParam] [PARAM3, PARAM2, PARAM1] [NOP, NOP, VALUE10] [NOP, VALUE20, VALUE11] [VALUE30, VALUE21, VALUE12] [CSn=1]



SPI frame #3
:

a)      HIGH-to-LOW transition on the common Chip Select signal (CSn=0, start of SPI frame);
b)      spi_byte[00]: 1st NOP for 3rd device;
c)       spi_byte[01]: 1st NOP for 2nd device;
d)      spi_byte[02]: SetParam command for 1st  device;
e)      spi_byte[03]: 2nd NOP for 3rd device;
f)       spi_byte[04]: SetParam command for 2nd  device;
g)      spi_byte[05]: PARAM1 for 1st device;
h)      spi_byte[06]: SetParam command for 3rd device;
i)        spi_byte[07]: PARAM2 for 2nd device;
j)        spi_byte[08]: VALUE10 for 1st device;
k)      spi_byte[09]: PARAM3 for 3rd device;
l)        spi_byte[10]: VALUE20 for 2nd device;
m)    spi_byte[11]: VALUE11 for 1st device;
n)      spi_byte[12]: VALUE30 for 3rd device;
o)   spi_byte[13]: VALUE21 for 2nd device;
p)      spi_byte[14]: VALUE12 for 1st device;
q)      LOW-to-HIGH transition on the common Chip Select signal (CSn=1, stop of SPI frame).

 [CSn=0] [NOP, NOP, SetParam] [NOP, SetParam, PARAM1 ] [SetParam, PARAM2, VALUE10] [PARAM3, VALUE20, VALUE11] [VALUE30, VALUE21, VALUE12] [CSn=1]



I think the possible correct sequence may be those contained in SPI frame#1 or in SPI frame#3, so I ask everyone who already have faced this situation what  is the correct sequence to pack data bytes of application commands with different payload length.

Thanks in advance for any help anyone can give me.

Outcomes