background image

2.3.1.2

Motor control BSP

This BSP provides a common interface to access the driver functions of various motor drivers, such as 

L6206

,

L6474

powerSTEP01

STSPIN240

, etc. This is done via a couple of c/h files: MotorControl/motorcontrol.c/h,

which defines all the functions to configure and control the motor driver. These functions are then mapped to
the functions of the motor driver component used on the given expansion board via the structure file: motorDrv_t
(defined in Components\Common\motor.h).
This structure defines a list of function pointers filled during its instantiation in the corresponding motor driver
component.
For 

X-CUBE-SPN12

, the structure instance is called stspin240_250Drv (see file

BSP\Components\stspin240_250\stspin240_250.c)
As the motor control BSP is common for all motor driver expansion boards, some functions are not available for
all expansion boards. In this case, during the instantiation of the motorDrv_t structure in the driver component, the
unavailable functions are replaced by a null pointer.

2.3.1.3

Stspin240_250 BSP component

The stspin240_250 BSP component provides the driver functions of the 

STSPIN240

 low voltage dual brush DC

motor driver in the folder stm32_cube\Drivers\BSP\Components\stspin240_250, which contains:

stspin240_250.c:

 Stspin240_250 driver core functions

stspin240_250.h:

 declaration of the Stspin240_250 driver functions and their associated definitions

stspin240_250_target_config.h:

 parameter value setup for the 

STSPIN240

 (bridge configuration, number

of brush DC motors, bridge input PWMs frequency)

When used with an 

STSPIN240

 driver as in the case of the 

X-NUCLEO-IHM12A1

 expansion board, this

component requires the compilation flag declaration: STSPIN_240.

2.3.2

Project folder

For each 

STM32 Nucleo

 development board, the example projects are in the folder

stm32_cube\Projects\Multi\Examples\MotionControl\: IHM12A1_ExampleFor2BiDirMotors (examples of control
functions for two bidirectional brush DC motor driving).
There is a dedicated folder for the target IDE:

EWARM

 containing the project files for IAR

MDK-ARM

 containing the project files for Keil

STM32CubeIDE

 containing the project files for 

STM32CubeIDE

Each example also has the following code files:

inc\main.h

: main header file

inc\ stm32xxxx_hal_conf.h

: HAL configuration file

inc\stm32xxxx_it.h

 : header for the interrupt handler

src\main.c:

 main program (code of the example which is based on the motor control library for 

STSPIN240

)

src\stm32xxxx_hal_msp.c

: HAL initialization routines

src\stm32xxxx_it.c

: interrupt handler

src\system_stm32xxxx.c

: system initialization

src\clock_xx.c

: clock initialization

2.4

Software required resources

STSPIN240

 and the MCU communicate through GPIOs:

1 common GPIO for the flag interrupt (overcurrent detection or overtemperature protection) and the enable
pin

2 GPIOs to generate a PWM for each bridge input (PWMA and PWMB)

2 GPIOs for the bridge input phase and to set the motor direction (PHA/DIR_A and PHB/DIR_B)

1 GPIO to generate a PWM for REF level setup

1 GPIO to set/reset the reset pin

UM2110

Software required resources

UM2110

 - 

Rev 2

page 5/14

Summary of Contents for X-CUBE-SPN12

Page 1: ...R8 NUCLEO F030R8 or NUCLEO L053R8 development boards connected to an X NUCLEO IHM12A1 expansion board The software comes with a sample implementation driving two bidirectional low voltage dual brush DC motors RELATED LINKS Visit the STM32Cube ecosystem web page on www st com for further information Getting started with the X CUBE SPN12 low voltage dual brush DC motor driver software expansion for ...

Page 2: ...tion programming interface BSP Board support package CMSIS Cortex microcontroller software interface standard HAL Hardware abstraction layer SPI Serial port interface IDE Integrated development environment LED Light emitting diode UM2110 Acronyms and abbreviations UM2110 Rev 2 page 2 14 ...

Page 3: ...so use callback functions with the flag interrupt handler when a failure is reported by the STSPIN240 the error handler called by the library when it reports an error Then you can drive different brush DC motors by setting a specified running direction and by changing the maximum speed When a motor is requested to run the related bridge is automatically enabled A motion command can be stopped at a...

