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.
Diff: IHM01A1/l6474.cpp
- Revision:
- 6:19c1b4a04c24
- Parent:
- 0:b9444a40a999
--- 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