X-CUBE-SPN1-20150128 example source code for one motor compiled under mbed. Tested OK on Nucleo F401. l6474.cpp is modified from original with defines in l6474_target_config.h to select the original behaviour (motor de-energised when halted), or new mode to continue powering with a (reduced) current in the coils (braking/position hold capability). On F401 avoid using mbed's InterruptIn on pins 10-15 (any port). Beware of other conflicts! L0 & F0 are included but untested.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
gregeric
Date:
Tue Oct 13 10:46:01 2015 +0000
Parent:
5:615cacd7d036
Commit message:
Ensure bridge is disabled before resetting the L6474.

Changed in this revision

IHM01A1/ihm01a1.h Show annotated file Show diff for this revision Revisions of this file
IHM01A1/l6474.cpp Show annotated file Show diff for this revision Revisions of this file
IHM01A1/stm32f0xx_nucleo_ihm01a1.h Show annotated file Show diff for this revision Revisions of this file
IHM01A1/stm32f4xx_nucleo_ihm01a1.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 615cacd7d036 -r 19c1b4a04c24 IHM01A1/ihm01a1.h
--- a/IHM01A1/ihm01a1.h	Fri Sep 18 12:10:45 2015 +0000
+++ b/IHM01A1/ihm01a1.h	Tue Oct 13 10:46:01 2015 +0000
@@ -44,7 +44,7 @@
 #include "motorcontrol.h"
 #include "l6474.h"
 
-#if defined TARGET_STM32F4
+#if defined TARGET_STM32F4 //TARGET_NUCLEO_F401RE
 #include "stm32f4xx_nucleo_ihm01a1.h"
 #elif defined TARGET_STM32F0
 #warning Untested platform!
diff -r 615cacd7d036 -r 19c1b4a04c24 IHM01A1/l6474.cpp
--- a/IHM01A1/l6474.cpp	Fri Sep 18 12:10:45 2015 +0000
+++ b/IHM01A1/l6474.cpp	Tue Oct 13 10:46:01 2015 +0000
@@ -556,6 +556,13 @@
     {
     /* Stop movement and disable power stage*/
     L6474_HardStop(loop);
+#ifdef L6474_CONF_BRAKE_WHEN_HALTED
+    /* Disable corresponding PWM */
+    BSP_MotorControlBoard_PwmStop(loop);
+
+    /* Disable power stage */
+    L6474_CmdDisable(loop);
+#endif
   }
     L6474_Reset();
   BSP_MotorControlBoard_Delay(1); // Reset pin must be forced low for at least 10us
diff -r 615cacd7d036 -r 19c1b4a04c24 IHM01A1/stm32f0xx_nucleo_ihm01a1.h
--- a/IHM01A1/stm32f0xx_nucleo_ihm01a1.h	Fri Sep 18 12:10:45 2015 +0000
+++ b/IHM01A1/stm32f0xx_nucleo_ihm01a1.h	Tue Oct 13 10:46:01 2015 +0000
@@ -53,10 +53,6 @@
   * @{
   */   
    
-/** @addtogroup STM32F0XX_NUCLEO_IHM01A1
-  * @{   
-  */   
-
 /** @defgroup IHM01A1_Board_Private_Function_Prototypes
   * @{
   */   
@@ -76,6 +72,10 @@
 uint8_t BSP_MotorControlBoard_SpiInit(void);   //Initialise the SPI used for L6474s
 uint8_t BSP_MotorControlBoard_SpiWriteBytes(uint8_t *pByteToTransmit, uint8_t *pReceivedByte, uint8_t nbDevices); //Write bytes to the L6474s via SPI
 
+/** @addtogroup STM32F0XX_NUCLEO_IHM01A1
+  * @{   
+  */   
+
    
 /* Exported Constants --------------------------------------------------------*/
    
diff -r 615cacd7d036 -r 19c1b4a04c24 IHM01A1/stm32f4xx_nucleo_ihm01a1.cpp
--- a/IHM01A1/stm32f4xx_nucleo_ihm01a1.cpp	Fri Sep 18 12:10:45 2015 +0000
+++ b/IHM01A1/stm32f4xx_nucleo_ihm01a1.cpp	Tue Oct 13 10:46:01 2015 +0000
@@ -73,7 +73,7 @@
 static SPI_HandleTypeDef SpiHandle;
 /// Timer handler for PWM1
 TIM_HandleTypeDef hTimPwm1;
-/// imer handler for PWM2
+/// Timer handler for PWM2
 TIM_HandleTypeDef hTimPwm2;
 /// Timer handler for PWM3
 TIM_HandleTypeDef hTimPwm3;