thanks to Zoltan Hudak publish the way to use stm32f103c8t6 on mbed. now you can use it with stepper driver
Dependencies: mbed-STM32F103C8T6 mbed
Fork of STM32F103C8T6_Hello by
Diff: main.cpp
- Revision:
- 11:f44fc4db4ab1
- Parent:
- 10:4b88be251088
--- a/main.cpp Thu Sep 15 18:40:03 2016 +0000 +++ b/main.cpp Tue May 23 17:28:21 2017 +0000 @@ -1,20 +1,49 @@ #include "stm32f103c8t6.h" #include "mbed.h" - +#include "AccelStepper.h" + +AccelStepper stepper(1, PC_14, PC_15);//STEP DIR +Timer t; int main() { + + + confSysClock(); //Configure system clock (72MHz HSE clock, 48MHz USB clock) Serial pc(PA_2, PA_3); DigitalOut myled(LED1); + //PwmOut myled(LED1); + + t.start(); + stepper.setMaxSpeed(200); + stepper.setAcceleration(50); + stepper.moveTo(500); + stepper.setMinPulseWidth(50); + + + + while(1) { // The on-board LED is connected, via a resistor, to +3.3V (not to GND). // So to turn the LED on or off we have to set it to 0 or 1 respectively - myled = 0; // turn the LED on + /*myled = 1; + wait(0.2); + myled = 0; + wait(0.2); + */ + + if (stepper.distanceToGo() == 0) + stepper.moveTo(-stepper.currentPosition()); + stepper.run(); + + /*myled = myled + 0.01; // turn the LED on wait_ms(200); // 200 millisecond - myled = 1; // turn the LED off - wait_ms(1000); // 1000 millisecond - pc.printf("Blink\r\n"); + if (myled = 1.0){ // turn the LED off + myled = 0; + }*/ + //wait_ms(1000); // 1000 millisecond + //pc.printf("Blink\r\n"); } } \ No newline at end of file