AN4290
Application note
L647x, L648x and powerSTEP01 family communication protocol
Enrico Poli
Introduction
The L6470, L6472, L6474, L648x and powerSTEP01 devices provide advanced features
and high programmability. The devices are controlled by a host microcontroller through
a fast SPI interface compliant with the daisy chain configuration.
This document describes how the SPI communication protocol is implemented and it gives
some suggestions about the application design.
The features of the different parts and the current control algorithms (voltage mode driving,
predictive current control and auto-adjusted decay) are not investigated in this document.
Please refer to the respective application notes.
March 2015
DocID024501 Rev 2
1/16
www.st.com
16
Contents
AN4290
Contents
1
SPI communication interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Communication protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Reading and writing registers (GetParam and SetParam commands) . . . . . . . . . . 6
Releasing the failure flags (GetStatus command) . . . . . . . . . . . . . . . . . . . . . . . . . 10
No operation command (NOP). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Motion commands (L6470, L6472, L648x and powerSTEP01 only) . . . . . . . . . . . 11
2
3
Daisy chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2/16
DocID024501 Rev 2
AN4290
SPI communication interface
1
SPI communication interface
The devices (always slave) can be driven by an MCU (always master) sending commands
through an 8-bit SPI interface. The 8-bit shift register of the device is kept enabled while CS
input is forced low. During this time, at every raising edge of the serial clock (CK) the SDI
input is stored into the shift register. At CK falling edges the SDO output is updated
according to the last bit of the shift register (see
Figure 1).
When the CS input is raised, the device catches the shift register content and interprets its
value as a command or an argument of the command received previously.
All the bytes are transmitted starting from the most significant bit.
At every transmission cycle, that is the time between the falling and raising edge of the CS
line, the number of bytes transmitted by the master is equal to those received.
Figure 1. SPI interface structure
Tx Buffer
8
CK
SDI
CS
1
Shift register
LOAD
0
SDO
8
Rx Buffer
AM16745v1
Communication protocol
The communication protocol is based on single byte commands that can be followed by
a command argument up to 3 bytes long.
Part of the information needed to execute the target operation could be embedded into the
command byte, that is the target direction for the Run command, and the argument provides
the extra data as well as the target position of the GoTo command.
When a command requires an argument, it has to be transmitted starting from the most
significant byte. The command is not completed and it is not executed until all the argument
bytes are received by the device. It is not possible for the transmission of a command to be
aborted once it is started; the command has to be completed and a new command can be
used. The flow chart of the communication protocol is shown in
Figure 2.
DocID024501 Rev 2
3/16
16
SPI communication interface
Figure 2. Communication protocol flow chart
AN4290
IDLE
(waiting for a command byte)
EXECUTE
(command is executed)
NO
More argument
bytes are needed?
YES
YES
New byte
is received?
New byte
is received?
NO
Decode
Waiting for an
argument byte
YES
NO
Is the command
valid?
YES
NO
Argument
bytes are needed?
AM16746v1
By default the response byte of the device is h00 (hexadecimal format). Some commands,
for example those used to read the value of a register, generate a response from the device
up to 3 bytes long which is transmitted during the following transmission cycles.
When a command returns a response, it is transmitted during the following transmission
cycles starting from the most significant byte.The MCU transmits a byte (command or
argument) for each response byte that is transmitted.
The number of required argument bytes and the number of returned response bytes for
each command are listed in
Table 1
(the zero value implies that no argument is requested or
that no response is generated).
4/16
DocID024501 Rev 2
AN4290
Table 1. Command list
Command
NOP
SetParam
GetParam
Run
(1)
Move
(1)
GoTo
(1)
GoTo_DIR
(1)
GoHome
(1)
GoMark
(1)
GoUntil
(1)
ReleaseSW
(1)
StepClock
(1)
SoftStop
(1)
HardStop (enable in L6474)
SoftHiZ
(1)
HardHiz
(disable in L6474)
ResetPos
(1)
ResetDevice
(1)
GetStatus
Argument length Response length
[byte]
0
According to the
target register
0
3
3
3
3
0
0
3
0
0
0
0
0
0
0
0
0
[byte]
0
0
According to the
target register
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
SPI communication interface
Notes
Some registers are read only. Some registers
can be set in specific conditions only.
Available only if the motor is stopped.
Available only if a previous command is not
under execution (not BUSY).
Available only if a previous command is not
under execution (not BUSY).
Available only if a previous command is not
under execution (not BUSY).
Available only if a previous command is not
under execution (not BUSY).
Available only if the motor is stopped.
1. Available in L6470, L6472, L648x and powerSTEP01 devices only.
DocID024501 Rev 2
5/16
16