Page 4: ...BSP in the X CUBE SPN12 software provides the drivers to manage the STSPIN240 motor driver 2 3 Folder structure Figure 2 X CUBE SPN12 package folder structure The software is packaged in the following main folders Drivers STM32Cube HAL driver files which directly derive from the STM32Cube framework CMSIS folder with the CMSIS Cortex microcontroller software interface standard files from ARM These ...

Page 5: ...er value setup for the STSPIN240 bridge configuration number of brush DC motors bridge input PWMs frequency When used with an STSPIN240 driver as in the case of the X NUCLEO IHM12A1 expansion board this component requires the compilation flag declaration STSPIN_240 2 3 2 Project folder For each STM32 Nucleo development board the example projects are in the folder stm32_cube Projects Multi Examples...

Page 6: ...GPIO PA8 D7 Direction for B PHB DIR_B bridge GPIO PA0 TIM2 CH1 GPIO PA9 TIM1 CH2 GPIO PA0 TIM2 CH1 A0 or D8 for F0 REF GPIO PC7 D9 reset 2 5 APIs Detailed function and parameter descriptions for the user APIs are compiled in an HTML file in the software package Documentation folder X CUBE SPN12 software API is defined in the BSP motor control functions predefined through BSP_MotorControl_ Note Not...

Page 7: ... functionality of the STM32 Nucleo open development platform with a wide range of specialized expansion boards to choose from The STM32 Nucleo board does not require separate probes as it integrates the ST LINK V2 1 debugger programmer The STM32 Nucleo board comes with the comprehensive STM32 software HAL library together with various packaged software examples for different IDEs IAR EWARM Keil MD...

Page 8: ...ow voltage dual brush DC motor an external DC power supply with two electric cables up to 10 V a USB type A to mini B USB cable to connect the STM32 Nucleo to a PC laptop a Windows v 7 and above laptop or PC 3 3 Software requirements The following software components are needed for a suitable development environment for applications based on the motor driver expansion board ST LINK V2 1 USB driver...

Page 9: ...EO IHM12A1 bridge output connector A A and the second to connectors B B Step 4 Power on theX NUCLEO IHM12A1 expansion board by connecting its connectors Vin and Gnd to the DC power supply The DC supply must be set to deliver the required voltage to the three phase brushless motor Step 5 Open your preferred toolchain Step 6 Depending on the used STM32 Nucleo board open the software project from stm...

Page 10: ... Overview Section 2 2 Architecture Section 2 3 Folder structure Section 2 3 2 Project folder Section 3 3 Software requirements and Section 3 4 3 Setup to drive two bidirectional brush DC motors Removed Section 2 What is STM32Cube and Section 2 1 STM32Cube architecture and replaced them with a link in the Introduction UM2110 UM2110 Rev 2 page 10 14 ...

Page 11: ...cription 7 3 1 1 STM32 Nucleo 7 3 1 2 X NUCLEO IHM12A1 low voltage dual brush DC motor driver expansion board 8 3 2 Hardware requirements 8 3 3 Software requirements 8 3 4 Hardware and software setup 9 3 4 1 Common setup for all configurations 9 3 4 2 REF pin setup on X NUCLEO IHM12A1 expansion board 9 3 4 3 Setup to drive two bidirectional brush DC motors 9 Revision history 10 Contents 11 List of...

Page 12: ...List of tables Table 1 List of acronyms 2 Table 2 Required resources for the X CUBE SPN12 software 6 Table 3 Document revision history 10 UM2110 List of tables UM2110 Rev 2 page 12 14 ...

Page 13: ... Figure 1 X CUBE SPN12 software architecture 3 Figure 2 X CUBE SPN12 package folder structure 4 Figure 3 STM32 Nucleo board 7 Figure 4 X NUCLEO IHM12A1 expansion board 8 UM2110 List of figures UM2110 Rev 2 page 13 14 ...

Page 14: ...cts and ST assumes no liability for application assistance or the design of Purchasers products No license express or implied to any intellectual property right is granted by ST herein Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product ST and the ST logo are trademarks of ST For additional information about S...

Reviews: