Created
May 13, 2015 23:47
-
-
Save d2rk/505bd380afedadd8f0cf to your computer and use it in GitHub Desktop.
Crawler board test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <propeller.h> | |
#include <stdlib.h> | |
#define STP1_PIN 19 | |
#define DIR1_PIN 18 | |
#define STP2_PIN 17 | |
#define DIR2_PIN 16 | |
#define STEP_DELAY 10 | |
#define PAUSE(time) waitcnt((time * (CLKFREQ / 1000)) + CNT) | |
int main() { | |
int i = 0; | |
DIRA |= 1 << STP1_PIN; | |
DIRA |= 1 << DIR1_PIN; | |
DIRA |= 1 << STP2_PIN; | |
DIRA |= 1 << DIR2_PIN; | |
while (1) { | |
OUTA |= 1 << DIR1_PIN; | |
OUTA |= 1 << DIR2_PIN; | |
for (i = 0; i < 100; i++) { | |
OUTA |= 1 << STP1_PIN; | |
OUTA |= 1 << STP2_PIN; | |
PAUSE(STEP_DELAY); | |
OUTA &= ~(1 << STP1_PIN); | |
OUTA &= ~(1 << STP2_PIN); | |
PAUSE(STEP_DELAY); | |
} | |
sleep(1); | |
OUTA &= ~(1 << DIR1_PIN); | |
OUTA &= ~(1 << DIR2_PIN); | |
for (i = 0; i < 100; i++) { | |
OUTA |= 1 << STP1_PIN; | |
OUTA |= 1 << STP2_PIN; | |
PAUSE(STEP_DELAY); | |
OUTA &= ~(1 << STP1_PIN); | |
OUTA &= ~(1 << STP2_PIN); | |
PAUSE(STEP_DELAY); | |
} | |
sleep(1); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment