Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 Ticker ticker_step; 00004 DigitalOut step(PB_0), dir(PB_1), en(PC_13); 00005 volatile int remain; 00006 00007 void toggle_step() { //产生STEP脉冲信号 00008 if(remain == 0) 00009 return; 00010 if(step){ 00011 step = 0; //STEP 1->0 00012 remain--; 00013 }else{ 00014 step = 1; //STEP 0->1 00015 } 00016 } 00017 00018 int main() { 00019 ticker_step.attach(&toggle_step, 0.0002); 00020 en = 0; //Enable stepper driver 00021 00022 while (true) { 00023 dir = 0; 00024 remain = 3200; 00025 wait(1.5); 00026 dir = 1; 00027 remain = 3200; 00028 wait(1.5); 00029 } 00030 }
Generated on Sun Jul 17 2022 00:49:03 by
1.7.2