cancel
Showing results for 
Search instead for 
Did you mean: 

How to pack data in a SPI frame in a L6470 daisy chain configuration.

Muscle Man
Associate III

Hi,

I have a project, based on a STM32L071CB MCU, where I use two L6470

stepper motor drivers attached together in a daisy chain configuration:

a pin of MCU configured as general purpose output is connected to both

the Chip Select of the two L6470 devices; the SCLK output of SPI1 is

connected to both the CK inputs; the SPI1's MOSI from MCU goes into

SDI of the first L6470 device and the SDO of the second L6470 chip is

attached to the SPI1's MISO of MCU.

I'm here to ask help on how to pack data to proper form a valid SPI frame,

that send on the SPI bus, allow me to put L6470's commands.

At the moment I cannot receive any kind of data from one or more L6470

devices when I issue a GETSTATUS or a GETPARAM command to them.

Here I depict the SPI frame I sent on the SPI daisy chain bus when I want

to ask to the second L6470 device (the one whose SDO pin is connected to

the MISO) its STATUS register value, by means of a GETSTATUS command:

CS\ ---\ /---

\_____________________________________________/

----------> t

MOSI pin |CMD| NOP | NOP | NOP | NOP | NOP |

MISO pin |NOP| NOP | MSB | NOP | LSB | NOP |

Where: CMD = 0xD0

NOP = 0x00

STATUS = MSB << 8 | LSB

Sending the buffer [0xD0, 0x00, 0x00, 0x00, 0x00, 0x00] on the SPI bus

I am telling to the second device to give me its 16-bit status word that

I think to retrieve in the third received byte and in the 5th received byte.

Am I wrong?

3 REPLIES 3
S.Ma
Principal

Stm32 mosi to slave1 mosi, slave1 miso to slave2 mosi, slave2 miso to stm32 mosi

Now as clock master, stm32 must push as many bytes as needed to update all slaves. Check that slaves truly work as intended when pushing bytes to them... maybe the second sent byte became the second slave first byte and you are screwed.... check this first.

Muscle Man
Associate III

Thanks for you reply,

what I've learned is that in a daisy chain configuration the first byte sent in a frame

(for frame I mean all the bytes sent by MCU between a falling and a rising edge of

the Chip Select pin) will be the first byte that the last device will get.

After various attempts I learned that I cannot send a unique whole frame containing

all the commands and parameters of both devices, but break it in smaller frames.

For example, to send to both first and second device the GETSTATUS command

I don't have to send an unique frame with the following contents:

|------|------|------|------|------|------|
| 0xD0 | 0xD0 | 0x00 | 0x00 | 0x00 | 0x00 |
|------|------|------|------|------|------|

Instead I have to send three frame with following contents:

|------|------|
| 0xD0 | 0xD0 |
|------|------|
|------|------|
| 0x00 | 0x00 |
|------|------|
|------|------|
| 0x00 | 0x00 |
|------|------|

To me this is in contrast with the explanation of the protocol given in the L6470

datasheet (there the explanation is done with a focus for a single device)

I found another document (AN4290), written by ST employee Enrico Poli, where the

operation of device is described in greater detail than those made in the datasheet,

but also in the Enrico Poli documents there are (this is my opinion!) some things that

are not explicitly explained.

S.Ma
Principal

Ok so each slave behave like 8 bit **** register and latch data on nss rise edge. If you have spare pin, non daisy chain config is more efficient if speed is important.