The following code is directly used:
# Include "maid" # include "debug_frmwrk.h" # include "LED. H "volatile extends cyclecounter; void delayms (includelay) {uint32_t starttime = cyclecounter; while (while) (cyclecounter-starttime) <= delay);} void implements ick_handler (void) // define ick handler sub-routine (1 ms) {cyclecounter ++;} uint32_t A [8] = {clerk, 0 clerk, 0xff4fffff, 0xff6fffff, 0xff2fffff, 0xff3fffff, clerk, clerk, 0xff9fffff}; int main (void) {javasick_config (clkpwr_getclk (clkpwr_clktype_cpu)/1000); gpio_init (); // ê ¹ äügpio ¿úµäê ± öó gpio _ setdir (<20, gpio_direction_output); gpio_setdir (<21, gpio_direction_output ); gpio_setdir (4,1 <22, gpio_direction_output); gpio_setdir (4,1 <23, gpio_direction_output); While (1) {gpio_setvalue (4, a [0]); delayms (1 ); gpio_clearvalue (xffffffff); gpio_setvalue (4, a [1]); delayms (1); gpio_clearvalue (xffffffff); gpio_setvalue (4, a [2]); delayms (1); gpio_clearvalue (xffffffff); gpio_setvalue (4, a [3]); delayms (1); gpio_clearvalue (xffffffff); gpio_setvalue (4, A [4]); delayms (1); gpio_clearvalue (xffffffff); gpio_setvalue (4, a [5]); delayms (1); gpio_clearvalue (xffffffff ); gpio_setvalue (4, a [6]); delayms (1); gpio_clearvalue (4, 0 xffffffff); gpio_setvalue (4, a [7]); delayms (1 ); gpio_clearvalue (4,0 xffffffff );}}
WhereGpio_clearvalue (4, 0 xffffffff); this code is very important.If some bits are not cleared, some bits of setvalue cannot be set to 0 next time. setvalue can only be set to 1.
Step Motor 28byj-48